Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "ScriptPCH.h"
- #include "Player.h"
- #include "ScriptMgr.h"
- #include "ScriptedGossip.h"
- #include "ScriptedCreature.h"
- #include "WorldSession.h"
- #include "LoginDatabase.h"
- #include "QueryResult.h"
- #include "SmartAI.h"
- #include "Field.h"
- #include "DatabaseWorkerPool.h"
- #include "DatabaseLoader.h"
- #include "DatabaseEnv.h"
- #include "GossipDef.h"
- #define ACP "SELECT `acp` FROM account WHERE id = '%u'"
- class Npc_Show_Points : public CreatureScript
- {
- public:
- Npc_Show_Points() : CreatureScript("Npc_Show_Points") { }
- static bool OnGossipHello(Player* player, Creature* creature)
- {
- AddGossipItemFor(player, 5, "Show My Vote Points", GOSSIP_SENDER_MAIN, 1);
- AddGossipItemFor(player, 7, "Close", GOSSIP_SENDER_MAIN, 2);
- SendGossipMenuFor(player, DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
- return true;
- }
- static bool OnGossipSelect(Player * player, Creature * creature, uint32 sender, uint32 Action)
- QueryResult result = LoginDatabase.PQuery(ACP, player->GetSession()->GetAccountId());
- if(!result)
- {
- player->GetSession()->SendAreaTriggerMessage("Error");
- return false;
- }
- Field* fields = result->Fetch();
- uint32 acp = fields[0].GetUInt32();
- player->PlayerTalkClass->ClearMenus();
- if (sender == GOSSIP_SENDER_MAIN)
- {
- switch(uiAction)
- {
- case 1:
- player->GetSession()->SendAreaTriggerMessage("Vote Points: %u", acp);
- CloseGossipMenuFor(player);
- break;
- case 2:
- CloseGossipMenuFor(player);
- break;
- }
- }
- return true;
- }
- struct npcshowpointsAI : public ScriptedAI
- {
- npcshowpointsAI(Creature* creature)
- : ScriptedAI(creature) { }
- bool GossipHello(Player* player) override
- {
- return OnGossipHello(player, me);
- }
- bool GossipSelect(Player* player, uint32 menuId, uint32 gossipListId) override
- {
- uint32 const sender = player->PlayerTalkClass->GetGossipOptionSender(gossipListId);
- uint32 const action = player->PlayerTalkClass->GetGossipOptionAction(gossipListId);
- return OnGossipSelect(player, me, sender, action);
- }
- };
- CreatureAI* GetAI(Creature* creature) const override
- {
- return new npcshowpointsAI(creature);
- }
- };
- void AddSC_Npc_Show_Points()
- {
- new Npc_Show_Points();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement