added return of first sent items guid

- get the guid of the first item generated in the mail and return it to lua

- declaration of mailGUID to check if data was already pushed to lua in a previous walkthrough of the while loop, in case there are multiple items added
This commit is contained in:
55Honey
2021-03-11 10:46:46 +01:00
parent 5ce4b51ac2
commit c04b0d1c4a

View File

@@ -2128,6 +2128,7 @@ 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);
@@ -2156,6 +2157,13 @@ namespace LuaGlobalFunctions
item->SaveToDB();
#endif
draft.AddItem(item);
if (!mailGUID > 0)
{
mailGUID = item->GetGUIDLow();
Eluna::Push(L, mailGUID);
}
++addedItems;
}
}
@@ -2167,7 +2175,7 @@ namespace LuaGlobalFunctions
#else
draft.SendMailTo(MailReceiver(receiverPlayer, MAKE_NEW_GUID(receiverGUIDLow, 0, HIGHGUID_PLAYER)), sender);
#endif
return 0;
return 1;
}
/**