Advertisement
Guest User

Script

a guest
Jan 22nd, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.02 KB | None | 0 0
  1. #include "ScriptPCH.h"
  2. #include "Player.h"
  3. #include "ScriptMgr.h"
  4. #include "ScriptedGossip.h"
  5.  
  6. #define SELECT_DP_VP "SELECT `vote` FROM account WHERE id = '%u'"
  7.  
  8. class Npc_Show_Points : public CreatureScript
  9. {
  10. public:
  11.         Npc_Show_Points() : CreatureScript("Npc_Show_Points") { }
  12.  
  13.         bool OnGossipHello(Player* player, Creature* creature)
  14.         {
  15.                 AddGossipItemFor(player, GOSSIP_ICON_CHAT, "Show My Vote Points", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
  16.                 AddGossipItemFor(player, GOSSIP_ICON_CHAT, "Close", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2);
  17.  
  18.                 player->PlayerTalkClass->SendGossipMenu(1, creature->GetGUID());      
  19.                 return true;
  20.         }
  21.  
  22.         bool OnGossipSelect(Player * player, Creature * creature, uint32 sender, uint32 uiAction)
  23.         {
  24.                 QueryResult result = LoginDatabase.PQuery(SELECT_DP_VP, player->GetSession()->GetAccountId());
  25.  
  26.                 if(!result)
  27.                 {
  28.                         player->GetSession()->SendAreaTriggerMessage("Error");
  29.                         return false;
  30.                 }
  31.  
  32.                 Field* fields = result->Fetch();
  33.                 uint32 vp = fields[0].GetUInt32();
  34.  
  35.                 if (sender == GOSSIP_SENDER_MAIN)
  36.                 {
  37.                         player->PlayerTalkClass->ClearMenus();
  38.                         switch(uiAction)
  39.                         {
  40.                                                 case 1:
  41.                                 player->GetSession()->SendAreaTriggerMessage("Vote Points: %u", vp);
  42.                                 player->CLOSE_GOSSIP_MENU();
  43.                                 break;
  44.  
  45.                                                 case 3:
  46.                                 player->CLOSE_GOSSIP_MENU();
  47.                                 break;    
  48.                         }
  49.                 }
  50.                 return true;
  51.         }
  52. };
  53.  
  54. void AddSC_Npc_Show_Points()
  55. {
  56.         new Npc_Show_Points();
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement