1 (edited by zugurysus 2016-06-07 22:54:53)

#include "ScriptPCH.h"
#include "BattleGroundMgr.h"
#include "Chat.h"

bool GossipHello_npc_arena_spectator(Player *pPlayer, Creature *pCreature)
{
    pPlayer->ADD_GOSSIP_ITEM(0, "Показать список игр выше 1800 Рейтинга", GOSSIP_SENDER_MAIN, 1000);
    pPlayer->ADD_GOSSIP_ITEM(0, "Показать список игр ниже 1800 Рейтинга", GOSSIP_SENDER_MAIN, 2000);
    
    pPlayer->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, pCreature->GetGUID());
    return true;
}

std::string GetClassNameById(uint8 id)
{
    std::string sClass = "";
    switch (id)
    {
        case CLASS_WARRIOR:         sClass = "Воин";        break;
        case CLASS_PALADIN:         sClass = "Паладин";           break;
        case CLASS_HUNTER:          sClass = "Охотник";           break;
        case CLASS_ROGUE:           sClass = "Разбойник";          break;
        case CLASS_PRIEST:          sClass = "Жрец";         break;
        case CLASS_DEATH_KNIGHT:    sClass = "Рыцарь смерти";             break;
        case CLASS_SHAMAN:          sClass = "Шаман";          break;
        case CLASS_MAGE:            sClass = "Маг";           break;
        case CLASS_WARLOCK:         sClass = "Чернокнижник";        break;
        case CLASS_DRUID:           sClass = "Друид";          break;
    }
    return sClass;
}

std::string GetGamesStringData(BattleGround *bg, uint32 rating)
{
    std::string teamsMember[BG_TEAMS_COUNT];
    uint32 firstTeamId = 0;
    for (BattleGround::BattleGroundPlayerMap::const_iterator itr = bg->GetPlayers().begin(); itr != bg->GetPlayers().end(); ++itr)
        if (Player* player = ObjectAccessor::FindPlayer(itr->first))
            {
                uint32 team = itr->second.Team;
                if (!firstTeamId)
                    firstTeamId = team;

                teamsMember[firstTeamId == team] += GetClassNameById(player->getClass());
            }

    std::string data = teamsMember[0] + " - ";
    std::stringstream ss;
    ss << rating;
    data += ss.str();
    data += " - " + teamsMember[1];
    return data;
}

uint64 GetFirstPlayerGuid(BattleGround *bg)
{
    for (BattleGround::BattleGroundPlayerMap::const_iterator itr = bg->GetPlayers().begin(); itr != bg->GetPlayers().end(); ++itr)
    {
        if (Player* pPlayer = ObjectAccessor::FindPlayer(itr->first))
            return pPlayer->GetGUID();
        else
            return 0;
    }
    return 0;
}

void ShowPage (Player *pPlayer, Creature* pCreature, uint32 pages, bool isTop)
{
    uint32 highGames = 0;
    uint32 lowGames = 0;
    uint32 gamesOnPage = 20;
    bool nextPage = false;
    for (BattleGroundSet::iterator itr = sBattleGroundMgr.m_BattleGrounds.begin(); itr != sBattleGroundMgr.m_BattleGrounds.end(); ++itr)
    {
        BattleGround * bg = itr->second;
        if (bg->isArena() && bg->isRated())
        {
            if (Player * aPlayer = ObjectAccessor::FindPlayer(GetFirstPlayerGuid(bg)))
            {
                uint32 rating = aPlayer->GetMaxPersonalArenaRatingRequirement();
                if (isTop && rating >= 1800)
                {
                    ++highGames;
                    if (highGames > (pages + 1) * gamesOnPage)
                        nextPage = true;
                    if (highGames >= pages * gamesOnPage)
                        pPlayer->ADD_GOSSIP_ITEM(0, GetGamesStringData(bg, rating), GOSSIP_SENDER_MAIN, (3000 + GetFirstPlayerGuid(bg)));
                }
                else if (!isTop && rating >= 1000)
                {
                    ++lowGames;
                    if (lowGames > (pages + 1) * gamesOnPage)
                        nextPage = true;
                    if (lowGames >= pages * gamesOnPage)
                        pPlayer->ADD_GOSSIP_ITEM(0, GetGamesStringData(bg, rating), GOSSIP_SENDER_MAIN, (3000 + GetFirstPlayerGuid(bg)));
                }
            }
            /*else
            {
                pPlayer->ADD_GOSSIP_ITEM(0, "No Rated Arena Games Now!!!", GOSSIP_SENDER_MAIN, (3000 + GetFirstPlayerGuid(bg)));
            }*/
        }
    }
    if (pages > 0)
        pPlayer->ADD_GOSSIP_ITEM(0, "Предыдущая страница...", GOSSIP_SENDER_MAIN, 1000 + pages - 1);
    if (nextPage)
        pPlayer->ADD_GOSSIP_ITEM(0, "Следующая страница...", GOSSIP_SENDER_MAIN, 1000 + pages + 1);
}

bool GossipSelect_npc_arena_spectator(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
{
    pPlayer->PlayerTalkClass->ClearMenus();
    if (uiAction >= 1000 && uiAction < 2000)
    {
        ShowPage(pPlayer, pCreature, uiAction - 1000, true);
        pPlayer->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, pCreature->GetGUID());
    }
    else if (uiAction >= 2000 && uiAction < 3000)
    {
        ShowPage(pPlayer, pCreature, uiAction - 2000, false);
        pPlayer->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, pCreature->GetGUID());
    }
    else
    {
        pPlayer->CLOSE_GOSSIP_MENU();

        // Взять игрока для просмотра
        uint64 guid = (uiAction - 3000);
        if (Player *pTarget = ObjectAccessor::FindPlayer(guid))
            {
            if (pTarget->GetMap()->IsBattleGroundOrArena())
            {
                // Невозможно просматривать арену в которой являешься участником.
                uint32 bgInstId = pTarget->GetBattleGround()->GetInstanceID();
                if (pPlayer->IsInvitedForBattleGroundInstance(bgInstId))
                {
                    pPlayer->CLOSE_GOSSIP_MENU();
                    pCreature->MonsterWhisper("Вы приглашены на эту арену! Не можете наблюдать за собой.", pPlayer->GetGUID());
                    return true;
                }

                pPlayer->SetBattleGroundId(pTarget->GetBattleGroundId());
                // remember current position as entry point for return at bg end teleportation
                if (!pPlayer->GetMap()->IsBattleGroundOrArena())
                    pPlayer->SetBattleGroundEntryPoint();

                // stop flight if need
                if (pPlayer->isInFlight())
                {
                    pPlayer->GetMotionMaster()->MovementExpired();
                    pPlayer->CleanupAfterTaxiFlight();
                }
                // save only in non-flight case
                else
                    pPlayer->SaveRecallPosition();

                // to point to see at pTarget with same orientation
                float x,y,z;
                pTarget->GetContactPoint(pPlayer,x,y,z);

                if (pPlayer->GetPet())
                {
                    if (pPlayer->GetPet()->getPetType() == SUMMON_PET || pPlayer->GetPet()->getPetType() == HUNTER_PET)
                    {
                        pPlayer->SetTemporaryUnsummonedPetNumber(pPlayer->GetPet()->GetCharmInfo()->GetPetNumber());
                        pPlayer->SetOldPetSpell(pPlayer->GetPet()->GetUInt32Value(UNIT_CREATED_BY_SPELL));
                    }
                    pPlayer->RemovePet(NULL,PET_SAVE_NOT_IN_SLOT);
                }
                else
                    pPlayer->SetTemporaryUnsummonedPetNumber(0);

                pPlayer->TeleportTo(pTarget->GetMapId(), x, y, z, pPlayer->GetAngle(pTarget), TELE_TO_GM_MODE);

                pPlayer->SetSpectator(true);

                pCreature->MonsterWhisper("Вы можете отменить слежение за игроками! Используйте команду .spstop", pPlayer->GetGUID());
                return true;
            }
            else
            {
                pPlayer->CLOSE_GOSSIP_MENU();
                pCreature->MonsterWhisper("Игроки не на арене!!!", pPlayer->GetGUID());
                return true;
            }
        }
        else
        {
            pPlayer->CLOSE_GOSSIP_MENU();
            pCreature->MonsterWhisper("Не удается найти выбранных игроков!!!", pPlayer->GetGUID());
            return true;
        }
    }
    return true;
}

void AddSC_npc_arena_spectator() // Регистрация скрипта
{
    Script *newscript;
    newscript = new Script;
    newscript->Name = "npc_arena_spectator";
    newscript->pGossipHello = &GossipHello_npc_arena_spectator;
    newscript->pGossipSelect = &GossipSelect_npc_arena_spectator;
    newscript->RegisterSelf();
}

one drawback - after watching the fight - when you register for the fight itself ,
the effect of the viewer does not disappear, you can not use spells and you invulnerable

THX! where u find Evrial's pathes? may be u have patch for PVP rank???))

/* ScriptData
+SDName: Titles Giver NPC
+SD%Complete: 100
+SDComment: By Evrial
+SDCategory: NPC
+EndScriptData */

#include "ScriptPCH.h"
#include <cstring>
#include "World.h"

bool GossipHello_npc_titles(Player* pPlayer, Creature* pCreature)
{
    pPlayer->ADD_GOSSIP_ITEM( 0, "Gladiator's Title", GOSSIP_SENDER_MAIN, 1000);
    pPlayer->ADD_GOSSIP_ITEM( 0, "Merciless Gladiator's Title", GOSSIP_SENDER_MAIN, 2000);
    pPlayer->ADD_GOSSIP_ITEM( 0, "Vengeful Gladiator's Title", GOSSIP_SENDER_MAIN, 3000);

    pPlayer->SEND_GOSSIP_MENU(pPlayer->GetGossipTextId(pCreature), pCreature->GetGUID());
    return true;
}

void SendDefaultMenu_npc_titles(Player* pPlayer, Creature* pCreature, uint32 uiAction)
{
    // Not allowed if in combat.
    if (pPlayer->isInCombat())
    {
      pPlayer->CLOSE_GOSSIP_MENU();
      pCreature->MonsterSay("You are in combat!", LANG_UNIVERSAL, NULL);
      return;
    }

    // Process menu selection
    switch(uiAction)
    { 
        case 1000:
            // Gladiator's Title
            if(pPlayer->GetMoney() >= (sWorld.getConfig(CONFIG_TITLER_G_GOLD) * 10000) && (pPlayer->GetMaxPersonalArenaRatingRequirement() >= sWorld.getConfig(CONFIG_TITLER_G_RATING) 
                && pPlayer->HasItemCount(sWorld.getConfig(CONFIG_TITLER_G_ITEMID), sWorld.getConfig(CONFIG_TITLER_G_ITEMCOUNT), true) 
                && pPlayer->GetHonorPoints() >= sWorld.getConfig(CONFIG_TITLER_G_HONOR) 
                && pPlayer->GetArenaPoints() >= sWorld.getConfig(CONFIG_TITLER_G_AP)))
            {
                uint32 idg;
                idg = 42;
                CharTitlesEntry const* title = sCharTitlesStore.LookupEntry(idg);
                pPlayer->CLOSE_GOSSIP_MENU();
                pPlayer->ModifyMoney((-1)*sWorld.getConfig(CONFIG_TITLER_G_GOLD) * 10000);
                pPlayer->DestroyItemCount(sWorld.getConfig(CONFIG_TITLER_G_ITEMID),sWorld.getConfig(CONFIG_TITLER_G_ITEMCOUNT), true);
                pPlayer->ModifyHonorPoints((-1)*sWorld.getConfig(CONFIG_TITLER_G_HONOR));
                pPlayer->ModifyArenaPoints((-1)*sWorld.getConfig(CONFIG_TITLER_G_AP));
                pPlayer->SetTitle(title);
                pCreature->MonsterWhisper("Here are your Gladuator's Title. Relogin please.", pPlayer->GetGUID());
            }
            else
            {
                pPlayer->CLOSE_GOSSIP_MENU();
                pCreature->MonsterWhisper("You can not do it!", pPlayer->GetGUID());
            }
            break;
        case 2000:
            // Merciless Gladiator's Title
            if(pPlayer->GetMoney() >= (sWorld.getConfig(CONFIG_TITLER_MG_GOLD) * 10000) && (pPlayer->GetMaxPersonalArenaRatingRequirement() >= sWorld.getConfig(CONFIG_TITLER_MG_RATING) 
                && pPlayer->GetItemCount(sWorld.getConfig(CONFIG_TITLER_MG_ITEMID)) >= sWorld.getConfig(CONFIG_TITLER_MG_ITEMCOUNT) 
                && pPlayer->GetHonorPoints() >= sWorld.getConfig(CONFIG_TITLER_MG_HONOR) 
                && pPlayer->GetArenaPoints() >= sWorld.getConfig(CONFIG_TITLER_MG_AP)))
            {
                uint32 idmg;
                idmg = 62;
                CharTitlesEntry const* title = sCharTitlesStore.LookupEntry(idmg);
                pPlayer->CLOSE_GOSSIP_MENU();
                pPlayer->ModifyMoney((-1)*sWorld.getConfig(CONFIG_TITLER_MG_GOLD) * 10000);
                pPlayer->DestroyItemCount(sWorld.getConfig(CONFIG_TITLER_MG_ITEMID),sWorld.getConfig(CONFIG_TITLER_G_ITEMCOUNT), true);
                pPlayer->ModifyHonorPoints((-1)*sWorld.getConfig(CONFIG_TITLER_MG_HONOR));
                pPlayer->ModifyArenaPoints((-1)*sWorld.getConfig(CONFIG_TITLER_MG_AP));
                pPlayer->SetTitle(title);
                pCreature->MonsterWhisper("Here are your Merciless Gladuator's Title. Relogin please.", pPlayer->GetGUID());
            }
            else
            {
                pPlayer->CLOSE_GOSSIP_MENU();
                pCreature->MonsterWhisper("You can not do it!", pPlayer->GetGUID());
            }
            break;
        case 3000:
            // Vengeful Gladiator's Title
            if(pPlayer->GetMoney() >= (sWorld.getConfig(CONFIG_TITLER_VG_GOLD) * 10000) && (pPlayer->GetMaxPersonalArenaRatingRequirement() >= sWorld.getConfig(CONFIG_TITLER_VG_RATING) 
                && pPlayer->GetItemCount(sWorld.getConfig(CONFIG_TITLER_VG_ITEMID)) >= sWorld.getConfig(CONFIG_TITLER_VG_ITEMCOUNT) 
                && pPlayer->GetHonorPoints() >= sWorld.getConfig(CONFIG_TITLER_VG_HONOR) 
                && pPlayer->GetArenaPoints() >= sWorld.getConfig(CONFIG_TITLER_VG_AP)))
            {
                uint32 idvg;
                idvg = 71;
                CharTitlesEntry const* title = sCharTitlesStore.LookupEntry(idvg);
                pPlayer->CLOSE_GOSSIP_MENU();
                pPlayer->ModifyMoney((-1)*sWorld.getConfig(CONFIG_TITLER_VG_GOLD) * 10000);
                pPlayer->DestroyItemCount(sWorld.getConfig(CONFIG_TITLER_VG_ITEMID),sWorld.getConfig(CONFIG_TITLER_G_ITEMCOUNT), true);
                pPlayer->ModifyHonorPoints((-1)*sWorld.getConfig(CONFIG_TITLER_VG_HONOR));
                pPlayer->ModifyArenaPoints((-1)*sWorld.getConfig(CONFIG_TITLER_VG_AP));
                pPlayer->SetTitle(title);
                pCreature->MonsterWhisper("Here are your Vengeful Gladuator's Title. Relogin please.", pPlayer->GetGUID());
            }
            else
            {
                pPlayer->CLOSE_GOSSIP_MENU();
                pCreature->MonsterWhisper("You can not do it!", pPlayer->GetGUID());
            }
            break;
    }
}

bool GossipSelect_npc_titles(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
{
    // Show menu
    if (uiSender == GOSSIP_SENDER_MAIN)
        SendDefaultMenu_npc_titles(pPlayer, pCreature, uiAction);
    return true;
}

void AddSC_npc_titles()
{
    Script *newscript;
    newscript = new Script;
    newscript->Name = "npc_titles";
    newscript->pGossipHello = &GossipHello_npc_titles;
    newscript->pGossipSelect = &GossipSelect_npc_titles;
    newscript->RegisterSelf();
}

smile ) Friend , hold ))

zugurysus wrote:
/* ScriptData
+SDName: Titles Giver NPC
+SD%Complete: 100
+SDComment: By Evrial
+SDCategory: NPC
+EndScriptData */

#include "ScriptPCH.h"
#include <cstring>
#include "World.h"

bool GossipHello_npc_titles(Player* pPlayer, Creature* pCreature)
{
    pPlayer->ADD_GOSSIP_ITEM( 0, "Gladiator's Title", GOSSIP_SENDER_MAIN, 1000);
    pPlayer->ADD_GOSSIP_ITEM( 0, "Merciless Gladiator's Title", GOSSIP_SENDER_MAIN, 2000);
    pPlayer->ADD_GOSSIP_ITEM( 0, "Vengeful Gladiator's Title", GOSSIP_SENDER_MAIN, 3000);

    pPlayer->SEND_GOSSIP_MENU(pPlayer->GetGossipTextId(pCreature), pCreature->GetGUID());
    return true;
}

void SendDefaultMenu_npc_titles(Player* pPlayer, Creature* pCreature, uint32 uiAction)
{
    // Not allowed if in combat.
    if (pPlayer->isInCombat())
    {
      pPlayer->CLOSE_GOSSIP_MENU();
      pCreature->MonsterSay("You are in combat!", LANG_UNIVERSAL, NULL);
      return;
    }

    // Process menu selection
    switch(uiAction)
    { 
        case 1000:
            // Gladiator's Title
            if(pPlayer->GetMoney() >= (sWorld.getConfig(CONFIG_TITLER_G_GOLD) * 10000) && (pPlayer->GetMaxPersonalArenaRatingRequirement() >= sWorld.getConfig(CONFIG_TITLER_G_RATING) 
                && pPlayer->HasItemCount(sWorld.getConfig(CONFIG_TITLER_G_ITEMID), sWorld.getConfig(CONFIG_TITLER_G_ITEMCOUNT), true) 
                && pPlayer->GetHonorPoints() >= sWorld.getConfig(CONFIG_TITLER_G_HONOR) 
                && pPlayer->GetArenaPoints() >= sWorld.getConfig(CONFIG_TITLER_G_AP)))
            {
                uint32 idg;
                idg = 42;
                CharTitlesEntry const* title = sCharTitlesStore.LookupEntry(idg);
                pPlayer->CLOSE_GOSSIP_MENU();
                pPlayer->ModifyMoney((-1)*sWorld.getConfig(CONFIG_TITLER_G_GOLD) * 10000);
                pPlayer->DestroyItemCount(sWorld.getConfig(CONFIG_TITLER_G_ITEMID),sWorld.getConfig(CONFIG_TITLER_G_ITEMCOUNT), true);
                pPlayer->ModifyHonorPoints((-1)*sWorld.getConfig(CONFIG_TITLER_G_HONOR));
                pPlayer->ModifyArenaPoints((-1)*sWorld.getConfig(CONFIG_TITLER_G_AP));
                pPlayer->SetTitle(title);
                pCreature->MonsterWhisper("Here are your Gladuator's Title. Relogin please.", pPlayer->GetGUID());
            }
            else
            {
                pPlayer->CLOSE_GOSSIP_MENU();
                pCreature->MonsterWhisper("You can not do it!", pPlayer->GetGUID());
            }
            break;
        case 2000:
            // Merciless Gladiator's Title
            if(pPlayer->GetMoney() >= (sWorld.getConfig(CONFIG_TITLER_MG_GOLD) * 10000) && (pPlayer->GetMaxPersonalArenaRatingRequirement() >= sWorld.getConfig(CONFIG_TITLER_MG_RATING) 
                && pPlayer->GetItemCount(sWorld.getConfig(CONFIG_TITLER_MG_ITEMID)) >= sWorld.getConfig(CONFIG_TITLER_MG_ITEMCOUNT) 
                && pPlayer->GetHonorPoints() >= sWorld.getConfig(CONFIG_TITLER_MG_HONOR) 
                && pPlayer->GetArenaPoints() >= sWorld.getConfig(CONFIG_TITLER_MG_AP)))
            {
                uint32 idmg;
                idmg = 62;
                CharTitlesEntry const* title = sCharTitlesStore.LookupEntry(idmg);
                pPlayer->CLOSE_GOSSIP_MENU();
                pPlayer->ModifyMoney((-1)*sWorld.getConfig(CONFIG_TITLER_MG_GOLD) * 10000);
                pPlayer->DestroyItemCount(sWorld.getConfig(CONFIG_TITLER_MG_ITEMID),sWorld.getConfig(CONFIG_TITLER_G_ITEMCOUNT), true);
                pPlayer->ModifyHonorPoints((-1)*sWorld.getConfig(CONFIG_TITLER_MG_HONOR));
                pPlayer->ModifyArenaPoints((-1)*sWorld.getConfig(CONFIG_TITLER_MG_AP));
                pPlayer->SetTitle(title);
                pCreature->MonsterWhisper("Here are your Merciless Gladuator's Title. Relogin please.", pPlayer->GetGUID());
            }
            else
            {
                pPlayer->CLOSE_GOSSIP_MENU();
                pCreature->MonsterWhisper("You can not do it!", pPlayer->GetGUID());
            }
            break;
        case 3000:
            // Vengeful Gladiator's Title
            if(pPlayer->GetMoney() >= (sWorld.getConfig(CONFIG_TITLER_VG_GOLD) * 10000) && (pPlayer->GetMaxPersonalArenaRatingRequirement() >= sWorld.getConfig(CONFIG_TITLER_VG_RATING) 
                && pPlayer->GetItemCount(sWorld.getConfig(CONFIG_TITLER_VG_ITEMID)) >= sWorld.getConfig(CONFIG_TITLER_VG_ITEMCOUNT) 
                && pPlayer->GetHonorPoints() >= sWorld.getConfig(CONFIG_TITLER_VG_HONOR) 
                && pPlayer->GetArenaPoints() >= sWorld.getConfig(CONFIG_TITLER_VG_AP)))
            {
                uint32 idvg;
                idvg = 71;
                CharTitlesEntry const* title = sCharTitlesStore.LookupEntry(idvg);
                pPlayer->CLOSE_GOSSIP_MENU();
                pPlayer->ModifyMoney((-1)*sWorld.getConfig(CONFIG_TITLER_VG_GOLD) * 10000);
                pPlayer->DestroyItemCount(sWorld.getConfig(CONFIG_TITLER_VG_ITEMID),sWorld.getConfig(CONFIG_TITLER_G_ITEMCOUNT), true);
                pPlayer->ModifyHonorPoints((-1)*sWorld.getConfig(CONFIG_TITLER_VG_HONOR));
                pPlayer->ModifyArenaPoints((-1)*sWorld.getConfig(CONFIG_TITLER_VG_AP));
                pPlayer->SetTitle(title);
                pCreature->MonsterWhisper("Here are your Vengeful Gladuator's Title. Relogin please.", pPlayer->GetGUID());
            }
            else
            {
                pPlayer->CLOSE_GOSSIP_MENU();
                pCreature->MonsterWhisper("You can not do it!", pPlayer->GetGUID());
            }
            break;
    }
}

bool GossipSelect_npc_titles(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
{
    // Show menu
    if (uiSender == GOSSIP_SENDER_MAIN)
        SendDefaultMenu_npc_titles(pPlayer, pCreature, uiAction);
    return true;
}

void AddSC_npc_titles()
{
    Script *newscript;
    newscript = new Script;
    newscript->Name = "npc_titles";
    newscript->pGossipHello = &GossipHello_npc_titles;
    newscript->pGossipSelect = &GossipSelect_npc_titles;
    newscript->RegisterSelf();
}

smile ) Friend , hold ))

Thank U! I test it!

zugurysus wrote:

Rewrote the code Evrial

#include "ScriptPCH.h"
#include "BattleGroundMgr.h"
#include "Chat.h"

bool GossipHello_npc_arena_spectator(Player *pPlayer, Creature *pCreature)
{
    pPlayer->ADD_GOSSIP_ITEM(0, "Показать список игр выше 1800 Рейтинга", GOSSIP_SENDER_MAIN, 1000);
    pPlayer->ADD_GOSSIP_ITEM(0, "Показать список игр ниже 1800 Рейтинга", GOSSIP_SENDER_MAIN, 2000);
    
    pPlayer->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, pCreature->GetGUID());
    return true;
}

std::string GetClassNameById(uint8 id)
{
    std::string sClass = "";
    switch (id)
    {
        case CLASS_WARRIOR:         sClass = "Воин";        break;
        case CLASS_PALADIN:         sClass = "Паладин";           break;
        case CLASS_HUNTER:          sClass = "Охотник";           break;
        case CLASS_ROGUE:           sClass = "Разбойник";          break;
        case CLASS_PRIEST:          sClass = "Жрец";         break;
        case CLASS_DEATH_KNIGHT:    sClass = "Рыцарь смерти";             break;
        case CLASS_SHAMAN:          sClass = "Шаман";          break;
        case CLASS_MAGE:            sClass = "Маг";           break;
        case CLASS_WARLOCK:         sClass = "Чернокнижник";        break;
        case CLASS_DRUID:           sClass = "Друид";          break;
    }
    return sClass;
}

std::string GetGamesStringData(BattleGround *bg, uint32 rating)
{
    std::string teamsMember[BG_TEAMS_COUNT];
    uint32 firstTeamId = 0;
    for (BattleGround::BattleGroundPlayerMap::const_iterator itr = bg->GetPlayers().begin(); itr != bg->GetPlayers().end(); ++itr)
        if (Player* player = ObjectAccessor::FindPlayer(itr->first))
            {
                uint32 team = itr->second.Team;
                if (!firstTeamId)
                    firstTeamId = team;

                teamsMember[firstTeamId == team] += GetClassNameById(player->getClass());
            }

    std::string data = teamsMember[0] + " - ";
    std::stringstream ss;
    ss << rating;
    data += ss.str();
    data += " - " + teamsMember[1];
    return data;
}

uint64 GetFirstPlayerGuid(BattleGround *bg)
{
    for (BattleGround::BattleGroundPlayerMap::const_iterator itr = bg->GetPlayers().begin(); itr != bg->GetPlayers().end(); ++itr)
    {
        if (Player* pPlayer = ObjectAccessor::FindPlayer(itr->first))
            return pPlayer->GetGUID();
        else
            return 0;
    }
    return 0;
}

void ShowPage (Player *pPlayer, Creature* pCreature, uint32 pages, bool isTop)
{
    uint32 highGames = 0;
    uint32 lowGames = 0;
    uint32 gamesOnPage = 20;
    bool nextPage = false;
    for (BattleGroundSet::iterator itr = sBattleGroundMgr.m_BattleGrounds.begin(); itr != sBattleGroundMgr.m_BattleGrounds.end(); ++itr)
    {
        BattleGround * bg = itr->second;
        if (bg->isArena() && bg->isRated())
        {
            if (Player * aPlayer = ObjectAccessor::FindPlayer(GetFirstPlayerGuid(bg)))
            {
                uint32 rating = aPlayer->GetMaxPersonalArenaRatingRequirement();
                if (isTop && rating >= 1800)
                {
                    ++highGames;
                    if (highGames > (pages + 1) * gamesOnPage)
                        nextPage = true;
                    if (highGames >= pages * gamesOnPage)
                        pPlayer->ADD_GOSSIP_ITEM(0, GetGamesStringData(bg, rating), GOSSIP_SENDER_MAIN, (3000 + GetFirstPlayerGuid(bg)));
                }
                else if (!isTop && rating >= 1000)
                {
                    ++lowGames;
                    if (lowGames > (pages + 1) * gamesOnPage)
                        nextPage = true;
                    if (lowGames >= pages * gamesOnPage)
                        pPlayer->ADD_GOSSIP_ITEM(0, GetGamesStringData(bg, rating), GOSSIP_SENDER_MAIN, (3000 + GetFirstPlayerGuid(bg)));
                }
            }
            /*else
            {
                pPlayer->ADD_GOSSIP_ITEM(0, "No Rated Arena Games Now!!!", GOSSIP_SENDER_MAIN, (3000 + GetFirstPlayerGuid(bg)));
            }*/
        }
    }
    if (pages > 0)
        pPlayer->ADD_GOSSIP_ITEM(0, "Предыдущая страница...", GOSSIP_SENDER_MAIN, 1000 + pages - 1);
    if (nextPage)
        pPlayer->ADD_GOSSIP_ITEM(0, "Следующая страница...", GOSSIP_SENDER_MAIN, 1000 + pages + 1);
}

bool GossipSelect_npc_arena_spectator(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
{
    pPlayer->PlayerTalkClass->ClearMenus();
    if (uiAction >= 1000 && uiAction < 2000)
    {
        ShowPage(pPlayer, pCreature, uiAction - 1000, true);
        pPlayer->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, pCreature->GetGUID());
    }
    else if (uiAction >= 2000 && uiAction < 3000)
    {
        ShowPage(pPlayer, pCreature, uiAction - 2000, false);
        pPlayer->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, pCreature->GetGUID());
    }
    else
    {
        pPlayer->CLOSE_GOSSIP_MENU();

        // Взять игрока для просмотра
        uint64 guid = (uiAction - 3000);
        if (Player *pTarget = ObjectAccessor::FindPlayer(guid))
            {
            if (pTarget->GetMap()->IsBattleGroundOrArena())
            {
                // Невозможно просматривать арену в которой являешься участником.
                uint32 bgInstId = pTarget->GetBattleGround()->GetInstanceID();
                if (pPlayer->IsInvitedForBattleGroundInstance(bgInstId))
                {
                    pPlayer->CLOSE_GOSSIP_MENU();
                    pCreature->MonsterWhisper("Вы приглашены на эту арену! Не можете наблюдать за собой.", pPlayer->GetGUID());
                    return true;
                }

                pPlayer->SetBattleGroundId(pTarget->GetBattleGroundId());
                // remember current position as entry point for return at bg end teleportation
                if (!pPlayer->GetMap()->IsBattleGroundOrArena())
                    pPlayer->SetBattleGroundEntryPoint();

                // stop flight if need
                if (pPlayer->isInFlight())
                {
                    pPlayer->GetMotionMaster()->MovementExpired();
                    pPlayer->CleanupAfterTaxiFlight();
                }
                // save only in non-flight case
                else
                    pPlayer->SaveRecallPosition();

                // to point to see at pTarget with same orientation
                float x,y,z;
                pTarget->GetContactPoint(pPlayer,x,y,z);

                if (pPlayer->GetPet())
                {
                    if (pPlayer->GetPet()->getPetType() == SUMMON_PET || pPlayer->GetPet()->getPetType() == HUNTER_PET)
                    {
                        pPlayer->SetTemporaryUnsummonedPetNumber(pPlayer->GetPet()->GetCharmInfo()->GetPetNumber());
                        pPlayer->SetOldPetSpell(pPlayer->GetPet()->GetUInt32Value(UNIT_CREATED_BY_SPELL));
                    }
                    pPlayer->RemovePet(NULL,PET_SAVE_NOT_IN_SLOT);
                }
                else
                    pPlayer->SetTemporaryUnsummonedPetNumber(0);

                pPlayer->TeleportTo(pTarget->GetMapId(), x, y, z, pPlayer->GetAngle(pTarget), TELE_TO_GM_MODE);

                pPlayer->SetSpectator(true);

                pCreature->MonsterWhisper("Вы можете отменить слежение за игроками! Используйте команду .spstop", pPlayer->GetGUID());
                return true;
            }
            else
            {
                pPlayer->CLOSE_GOSSIP_MENU();
                pCreature->MonsterWhisper("Игроки не на арене!!!", pPlayer->GetGUID());
                return true;
            }
        }
        else
        {
            pPlayer->CLOSE_GOSSIP_MENU();
            pCreature->MonsterWhisper("Не удается найти выбранных игроков!!!", pPlayer->GetGUID());
            return true;
        }
    }
    return true;
}

void AddSC_npc_arena_spectator() // Регистрация скрипта
{
    Script *newscript;
    newscript = new Script;
    newscript->Name = "npc_arena_spectator";
    newscript->pGossipHello = &GossipHello_npc_arena_spectator;
    newscript->pGossipSelect = &GossipSelect_npc_arena_spectator;
    newscript->RegisterSelf();
}

one drawback - after watching the fight - when you register for the fight itself ,
the effect of the viewer does not disappear, you can not use spells and you invulnerable

please english language? smile

that script is incorrect and that's not complete

I have the full data scripts, the information in Skype: zugurysus@gmail.com

Hey do you still have the arena spectator c++ script ? tongue would be cool if u can share it

This script is not complete...
But there is a complete under the latest revision

And why did you actually remove the copyright? You did not write it. Not respect for the author of the patch. It is not good to do so.