Advertisement
Guest User

Untitled

a guest
Oct 30th, 2017
453
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "ScriptMgr.h"
  2. #include "Chat.h"
  3. #include "AccountMgr.h"
  4. #include "ObjectMgr.h"
  5. #include "PlayerDump.h"
  6. #include "ScriptedGossip.h"
  7.  
  8. class npc_pvp_titles : CreatureScript
  9. {
  10. public:
  11. npc_pvp_titles() : CreatureScript("npc_pvp_titles") {}
  12.  
  13. char* fixText(const char* Text, ...)
  14. {
  15. va_list ap;
  16. char szStr[1024];
  17. szStr[0] = '\0';
  18.  
  19. va_start(ap, Text);
  20. vsnprintf(szStr, 1024, Text, ap);
  21. va_end(ap);
  22.  
  23. uint32 length = strlen(szStr) + 1;
  24. return szStr;
  25. }
  26.  
  27. bool OnGossipHello(Player* player, Creature* creature)
  28. {
  29. player->PlayerTalkClass->ClearMenus();
  30.  
  31. uint32 count = 0;
  32. for (uint32 i = 0; i < sCharTitlesStore.GetNumRows(); ++i)
  33. {
  34. CharTitlesEntry const* entry = sCharTitlesStore.LookupEntry(i);
  35. if (entry)
  36. {
  37. count++;
  38. std::string findS = std::string(entry->name);
  39. if(findS.find("%s") != std::string::npos)
  40. {
  41. char* text = fixText(entry->name, player->GetName());
  42. player->ADD_GOSSIP_ITEM(0, text, 0, entry->ID);
  43. }
  44. else
  45. {
  46. player->ADD_GOSSIP_ITEM(0, entry->name, 0, entry->ID);
  47. }
  48. if (count >= 15)
  49. {
  50. player->ADD_GOSSIP_ITEM(0, "--------->", 0, 200015);
  51. break;
  52. }
  53.  
  54. }
  55. }
  56. player->PlayerTalkClass->SendGossipMenu(1, creature->GetGUID());
  57. return true;
  58. }
  59.  
  60. void showMore(Player* player, Creature* creature, uint32 action)
  61. {
  62. if (action >= 200000)//lol
  63. {
  64. uint32 count = 0;
  65. for (uint32 i = (action - 200000); i < sCharTitlesStore.GetNumRows(); ++i)
  66. {
  67. CharTitlesEntry const* entry = sCharTitlesStore.LookupEntry(i);
  68. if (entry)
  69. {
  70. count++;
  71. char* text = fixText(entry->name, player->GetName());
  72. player->ADD_GOSSIP_ITEM(0, text, 0, entry->ID);
  73. if (count >= 15)
  74. {
  75. player->ADD_GOSSIP_ITEM(0, "--------->", 0, action + 15);
  76. break;
  77. }
  78. }
  79. }
  80. if (action >= 200015)
  81. player->ADD_GOSSIP_ITEM(0, "<---------", 0, action - 15);
  82. }
  83. else
  84. {
  85. action = 200000 + action;
  86. uint32 count = 0;
  87. for (uint32 i = (action - 200000); i < sCharTitlesStore.GetNumRows(); ++i)
  88. {
  89. CharTitlesEntry const* entry = sCharTitlesStore.LookupEntry(i);
  90. if (entry)
  91. {
  92. count++;
  93. char* text = fixText(entry->name, player->GetName());
  94. player->ADD_GOSSIP_ITEM(0, text, 0, entry->ID);
  95. if (count >= 15)
  96. {
  97. player->ADD_GOSSIP_ITEM(0, "--------->", 0, action + 15);
  98. break;
  99. }
  100. }
  101. }
  102. if (action >= 200000+15)
  103. player->ADD_GOSSIP_ITEM(0, "<---------", 0, action - 15);
  104. }
  105. player->PlayerTalkClass->SendGossipMenu(1, creature->GetGUID());
  106. }
  107.  
  108. bool OnGossipSelect(Player* player, Creature* creature, uint32, uint32 action)
  109. {
  110. player->PlayerTalkClass->ClearMenus();
  111.  
  112. CharTitlesEntry const* entry = sCharTitlesStore.LookupEntry(action);
  113. if (entry)
  114. if (!player->HasTitle(entry))
  115. player->SetTitle(entry);
  116.  
  117.  
  118. showMore(player, creature, action);
  119.  
  120. return true;
  121. }
  122. };
  123.  
  124. void AddSC_npc_pvp_titles()
  125. {
  126. new npc_pvp_titles();
  127. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement