Advertisement
randy336

[Trinity] Faction / Race Npc Changer

Mar 20th, 2013
1,894
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.13 KB | None | 0 0
  1. /*
  2. <--------------------------------------------------------------------------->
  3.  - Developer(s): Ghostcrawler336
  4.  - Complete: 100%
  5.  - ScriptName: 'Faction / Race Changer'
  6.  - Comment: Untested
  7.  - Updated - 8/7/2013 or 7/8/2013
  8. <--------------------------------------------------------------------------->
  9. */
  10. #include "ScriptPCH.h"
  11.  
  12. enum  defines
  13. {
  14.  faction_token = 100, // Faction Change Token
  15.  race_token = 100 // Race Change Token
  16. };
  17.  
  18. class npc_changer : public CreatureScript
  19. {
  20.     public:
  21.         npc_changer() : CreatureScript("npc_changer"){}
  22.  
  23.         bool OnGossipHello(Player * pPlayer, Creature * pCreature)
  24.         {
  25.            
  26.            
  27.             pPlayer->ADD_GOSSIP_ITEM(4, "Change My Race ", GOSSIP_SENDER_MAIN, 0);
  28.             pPlayer->ADD_GOSSIP_ITEM(4, "Change My Faction", GOSSIP_SENDER_MAIN, 1);
  29.             pPlayer->PlayerTalkClass->SendGossipMenu(9425, pCreature->GetGUID());
  30.             return true;
  31.         }
  32.  
  33.         bool OnGossipSelect(Player * Player, Creature * Creature, uint32 /*uiSender*/, uint32 uiAction)
  34.         {
  35.             if(!Player)
  36.                 return true;
  37.  
  38.             switch(uiAction)
  39.             {
  40.                 case 0:
  41.                     if(Player->HasItemCount(race_token, 1))
  42.                     {
  43.                         Player->DestroyItemCount(race_token, 1, true, false);
  44.                         Player->SetAtLoginFlag(AT_LOGIN_CHANGE_RACE);
  45.                         Player->GetSession()->SendNotification("You need to relog, to change your race!");
  46.                         Player->PlayerTalkClass->SendCloseGossip();
  47.                     }
  48.                     else
  49.                     {
  50.                         Player->GetSession()->SendNotification("You need atleast one race change token!");
  51.                         Player->PlayerTalkClass->SendCloseGossip();
  52.                     }
  53.                     break;
  54.                 case 1:
  55.                     if(Player->HasItemCount(faction_token, 1))
  56.                     {
  57.                         Player->DestroyItemCount(faction_token, 1, true, false);
  58.                         Player->SetAtLoginFlag(AT_LOGIN_CHANGE_FACTION);
  59.                         Player->GetSession()->SendNotification("You need to relog, to change your faction!");
  60.                         Player->PlayerTalkClass->SendCloseGossip();
  61.                     }
  62.                     else
  63.                     {
  64.                         Player->GetSession()->SendNotification("You need atleast one faction change token!");
  65.                         Player->PlayerTalkClass->SendCloseGossip();
  66.                     }
  67.                     break;
  68.             }
  69.             return true;
  70.         }
  71.  
  72. };
  73.  
  74. void AddSC_npc_changer()
  75. {
  76.     new npc_changer();
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement