new approach: multiple variables

Return the guid of items created by SendMail for Azerothcore.
Syntax:
item1, item2, item3, ... = SendMail(subject, text, receiverGUIDLow, senderGUIDLow, stationary, delay, money, cod, entry1, amount1, entry2, amount2, entry3, amount3...)
This commit is contained in:
55Honey
2021-03-13 20:55:25 +01:00
parent 2074daf065
commit 620cb0ff15

View File

@@ -2128,7 +2128,6 @@ namespace LuaGlobalFunctions
SQLTransaction trans = CharacterDatabase.BeginTransaction(); SQLTransaction trans = CharacterDatabase.BeginTransaction();
#endif #endif
uint8 addedItems = 0; uint8 addedItems = 0;
uint32 mailGUID = 0;
while (addedItems <= MAX_MAIL_ITEMS && i + 2 <= argAmount) while (addedItems <= MAX_MAIL_ITEMS && i + 2 <= argAmount)
{ {
uint32 entry = Eluna::CHECKVAL<uint32>(L, ++i); uint32 entry = Eluna::CHECKVAL<uint32>(L, ++i);
@@ -2157,17 +2156,9 @@ namespace LuaGlobalFunctions
item->SaveToDB(); item->SaveToDB();
#endif #endif
draft.AddItem(item); draft.AddItem(item);
if (mailGUID <= 0)
{
#if defined AZEROTHCORE #if defined AZEROTHCORE
mailGUID = item->GetGUIDLow(); Eluna::Push(L, item->GetGUIDLow());
#elif defined TRINITY
mailGUID = item->GetGUID();
#endif #endif
Eluna::Push(L, mailGUID);
}
++addedItems; ++addedItems;
} }
} }
@@ -2179,8 +2170,8 @@ namespace LuaGlobalFunctions
#else #else
draft.SendMailTo(MailReceiver(receiverPlayer, MAKE_NEW_GUID(receiverGUIDLow, 0, HIGHGUID_PLAYER)), sender); draft.SendMailTo(MailReceiver(receiverPlayer, MAKE_NEW_GUID(receiverGUIDLow, 0, HIGHGUID_PLAYER)), sender);
#endif #endif
#if defined TRINITY || AZEROTHCORE #if defined AZEROTHCORE
return 1; return addedItems;
#else #else
return 0; return 0;
#endif #endif