Advertisement
Guest User

Faction/Race/Rename/Customize change NPC

a guest
Oct 24th, 2013
281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.48 KB | None | 0 0
  1. /*
  2. <--------------------------------------------------------------------------->
  3. - Developer(s): Ghostcrawler336
  4. - Fixed Compile Errors: Wise
  5. - Complete: 100%
  6. - ScriptName: 'npc_changer'
  7. - Comment: Tested.
  8. - Updated: 24/10/13.
  9. <--------------------------------------------------------------------------->
  10. */
  11. #include "ScriptPCH.h"
  12.  
  13. enum defines
  14. {
  15. faction_token = 100, // Faction Change Token
  16. race_token = 100, // Race Change Token
  17. customize_token = 100, // Customize Change Token
  18. rename_token = 100, // Rename Change Token
  19. };
  20.  
  21. class npc_changer : public CreatureScript
  22. {
  23. public:
  24. npc_changer() : CreatureScript("npc_changer"){}
  25.  
  26. bool OnGossipHello(Player * pPlayer, Creature * pCreature)
  27. {
  28.  
  29.  
  30. pPlayer->ADD_GOSSIP_ITEM(4, "Change My Race ", GOSSIP_SENDER_MAIN, 0);
  31. pPlayer->ADD_GOSSIP_ITEM(4, "Change My Faction", GOSSIP_SENDER_MAIN, 1);
  32. pPlayer->ADD_GOSSIP_ITEM(4, " Customize My Character", GOSSIP_SENDER_MAIN, 2);
  33. pPlayer->ADD_GOSSIP_ITEM(4, " Change My Name", GOSSIP_SENDER_MAIN, 3);
  34. pPlayer->PlayerTalkClass->SendGossipMenu(9425, pCreature->GetGUID());
  35. return true;
  36. }
  37.  
  38. bool OnGossipSelect(Player * Player, Creature * Creature, uint32 /*uiSender*/, uint32 uiAction)
  39. {
  40. if(!Player)
  41. return true;
  42.  
  43. switch(uiAction)
  44. {
  45. case 0:
  46. if(Player->HasItemCount(race_token, 1))
  47. {
  48. Player->DestroyItemCount(race_token, 1, true, false);
  49. Player->SetAtLoginFlag(AT_LOGIN_CHANGE_RACE);
  50. Player->GetSession()->SendNotification("You need to relog, to change your race!");
  51. Player->PlayerTalkClass->SendCloseGossip();
  52. }
  53. else
  54. {
  55. Player->GetSession()->SendNotification("You need atleast one race change token!");
  56. Player->PlayerTalkClass->SendCloseGossip();
  57. }
  58. break;
  59. case 1:
  60. if(Player->HasItemCount(faction_token, 1))
  61. {
  62. Player->DestroyItemCount(faction_token, 1, true, false);
  63. Player->SetAtLoginFlag(AT_LOGIN_CHANGE_FACTION);
  64. Player->GetSession()->SendNotification("You need to relog, to change your faction!");
  65. Player->PlayerTalkClass->SendCloseGossip();
  66. }
  67. else
  68. {
  69. Player->GetSession()->SendNotification("You need atleast one faction change token!");
  70. Player->PlayerTalkClass->SendCloseGossip();
  71. }
  72. break;
  73. case 2:
  74. if(Player->HasItemCount(customize_token, 1))
  75. {
  76. Player->DestroyItemCount(customize_token, 1, true, false);
  77. Player->SetAtLoginFlag(AT_LOGIN_CUSTOMIZE);
  78. Player->GetSession()->SendNotification("you need to relog, to change your customize!");
  79. Player->PlayerTalkClass->SendCloseGossip();
  80.  
  81. }
  82.  
  83. else
  84. {
  85. Player->GetSession()->SendNotification("you need atleast 1 customize change token!");
  86. Player->PlayerTalkClass->SendCloseGossip();
  87. }
  88. break;
  89. case 3:
  90. if(Player->HasItemCount(rename_token, 1))
  91. {
  92. Player->DestroyItemCount(rename_token, 1, true, false);
  93. Player->SetAtLoginFlag(AT_LOGIN_RENAME);
  94. Player->GetSession()->SendNotification("you need to relog, to change your name!");
  95. Player->PlayerTalkClass->SendCloseGossip();
  96.  
  97. }
  98.  
  99. else
  100. {
  101. Player->GetSession()->SendNotification("you need atleast 1 name change token!");
  102. Player->PlayerTalkClass->SendCloseGossip();
  103. }
  104. break;
  105. }
  106. return true;
  107. }
  108.  
  109. };
  110.  
  111. void AddSC_npc_changer()
  112. {
  113. new npc_changer();
  114. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement