From 4395d9c624e052e6ffc0a065d7b7e28c40ed75b5 Mon Sep 17 00:00:00 2001 From: Axel Cocat Date: Thu, 29 Dec 2022 11:54:55 +0100 Subject: [PATCH] feat: add Player:GetMailCount() (#76) --- src/LuaEngine/LuaFunctions.cpp | 1 + src/LuaEngine/PlayerMethods.h | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) 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. *