diff options
| author | Gargarensis <gabririchi@yahoo.it> | 2017-01-04 01:48:38 +0100 |
|---|---|---|
| committer | Yehonal <yehonal.azeroth@gmail.com> | 2017-03-26 01:09:32 +0100 |
| commit | a870e5fae4f54e3475b0eff8d235f1ffe006e8df (patch) | |
| tree | 311cceb6cacefd969ebd31131bde477afa59aa4a | |
| parent | 384ff412bf3beeed9178d65df0cd50add27901bd (diff) | |
hook before a player buys something
| -rw-r--r-- | src/game/Entities/Player/Player.cpp | 7 | ||||
| -rw-r--r-- | src/game/Scripting/ScriptMgr.cpp | 5 | ||||
| -rw-r--r-- | src/game/Scripting/ScriptMgr.h | 4 |
3 files changed, 16 insertions, 0 deletions
diff --git a/src/game/Entities/Player/Player.cpp b/src/game/Entities/Player/Player.cpp index 702ff7834a..2c2abb6da0 100644 --- a/src/game/Entities/Player/Player.cpp +++ b/src/game/Entities/Player/Player.cpp @@ -73,6 +73,7 @@ #include "PoolMgr.h" #include "SavingSystem.h" #include "TicketMgr.h" +#include "ScriptMgr.h" #define ZONE_UPDATE_INTERVAL (2*IN_MILLISECONDS) @@ -21573,6 +21574,12 @@ inline bool Player::_StoreOrEquipNewItem(uint32 vendorslot, uint32 item, uint8 c // Return true is the bought item has a max count to force refresh of window by caller bool Player::BuyItemFromVendorSlot(uint64 vendorguid, uint32 vendorslot, uint32 item, uint8 count, uint8 bag, uint8 slot) { + sScriptMgr->OnBeforeBuyItemFromVendor(this, vendorguid,vendorslot,item,count,bag,slot); + + // this check can be used from the hook to implement a custom vendor process + if (item == 0) + return true; + // cheating attempt if (count < 1) count = 1; diff --git a/src/game/Scripting/ScriptMgr.cpp b/src/game/Scripting/ScriptMgr.cpp index 98ae415d8c..d5a851ae8c 100644 --- a/src/game/Scripting/ScriptMgr.cpp +++ b/src/game/Scripting/ScriptMgr.cpp @@ -1530,6 +1530,11 @@ void ScriptMgr::OnPlayerMove(Player* player, MovementInfo movementInfo, uint32 o FOREACH_SCRIPT(MovementHandlerScript)->OnPlayerMove(player, movementInfo, opcode); } +void ScriptMgr::OnBeforeBuyItemFromVendor(Player* player, uint64 vendorguid, uint32 vendorslot, uint32 item, uint8 count, uint8 bag, uint8 slot) +{ + FOREACH_SCRIPT(PlayerScript)->OnBeforeBuyItemFromVendor(player, vendorguid, vendorslot, item, count, bag, slot);; +} + AllMapScript::AllMapScript(const char* name) : ScriptObject(name) { diff --git a/src/game/Scripting/ScriptMgr.h b/src/game/Scripting/ScriptMgr.h index 078a81c75f..831098f39b 100644 --- a/src/game/Scripting/ScriptMgr.h +++ b/src/game/Scripting/ScriptMgr.h @@ -882,6 +882,9 @@ class PlayerScript : public ScriptObject //After receiving item as a quest reward virtual void OnQuestRewardItem(Player* player, Item* item, uint32 count) { } + //Before buying something from any vendor + virtual void OnBeforeBuyItemFromVendor(Player* player, uint64 vendorguid, uint32 vendorslot, uint32 item, uint8 count, uint8 bag, uint8 slot); + }; class GuildScript : public ScriptObject @@ -1191,6 +1194,7 @@ class ScriptMgr void OnLootItem(Player* player, Item* item, uint32 count, uint64 lootguid); void OnCreateItem(Player* player, Item* item, uint32 count); void OnQuestRewardItem(Player* player, Item* item, uint32 count); + void OnBeforeBuyItemFromVendor(Player* player, uint64 vendorguid, uint32 vendorslot, uint32 item, uint8 count, uint8 bag, uint8 slot); public: /* GuildScript */ |
