From 2920ddd67526f809439bf6ee07b4eb527a23ad4b Mon Sep 17 00:00:00 2001 From: Axel Cocat Date: Sat, 4 Jun 2022 21:13:55 +0200 Subject: [PATCH] fix AddLoot --- src/LuaEngine/GameObjectMethods.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/LuaEngine/GameObjectMethods.h b/src/LuaEngine/GameObjectMethods.h index 0ffbf2c..f51e26a 100644 --- a/src/LuaEngine/GameObjectMethods.h +++ b/src/LuaEngine/GameObjectMethods.h @@ -245,9 +245,7 @@ namespace LuaGameObject int AddLoot(lua_State* L, GameObject* go) { - int i = 0; - uint32 entry = Eluna::CHECKVAL(L, ++i); - uint32 amount = Eluna::CHECKVAL(L, ++i, 1); + int i = 1; int argAmount = lua_gettop(L); #if defined TRINITY || defined AZEROTHCORE @@ -281,7 +279,7 @@ namespace LuaGameObject #else item->SaveToDB(); #endif - LootStoreItem storeItem = LootStoreItem(item->GetEntry(), 0, 100, 0, LOOT_MODE_DEFAULT, 0, 1, 1); + LootStoreItem storeItem(item->GetEntry(), 0, 100, 0, LOOT_MODE_DEFAULT, 0, item->GetCount(), item->GetCount()); go->loot.AddItem(storeItem); #if defined TRINITY || AZEROTHCORE Eluna::Push(L, item->GetGUID().GetCounter()); @@ -291,6 +289,11 @@ namespace LuaGameObject ++addedItems; } } + +#if defined TRINITY || AZEROTHCORE + CharacterDatabase.CommitTransaction(trans); +#endif + return addedItems; }