Advertisement
Guest User

Untitled

a guest
Apr 28th, 2015
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.60 KB | None | 0 0
  1. #include "ScriptPCH.h"
  2. using namespace std;
  3.  
  4. class npc_arena_teamTop : public CreatureScript
  5. {
  6. public:
  7.     npc_arena_teamTop() : CreatureScript("npc_arena_teamTop") { }
  8.  
  9.     bool OnGossipHello(Player * player, Creature * creature)
  10.     {
  11.         player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "View top 2v2 Arena Teams", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
  12.         player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "View top 3v3 Arena Teams", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2);
  13.         player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Nevermind", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3);
  14.         player->SEND_GOSSIP_MENU(1, creature->GetGUID());
  15.         return true;
  16.     }
  17.  
  18.     bool OnGossipSelect(Player * player, Creature * creature, uint32 sender, uint32 actions)
  19.     {
  20.         if (sender == GOSSIP_SENDER_MAIN)
  21.         {
  22.             switch (actions)
  23.             {
  24.             case GOSSIP_ACTION_INFO_DEF + 1:
  25.             {
  26.                 QueryResult result = CharacterDatabase.Query("SELECT name,rating FROM arena_team WHERE type='2' ORDER BY rating DESC LIMIT 10");
  27.                 if (!result)
  28.                     return false;
  29.  
  30.                 Field * fields = NULL;
  31.                 player->ADD_GOSSIP_MENU(GOSSIP_ICON_CHAT, "|cff4169E1Here are the top 10 2v2 arena teams:|r", GOSSIP_SENDER_MAIN, 0);
  32.                 do
  33.                 {
  34.                     fields = result->Fetch();
  35.                     string arena_name = fields[0].GetString();
  36.                     uint32 rating = fields[1].GetUInt32();
  37.                     char msg[250];
  38.                     snprintf(msg, 250, "Team Name: |cffFFFF00%s|r, Team Rating: %u \n", arena_name.c_str(), rating);
  39.                     player->ADD_GOSSIP_MENU(GOSSIP_ICON_CHAT, msg, GOSSIP_SENDER_MAIN, 0);
  40.                 } while (result->NextRow());
  41.                 player->SEND_GOSSIP_MENU(907, creature->GetGUID());
  42.             }break;
  43.  
  44.             case GOSSIP_ACTION_INFO_DEF + 2:
  45.             {
  46.                 QueryResult result = CharacterDatabase.Query("SELECT name,rating FROM arena_team WHERE type='3' ORDER BY rating DESC LIMIT 10");
  47.                 if (!result)
  48.                     return false;
  49.  
  50.                 Field * fields = NULL;
  51.                 player->ADD_GOSSIP_MENU(GOSSIP_ICON_CHAT, "|cff4169E1Here are the top 10 3v3 arena teams:|r", GOSSIP_SENDER_MAIN, 0);
  52.                 do
  53.                 {
  54.                     fields = result->Fetch();
  55.                     string arena_name = fields[0].GetString();
  56.                     uint32 rating = fields[1].GetUInt32();
  57.                     char msg[250];
  58.                     snprintf(msg, 250, "Team Name: |cffFFFF00%s|r, Team Rating: %u \n", arena_name.c_str(), rating);
  59.                     player->ADD_GOSSIP_MENU(GOSSIP_ICON_CHAT, msg, GOSSIP_SENDER_MAIN, 0);
  60.                 } while (result->NextRow());
  61.                 player->SEND_GOSSIP_MENU(907, creature->GetGUID());
  62.             }break;
  63.  
  64.             case GOSSIP_ACTION_INFO_DEF + 3:
  65.             {
  66.                 player->PlayerTalkClass->SendCloseGossip();
  67.             }break;
  68.             }
  69.         }
  70.  
  71.         return true;
  72.     }
  73. };
  74.  
  75. void AddSC_npc_arena_setup()
  76. {
  77.     new npc_arena_teamTop;
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement