diff --git a/src/LuaEngine/LuaFunctions.cpp b/src/LuaEngine/LuaFunctions.cpp index ede5e4a..643110d 100644 --- a/src/LuaEngine/LuaFunctions.cpp +++ b/src/LuaEngine/LuaFunctions.cpp @@ -471,6 +471,7 @@ ElunaRegister PlayerMethods[] = { "GetItemByPos", &LuaPlayer::GetItemByPos }, { "GetItemByEntry", &LuaPlayer::GetItemByEntry }, { "GetItemByGUID", &LuaPlayer::GetItemByGUID }, + { "GetMailCount", &LuaPlayer::GetMailCount }, { "GetMailItem", &LuaPlayer::GetMailItem }, { "GetReputation", &LuaPlayer::GetReputation }, { "GetEquippedItemBySlot", &LuaPlayer::GetEquippedItemBySlot }, diff --git a/src/LuaEngine/PlayerMethods.h b/src/LuaEngine/PlayerMethods.h index a01e8c4..093a832 100644 --- a/src/LuaEngine/PlayerMethods.h +++ b/src/LuaEngine/PlayerMethods.h @@ -1416,6 +1416,26 @@ namespace LuaPlayer return 1; } + /** + * Returns the amount of mails in the player's mailbox. + * + * @return uint32 mailCount + */ + int GetMailCount(lua_State* L, Player* player) + { + const CharacterCacheEntry* cache = sCharacterCache->GetCharacterCacheByGuid(player->GetGUID()); + if (cache) + { + Eluna::Push(L, static_cast(cache->MailCount)); + } + else + { + Eluna::Push(L, player->GetMailSize()); + } + + return 1; + } + /** * Returns a mailed [Item] by guid. *