Advertisement
Guest User

Untitled

a guest
Jan 21st, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.73 KB | None | 0 0
  1. #include "ScriptPCH.h"
  2.  
  3. /*Author: Mainaz*/
  4.  
  5. class Exchanger_NPC : public CreatureScript
  6. {
  7. public:
  8. Exchanger_NPC() : CreatureScript("Exchanger_NPC") { }
  9.  
  10. bool OnGossipHello(Player *player, Creature * creature)
  11. {
  12. if (player->isInCombat())
  13. {
  14. player->CLOSE_GOSSIP_MENU();
  15. creature->MonsterWhisper("You are in combat!", player->GetGUID());
  16. return true;
  17. }
  18. else
  19. {
  20. player->ADD_GOSSIP_ITEM_EXTENDED(5, "200 Conquest Points for 4000 Honor", GOSSIP_SENDER_MAIN, 1, "Are you sure you want to exchange 200 Conquest Points for 4000 Honor?", 0, false);
  21. player->ADD_GOSSIP_ITEM_EXTENDED(5, "4000 Honor for 200 Conquest Points", GOSSIP_SENDER_MAIN, 2, "Are you sure you want to exchange 4000 Honor for 200 Conquest Points?", 0, false);
  22. }
  23.  
  24. player->SEND_GOSSIP_MENU(60040, creature->GetGUID());
  25. return true;
  26. }
  27.  
  28. bool OnGossipSelect(Player * player, Creature * creature, uint32 sender, uint32 uiAction)
  29. {
  30. if (sender == GOSSIP_SENDER_MAIN)
  31. {
  32. player->PlayerTalkClass->ClearMenus();
  33. uint32 honor_points = player->GetCurrency(CURRENCY_TYPE_HONOR_POINTS, true);
  34. uint32 conquest_points = player->GetCurrency(CURRENCY_TYPE_HONOR_POINTS, true);
  35. switch (uiAction)
  36. {
  37. case 1:
  38. /*Note: Normally the value you use its value / 100 = ingame value but if we use * CURRENCY_PRECISION it will use exactly that amount*/
  39. if (conquest_points >= 200)
  40. {
  41. player->CLOSE_GOSSIP_MENU();
  42. player->ModifyCurrency(CURRENCY_TYPE_CONQUEST_POINTS, -100 * CURRENCY_PRECISION, true, true); //Conquest Points
  43. player->ModifyCurrency(CURRENCY_TYPE_HONOR_POINTS, +1000 * CURRENCY_PRECISION, true, true); //Honor Points
  44. creature->MonsterWhisper("|c00077766|r You exchanged 100 conquest points for 100 honor points successfully!", player->GetGUID(), true);
  45.  
  46. }
  47. else
  48. {
  49. player->CLOSE_GOSSIP_MENU();
  50. creature->MonsterWhisper("|c00077766|r You don't have enough Conquest Points!", player->GetGUID(), true);
  51.  
  52. return false;
  53. }
  54. break;
  55.  
  56. case 2:
  57. if (honor_points >= 4000)
  58. {
  59. player->CLOSE_GOSSIP_MENU();
  60. player->ModifyCurrency(CURRENCY_TYPE_CONQUEST_POINTS, +100 * CURRENCY_PRECISION, true, true); //Conquest Points
  61. player->ModifyCurrency(CURRENCY_TYPE_HONOR_POINTS, -100 * CURRENCY_PRECISION, true, true); //Honor Points
  62. creature->MonsterWhisper("|c00077766|r You exchanged 100 honor points for 100 conquest points successfully!", player->GetGUID(), true);
  63. }
  64. else
  65. {
  66. player->CLOSE_GOSSIP_MENU();
  67. creature->MonsterWhisper("|c00077766|r You don't have enough Honor Points!", player->GetGUID(), true);
  68. return false;
  69. }
  70. break;
  71. }
  72. }
  73. return true;
  74. }
  75. };
  76.  
  77. void AddSC_Exchanger_NPC()
  78. {
  79. new Exchanger_NPC();
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement