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"
- #define SELECT_DP_VP "SELECT `vote` FROM account WHERE id = '%u'"
- class Npc_Show_Points : public CreatureScript
- {
- public:
- Npc_Show_Points() : CreatureScript("Npc_Show_Points") { }
- bool OnGossipHello(Player* player, Creature* creature)
- {
- AddGossipItemFor(player, GOSSIP_ICON_CHAT, "Show My Vote Points", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
- AddGossipItemFor(player, GOSSIP_ICON_CHAT, "Close", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2);
- player->PlayerTalkClass->SendGossipMenu(1, creature->GetGUID());
- return true;
- }
- bool OnGossipSelect(Player * player, Creature * creature, uint32 sender, uint32 uiAction)
- {
- QueryResult result = LoginDatabase.PQuery(SELECT_DP_VP, player->GetSession()->GetAccountId());
- if(!result)
- {
- player->GetSession()->SendAreaTriggerMessage("Error");
- return false;
- }
- Field* fields = result->Fetch();
- uint32 vp = fields[0].GetUInt32();
- if (sender == GOSSIP_SENDER_MAIN)
- {
- player->PlayerTalkClass->ClearMenus();
- switch(uiAction)
- {
- case 1:
- player->GetSession()->SendAreaTriggerMessage("Vote Points: %u", vp);
- player->CLOSE_GOSSIP_MENU();
- break;
- case 3:
- player->CLOSE_GOSSIP_MENU();
- break;
- }
- }
- return true;
- }
- };
- void AddSC_Npc_Show_Points()
- {
- new Npc_Show_Points();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement