Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "ScriptMgr.h"
- #include "ScriptedCreature.h"
- #include "ScriptedGossip.h"
- #include "Player.h"
- #include <cstring>
- struct VendorData
- {
- uint32 rank;
- uint32 required_kills;
- uint32 entry;
- };
- // {vendor rank (1-14), required kills to use vendor, vendor entry}
- static VendorData const Vendors[] = {
- {1, 10, 800001},
- {2, 50, 800002},
- {3, 100, 800003},
- {4, 250, 800004},
- {5, 500, 800005},
- {6, 750, 800006},
- {7, 1000, 800007},
- {8, 1500, 800008},
- {9, 2000, 800009},
- {10, 2500, 800010},
- {11, 3000, 800011},
- {12, 3500, 800012},
- {13, 4000, 800013},
- {14, 5000, 800014},
- };
- class ArrayVendor : public CreatureScript
- {
- public:
- ArrayVendor() : CreatureScript("ArrayVendor")
- {
- }
- bool OnGossipHello(Player* player, Creature* creature) override
- {
- uint32 const playerHKs = player->GetUInt32Value(PLAYER_FIELD_LIFETIME_HONORABLE_KILLS);
- for (auto& data : Vendors)
- {
- uint32 vendorRank = (800000 - data.rank);
- if (playerHKs < data.required_kills)
- {
- std::ostringstream ss;
- ss << "The required rank to use this vendor is rank " << data.rank << "\nYou need " << (data.required_kills - playerHKs) << " more honorable kills to reach rank " << data.rank;
- player->GetSession()->SendAreaTriggerMessage(ss.str().c_str());
- player->CLOSE_GOSSIP_MENU();
- return true;
- }
- else
- {
- player->GetSession()->SendListInventory(creature->GetGUID());
- return true;
- }
- }
- }
- };
- void AddSC_ArrayVendor()
- {
- new ArrayVendor();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement