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