daily pastebin goal
36%
SHARE
TWEET

Untitled

a guest Jan 23rd, 2018 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "ScriptPCH.h"
  2. #include "Player.h"
  3. #include "ScriptMgr.h"
  4. #include "ScriptedGossip.h"
  5. #include "ScriptedCreature.h"
  6. #include "WorldSession.h"
  7. #include "LoginDatabase.h"
  8. #include "QueryResult.h"
  9. #include "SmartAI.h"
  10. #include "Field.h"
  11. #include "DatabaseWorkerPool.h"
  12. #include "DatabaseLoader.h"
  13. #include "DatabaseEnv.h"
  14. #include "GossipDef.h"
  15.  
  16.  
  17. #define ACP "SELECT `acp` FROM account WHERE id = '%u'"
  18.  
  19. class Npc_Show_Points : public CreatureScript
  20.  
  21. {
  22. public:
  23.         Npc_Show_Points() : CreatureScript("Npc_Show_Points") { }
  24.  
  25.         static bool OnGossipHello(Player* player, Creature* creature)
  26.         {
  27.                 AddGossipItemFor(player, 5, "Show My Vote Points", GOSSIP_SENDER_MAIN, 1);
  28.                 AddGossipItemFor(player, 7, "Close", GOSSIP_SENDER_MAIN, 2);
  29.                
  30.                 SendGossipMenuFor(player, DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
  31.  
  32.                 return true;
  33.         }
  34.        
  35.         static bool OnGossipSelect(Player * player, Creature * creature, uint32 sender, uint32 Action)
  36.  
  37.                 QueryResult result = LoginDatabase.PQuery(ACP, player->GetSession()->GetAccountId());
  38.  
  39.                 if(!result)
  40.                 {
  41.                         player->GetSession()->SendAreaTriggerMessage("Error");
  42.                         return false;
  43.                 }
  44.  
  45.                 Field* fields = result->Fetch();
  46.                 uint32 acp = fields[0].GetUInt32();
  47.  
  48.                 player->PlayerTalkClass->ClearMenus();
  49.  
  50.                 if (sender == GOSSIP_SENDER_MAIN)
  51.                 {
  52.                         switch(uiAction)
  53.                         {
  54.                                                 case 1:
  55.                                 player->GetSession()->SendAreaTriggerMessage("Vote Points: %u", acp);
  56.                                 CloseGossipMenuFor(player);
  57.                                 break;
  58.  
  59.                                                 case 2:
  60.                                 CloseGossipMenuFor(player);
  61.                                 break;    
  62.                         }
  63.                 }
  64.                 return true;
  65.         }
  66.  
  67.  
  68. struct npcshowpointsAI : public ScriptedAI
  69.         {
  70.                 npcshowpointsAI(Creature* creature)
  71.                         : ScriptedAI(creature) { }
  72.                
  73.                 bool GossipHello(Player* player) override
  74.                 {
  75.                         return OnGossipHello(player, me);
  76.                 }
  77.                
  78.                 bool GossipSelect(Player* player, uint32 menuId, uint32 gossipListId) override
  79.                 {
  80.                         uint32 const sender = player->PlayerTalkClass->GetGossipOptionSender(gossipListId);
  81.                         uint32 const action = player->PlayerTalkClass->GetGossipOptionAction(gossipListId);
  82.                         return OnGossipSelect(player, me, sender, action);
  83.                 }
  84.         };
  85.  
  86.         CreatureAI* GetAI(Creature* creature) const override
  87.         {
  88.                 return new npcshowpointsAI(creature);
  89.         }
  90.  
  91. };
  92.  
  93.  
  94. void AddSC_Npc_Show_Points()
  95. {
  96.         new Npc_Show_Points();
  97. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top