• This is a read only backup of the old Emudevs forum. If you want to have anything removed, please message me on Discord: KittyKaev

[SOLVED] Errors

Status
Not open for further replies.

Blazeqts

Enthusiast
I'm trying to add this Arena Spectator script. I'm getting these errors.

Code:
10>..\..\..\..\source\src\server\scripts\Custom\pvp_arena_spectator.cpp(44): error C2039: 'isInCombat' : is not a member of 'Player'
10>          C:/Users/Andreas/Desktop/Tournament Realm/source/src/server/game/Entities/Player\Player.h(1061) : see declaration of 'Player'
10>..\..\..\..\source\src\server\scripts\Custom\pvp_arena_spectator.cpp(65): error C2039: 'isSpectator' : is not a member of 'Player'
10>          C:/Users/Andreas/Desktop/Tournament Realm/source/src/server/game/Entities/Player\Player.h(1061) : see declaration of 'Player'
10>..\..\..\..\source\src\server\scripts\Custom\pvp_arena_spectator.cpp(94): error C2039: 'isSpectator' : is not a member of 'Player'
10>          C:/Users/Andreas/Desktop/Tournament Realm/source/src/server/game/Entities/Player\Player.h(1061) : see declaration of 'Player'
10>..\..\..\..\source\src\server\scripts\Custom\pvp_arena_spectator.cpp(102): error C2039: 'isInFlight' : is not a member of 'Player'
10>          C:/Users/Andreas/Desktop/Tournament Realm/source/src/server/game/Entities/Player\Player.h(1061) : see declaration of 'Player'
10>..\..\..\..\source\src\server\scripts\Custom\pvp_arena_spectator.cpp(125): error C2039: 'isSpectator' : is not a member of 'Player'
10>          C:/Users/Andreas/Desktop/Tournament Realm/source/src/server/game/Entities/Player\Player.h(1061) : see declaration of 'Player'
10>..\..\..\..\source\src\server\scripts\Custom\pvp_arena_spectator.cpp(158): error C2039: 'SetSpectate' : is not a member of 'Player'
10>          C:/Users/Andreas/Desktop/Tournament Realm/source/src/server/game/Entities/Player\Player.h(1061) : see declaration of 'Player'
10>..\..\..\..\source\src\server\scripts\Custom\pvp_arena_spectator.cpp(159): error C2039: 'AddSpectator' : is not a member of 'Battleground'
10>          c:\users\andreas\desktop\tournament realm\source\src\server\game\battlegrounds\Battleground.h(274) : see declaration of 'Battleground'
10>..\..\..\..\source\src\server\scripts\Custom\pvp_arena_spectator.cpp(168): error C2039: 'isSpectator' : is not a member of 'Player'
10>          C:/Users/Andreas/Desktop/Tournament Realm/source/src/server/game/Entities/Player\Player.h(1061) : see declaration of 'Player'
10>..\..\..\..\source\src\server\scripts\Custom\pvp_arena_spectator.cpp(175): error C2039: 'RemoveSpectator' : is not a member of 'Battleground'
10>          c:\users\andreas\desktop\tournament realm\source\src\server\game\battlegrounds\Battleground.h(274) : see declaration of 'Battleground'
10>..\..\..\..\source\src\server\scripts\Custom\pvp_arena_spectator.cpp(176): error C2039: 'CancelSpectate' : is not a member of 'Player'
10>          C:/Users/Andreas/Desktop/Tournament Realm/source/src/server/game/Entities/Player\Player.h(1061) : see declaration of 'Player'
10>..\..\..\..\source\src\server\scripts\Custom\pvp_arena_spectator.cpp(199): error C2039: 'isSpectator' : is not a member of 'Player'
10>          C:/Users/Andreas/Desktop/Tournament Realm/source/src/server/game/Entities/Player\Player.h(1061) : see declaration of 'Player'
10>..\..\..\..\source\src\server\scripts\Custom\pvp_arena_spectator.cpp(206): error C2039: 'isSpectator' : is not a member of 'Player'
10>          C:/Users/Andreas/Desktop/Tournament Realm/source/src/server/game/Entities/Player\Player.h(1061) : see declaration of 'Player'
10>..\..\..\..\source\src\server\scripts\Custom\pvp_arena_spectator.cpp(229): error C2039: 'getSpectateFrom' : is not a member of 'Player'
10>          C:/Users/Andreas/Desktop/Tournament Realm/source/src/server/game/Entities/Player\Player.h(1061) : see declaration of 'Player'
10>..\..\..\..\source\src\server\scripts\Custom\pvp_arena_spectator.cpp(229): error C2039: 'getSpectateFrom' : is not a member of 'Player'
10>          C:/Users/Andreas/Desktop/Tournament Realm/source/src/server/game/Entities/Player\Player.h(1061) : see declaration of 'Player'
10>..\..\..\..\source\src\server\scripts\Custom\pvp_arena_spectator.cpp(245): error C2039: 'isSpectator' : is not a member of 'Player'
10>          C:/Users/Andreas/Desktop/Tournament Realm/source/src/server/game/Entities/Player\Player.h(1061) : see declaration of 'Player'
10>..\..\..\..\source\src\server\scripts\Custom\pvp_arena_spectator.cpp(262): error C2039: 'isSpectator' : is not a member of 'Player'
10>          C:/Users/Andreas/Desktop/Tournament Realm/source/src/server/game/Entities/Player\Player.h(1061) : see declaration of 'Player'
10>..\..\..\..\source\src\server\scripts\Custom\pvp_arena_spectator.cpp(274): error C2065: 'SpectatorAddonMsg' : undeclared identifier
10>..\..\..\..\source\src\server\scripts\Custom\pvp_arena_spectator.cpp(274): error C2146: syntax error : missing ';' before identifier 'msg'
10>..\..\..\..\source\src\server\scripts\Custom\pvp_arena_spectator.cpp(274): error C2065: 'msg' : undeclared identifier
10>..\..\..\..\source\src\server\scripts\Custom\pvp_arena_spectator.cpp(275): error C2065: 'msg' : undeclared identifier
10>..\..\..\..\source\src\server\scripts\Custom\pvp_arena_spectator.cpp(275): error C2228: left of '.SetPlayer' must have class/struct/union
10>          type is ''unknown-type''
10>..\..\..\..\source\src\server\scripts\Custom\pvp_arena_spectator.cpp(277): error C2065: 'msg' : undeclared identifier
10>..\..\..\..\source\src\server\scripts\Custom\pvp_arena_spectator.cpp(277): error C2228: left of '.SetTarget' must have class/struct/union
10>          type is ''unknown-type''
10>..\..\..\..\source\src\server\scripts\Custom\pvp_arena_spectator.cpp(278): error C2065: 'msg' : undeclared identifier
10>..\..\..\..\source\src\server\scripts\Custom\pvp_arena_spectator.cpp(278): error C2228: left of '.SetStatus' must have class/struct/union
10>          type is ''unknown-type''
10>..\..\..\..\source\src\server\scripts\Custom\pvp_arena_spectator.cpp(278): error C2039: 'isAlive' : is not a member of 'Player'
10>          C:/Users/Andreas/Desktop/Tournament Realm/source/src/server/game/Entities/Player\Player.h(1061) : see declaration of 'Player'
10>..\..\..\..\source\src\server\scripts\Custom\pvp_arena_spectator.cpp(279): error C2065: 'msg' : undeclared identifier
10>..\..\..\..\source\src\server\scripts\Custom\pvp_arena_spectator.cpp(279): error C2228: left of '.SetClass' must have class/struct/union
10>          type is ''unknown-type''
10>..\..\..\..\source\src\server\scripts\Custom\pvp_arena_spectator.cpp(280): error C2065: 'msg' : undeclared identifier
10>..\..\..\..\source\src\server\scripts\Custom\pvp_arena_spectator.cpp(280): error C2228: left of '.SetCurrentHP' must have class/struct/union
10>          type is ''unknown-type''
10>..\..\..\..\source\src\server\scripts\Custom\pvp_arena_spectator.cpp(281): error C2065: 'msg' : undeclared identifier
10>..\..\..\..\source\src\server\scripts\Custom\pvp_arena_spectator.cpp(281): error C2228: left of '.SetMaxHP' must have class/struct/union
10>          type is ''unknown-type''
10>..\..\..\..\source\src\server\scripts\Custom\pvp_arena_spectator.cpp(283): error C2065: 'msg' : undeclared identifier
10>..\..\..\..\source\src\server\scripts\Custom\pvp_arena_spectator.cpp(283): error C2228: left of '.SetMaxPower' must have class/struct/union
10>          type is ''unknown-type''
10>..\..\..\..\source\src\server\scripts\Custom\pvp_arena_spectator.cpp(284): error C2065: 'msg' : undeclared identifier
10>..\..\..\..\source\src\server\scripts\Custom\pvp_arena_spectator.cpp(284): error C2228: left of '.SetCurrentPower' must have class/struct/union
10>          type is ''unknown-type''
10>..\..\..\..\source\src\server\scripts\Custom\pvp_arena_spectator.cpp(285): error C2065: 'msg' : undeclared identifier
10>..\..\..\..\source\src\server\scripts\Custom\pvp_arena_spectator.cpp(285): error C2228: left of '.SetPowerType' must have class/struct/union
10>          type is ''unknown-type''
10>..\..\..\..\source\src\server\scripts\Custom\pvp_arena_spectator.cpp(286): error C2065: 'msg' : undeclared identifier
10>..\..\..\..\source\src\server\scripts\Custom\pvp_arena_spectator.cpp(286): error C2228: left of '.SetTeam' must have class/struct/union
10>          type is ''unknown-type''
10>..\..\..\..\source\src\server\scripts\Custom\pvp_arena_spectator.cpp(287): error C2065: 'msg' : undeclared identifier
10>..\..\..\..\source\src\server\scripts\Custom\pvp_arena_spectator.cpp(287): error C2228: left of '.SendPacket' must have class/struct/union
10>          type is ''unknown-type''
10>..\..\..\..\source\src\server\scripts\Custom\pvp_arena_spectator.cpp(390): error C2039: 'isSpectator' : is not a member of 'Player'
10>          C:/Users/Andreas/Desktop/Tournament Realm/source/src/server/game/Entities/Player\Player.h(1061) : see declaration of 'Player'
10>..\..\..\..\source\src\server\scripts\Custom\pvp_arena_spectator.cpp(423): error C2248: 'BattlegroundMgr::IsArenaType' : cannot access private member declared in class 'BattlegroundMgr'
10>          C:/Users/Andreas/Desktop/Tournament Realm/source/src/server/game/Battlegrounds\BattlegroundMgr.h(140) : see declaration of 'BattlegroundMgr::IsArenaType'
10>          C:/Users/Andreas/Desktop/Tournament Realm/source/src/server/game/Battlegrounds\BattlegroundMgr.h(66) : see declaration of 'BattlegroundMgr'
10>..\..\..\..\source\src\server\scripts\Custom\pvp_arena_spectator.cpp(426): error C2039: 'GetBattlegroundsByType' : is not a member of 'BattlegroundMgr'
10>          C:/Users/Andreas/Desktop/Tournament Realm/source/src/server/game/Battlegrounds\BattlegroundMgr.h(66) : see declaration of 'BattlegroundMgr'

This is the script.

Code:
#include "ScriptPCH.h"
#include "Chat.h"
#include "Language.h"
#include "ArenaTeamMgr.h"
#include "BattlegroundMgr.h"

class arena_spectator_commands : public CommandScript
{
    public:
        arena_spectator_commands() : CommandScript("arena_spectator_commands") { }

        static bool HandleSpectateCommand(ChatHandler* handler, const char *args)
        {
            Player* target;
            uint64 target_guid;
            std::string target_name;
            if (!handler->extractPlayerTarget((char*)args, &target, &target_guid, &target_name))
                return false;

            Player* player = handler->GetSession()->GetPlayer();
            if (target == player || target_guid == player->GetGUID())
            {
                handler->SendSysMessage(LANG_CANT_TELEPORT_SELF);
                handler->SetSentErrorMessage(true);
                return false;
            }

            if (player->isInCombat())
            {
                handler->SendSysMessage(LANG_YOU_IN_COMBAT);
                handler->SetSentErrorMessage(true);
                return false;
            }

            if (!target)
            {
                handler->SendSysMessage(LANG_PLAYER_NOT_EXIST_OR_OFFLINE);
                handler->SetSentErrorMessage(true);
                return false;
            }

            if (player->GetPet())
            {
                handler->PSendSysMessage("You must hide your pet.");
                handler->SetSentErrorMessage(true);
                return false;
            }

            if (player->GetMap()->IsBattlegroundOrArena() && !player->isSpectator())
            {
                handler->PSendSysMessage("You are already on battleground or arena.");
                handler->SetSentErrorMessage(true);
                return false;
            }

            Map* cMap = target->GetMap();
            if (!cMap->IsBattleArena())
            {
                handler->PSendSysMessage("Player didnt found in arena.");
                handler->SetSentErrorMessage(true);
                return false;
            }

            if (player->GetMap()->IsBattleground())
            {
                handler->PSendSysMessage("Cant do that while you are on battleground.");
                handler->SetSentErrorMessage(true);
                return false;
            }

            // all's well, set bg id
            // when porting out from the bg, it will be reset to 0
            player->SetBattlegroundId(target->GetBattlegroundId(), target->GetBattlegroundTypeId());
            // remember current position as entry point for return at bg end teleportation
            if (!player->GetMap()->IsBattlegroundOrArena())
                player->SetBattlegroundEntryPoint();

            if (target->isSpectator())
            {
                handler->PSendSysMessage("Can`t do that. Your target is spectator.");
                handler->SetSentErrorMessage(true);
                return false;
            }

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

            // search for two teams
            Battleground *bGround = target->GetBattleground();
            if (bGround->isRated())
            {
                uint32 slot = bGround->GetArenaType() - 2;
                if (bGround->GetArenaType() > 3)
                    slot = 2;
                uint32 firstTeamID = target->GetArenaTeamId(slot);
                uint32 secondTeamID = 0;
                Player *firstTeamMember  = target;
                Player *secondTeamMember = NULL;
                for (Battleground::BattlegroundPlayerMap::const_iterator itr = bGround->GetPlayers().begin(); itr != bGround->GetPlayers().end(); ++itr)
                    if (Player* tmpPlayer = ObjectAccessor::FindPlayer(itr->first))
                    {
                        if (tmpPlayer->isSpectator())
                            continue;

                        uint32 tmpID = tmpPlayer->GetArenaTeamId(slot);
                        if (tmpID != firstTeamID && tmpID > 0)
                        {
                            secondTeamID = tmpID;
                            secondTeamMember = tmpPlayer;
                            break;
                        }
                    }

                if (firstTeamID > 0 && secondTeamID > 0 && secondTeamMember)
                {
                    ArenaTeam *firstTeam  = sArenaTeamMgr->GetArenaTeamById(firstTeamID);
                    ArenaTeam *secondTeam = sArenaTeamMgr->GetArenaTeamById(secondTeamID);
                    if (firstTeam && secondTeam)
                    {
                        handler->PSendSysMessage("You entered to rated arena.");
                        handler->PSendSysMessage("Teams:");
                        handler->PSendSysMessage("%s - %s", firstTeam->GetName().c_str(), secondTeam->GetName().c_str());
                        handler->PSendSysMessage("%u(%u) - %u(%u)", firstTeam->GetRating(), firstTeam->GetAverageMMR(firstTeamMember->GetGroup()),
                                                                    secondTeam->GetRating(), secondTeam->GetAverageMMR(secondTeamMember->GetGroup()));
                    }
                }
            }

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

            player->TeleportTo(target->GetMapId(), x, y, z, player->GetAngle(target), TELE_TO_GM_MODE);
            player->SetPhaseMask(target->GetPhaseMask(), true);
            player->SetSpectate(true);
            target->GetBattleground()->AddSpectator(player->GetGUID());

            return true;
        }

        static bool HandleSpectateCancelCommand(ChatHandler* handler, const char* /*args*/)
        {
            Player* player =  handler->GetSession()->GetPlayer();

            if (!player->isSpectator())
            {
                handler->PSendSysMessage("You are not spectator.");
                handler->SetSentErrorMessage(true);
                return false;
            }

            player->GetBattleground()->RemoveSpectator(player->GetGUID());
            player->CancelSpectate();
            player->TeleportToBGEntryPoint();

            return true;
        }

        static bool HandleSpectateFromCommand(ChatHandler* handler, const char *args)
        {
            Player* target;
            uint64 target_guid;
            std::string target_name;
            if (!handler->extractPlayerTarget((char*)args, &target, &target_guid, &target_name))
                return false;

            Player* player = handler->GetSession()->GetPlayer();

            if (!target)
            {
                handler->PSendSysMessage("Cant find player.");
                handler->SetSentErrorMessage(true);
                return false;
            }

            if (!player->isSpectator())
            {
                handler->PSendSysMessage("You are not spectator, spectate someone first.");
                handler->SetSentErrorMessage(true);
                return false;
            }

            if (target->isSpectator() && target != player)
            {
                handler->PSendSysMessage("Can`t do that. Your target is spectator.");
                handler->SetSentErrorMessage(true);
                return false;
            }

            if (player->GetMap() != target->GetMap())
            {
                handler->PSendSysMessage("Cant do that. Different arenas?");
                handler->SetSentErrorMessage(true);
                return false;
            }

            // check for arena preperation
            // if exists than battle didn`t begin
            if (target->HasAura(32728) || target->HasAura(32727))
            {
                handler->PSendSysMessage("Cant do that. Arena didn`t started.");
                handler->SetSentErrorMessage(true);
                return false;
            }

            (target == player && player->getSpectateFrom()) ? player->SetViewpoint(player->getSpectateFrom(), false) :
                                                                player->SetViewpoint(target, true);
            return true;
        }

        static bool HandleSpectateResetCommand(ChatHandler* handler, const char *args)
        {
            Player* player = handler->GetSession()->GetPlayer();

            if (!player)
            {
                handler->PSendSysMessage("Cant find player.");
                handler->SetSentErrorMessage(true);
                return false;
            }

            if (!player->isSpectator())
            {
                handler->PSendSysMessage("You are not spectator!");
                handler->SetSentErrorMessage(true);
                return false;
            }

            Battleground *bGround = player->GetBattleground();
            if (!bGround)
                return false;

            if (bGround->GetStatus() != STATUS_IN_PROGRESS)
                return true;

            for (Battleground::BattlegroundPlayerMap::const_iterator itr = bGround->GetPlayers().begin(); itr != bGround->GetPlayers().end(); ++itr)
                if (Player* tmpPlayer = ObjectAccessor::FindPlayer(itr->first))
                {
                    if (tmpPlayer->isSpectator())
                        continue;

                    uint32 tmpID = bGround->GetPlayerTeam(tmpPlayer->GetGUID());

                    // generate addon massage
                    std::string pName = tmpPlayer->GetName();
                    std::string tName = "";

                    if (Player *target = tmpPlayer->GetSelectedPlayer())
                        tName = target->GetName();

                    SpectatorAddonMsg msg;
                    msg.SetPlayer(pName);
                    if (tName != "")
                        msg.SetTarget(tName);
                    msg.SetStatus(tmpPlayer->isAlive());
                    msg.SetClass(tmpPlayer->getClass());
                    msg.SetCurrentHP(tmpPlayer->GetHealth());
                    msg.SetMaxHP(tmpPlayer->GetMaxHealth());
                    Powers powerType = tmpPlayer->getPowerType();
                    msg.SetMaxPower(tmpPlayer->GetMaxPower(powerType));
                    msg.SetCurrentPower(tmpPlayer->GetPower(powerType));
                    msg.SetPowerType(powerType);
                    msg.SetTeam(tmpID);
                    msg.SendPacket(player->GetGUID());
                }

            return true;
        }

        ChatCommand* GetCommands() const
        {
            static ChatCommand spectateCommandTable[] =
            {
                { "player",         SEC_PLAYER,      true,  &HandleSpectateCommand,        "", NULL },
                { "view",           SEC_PLAYER,      true,  &HandleSpectateFromCommand,    "", NULL },
                { "reset",          SEC_PLAYER,      true,  &HandleSpectateResetCommand,   "", NULL },
                { "leave",          SEC_PLAYER,      true,  &HandleSpectateCancelCommand,  "", NULL },
                { NULL,             0,               false, NULL,                          "", NULL }
            };

            static ChatCommand commandTable[] =
            {
                { "spectate",       SEC_PLAYER, false,  NULL, "", spectateCommandTable },
                { NULL,             0,          false,  NULL, "", NULL }
            };
            return commandTable;
        }
};


enum NpcSpectatorAtions {
    // will be used for scrolling
    NPC_SPECTATOR_ACTION_LIST_GAMES         = 1000,
    NPC_SPECTATOR_ACTION_LIST_TOP_GAMES     = 1800,

    // NPC_SPECTATOR_ACTION_SELECTED_PLAYER + player.Guid()
    NPC_SPECTATOR_ACTION_SELECTED_PLAYER    = 3000
};

const uint16 TopGamesRating = 1800;
const uint8  GamesOnPage    = 20;

class npc_arena_spectator : public CreatureScript
{
    public:
        npc_arena_spectator() : CreatureScript("npc_arena_spectator") { }

        bool OnGossipHello(Player* pPlayer, Creature* pCreature)
        {
            pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Arena Teams 1800+ mmr", GOSSIP_SENDER_MAIN, NPC_SPECTATOR_ACTION_LIST_TOP_GAMES);
            pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Arena Teams 1000+ mmr", GOSSIP_SENDER_MAIN, NPC_SPECTATOR_ACTION_LIST_GAMES);
            pPlayer->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, pCreature->GetGUID());
            return true;
        }

        bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 action)
        {
            player->PlayerTalkClass->ClearMenus();
            if (action >= NPC_SPECTATOR_ACTION_LIST_GAMES && action < NPC_SPECTATOR_ACTION_LIST_TOP_GAMES)
            {
                ShowPage(player, action - NPC_SPECTATOR_ACTION_LIST_GAMES, false);
                player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
            }
            else if (action >= NPC_SPECTATOR_ACTION_LIST_TOP_GAMES && action < NPC_SPECTATOR_ACTION_LIST_TOP_GAMES)
            {
                ShowPage(player, action - NPC_SPECTATOR_ACTION_LIST_TOP_GAMES, true);
                player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
            }
            else
            {
                uint64 guid = action - NPC_SPECTATOR_ACTION_SELECTED_PLAYER;
                if (Player* target = ObjectAccessor::FindPlayer(guid))
                {
                    ChatHandler handler(player->GetSession());
                     arena_spectator_commands::HandleSpectateCommand(&handler, target->GetName().c_str());
                }
            }
            return true;
        }

        std::string GetClassNameById(uint8 id)
        {
            std::string sClass = "";
            switch (id)
            {
                case CLASS_WARRIOR:         sClass = "Warrior ";        break;
                case CLASS_PALADIN:         sClass = "Pala ";           break;
                case CLASS_HUNTER:          sClass = "Hunt ";           break;
                case CLASS_ROGUE:           sClass = "Rogue ";          break;
                case CLASS_PRIEST:          sClass = "Priest ";         break;
                case CLASS_DEATH_KNIGHT:    sClass = "DK ";             break;
                case CLASS_SHAMAN:          sClass = "Shama ";          break;
                case CLASS_MAGE:            sClass = "Mage ";           break;
                case CLASS_WARLOCK:         sClass = "Warlock ";        break;
                case CLASS_DRUID:           sClass = "Druid ";          break;
            }
            return sClass;
        }

        std::string GetGamesStringData(Battleground *arena, uint16 mmr)
        {
            std::string teamsMember[BG_TEAMS_COUNT];
            uint32 firstTeamId = 0;
            for (Battleground::BattlegroundPlayerMap::const_iterator itr = arena->GetPlayers().begin(); itr != arena->GetPlayers().end(); ++itr)
                if (Player* player = ObjectAccessor::FindPlayer(itr->first))
                {
                    if (player->isSpectator())
                        continue;

                    uint32 team = itr->second.Team;
                    if (!firstTeamId)
                        firstTeamId = team;

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

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

        uint64 GetFirstPlayerGuid(Battleground *arena)
        {
            for (Battleground::BattlegroundPlayerMap::const_iterator itr = arena->GetPlayers().begin(); itr != arena->GetPlayers().end(); ++itr)
                if (Player* player = ObjectAccessor::FindPlayer(itr->first))
                    return itr->first;
            return 0;
        }

        void ShowPage(Player *player, uint16 page, bool isTop)
        {
            uint16 highGames  = 0;
            uint16 lowGames   = 0;
            bool haveNextPage = false;
            for (uint8 i = BATTLEGROUND_NA; i <= BATTLEGROUND_RV; ++i)
            {
                if (!sBattlegroundMgr->IsArenaType((BattlegroundTypeId)i))
                    continue;

                BattlegroundContainer bgs = sBattlegroundMgr->GetBattlegroundsByType((BattlegroundTypeId)i);
                for (BattlegroundContainer::iterator itr = bgs.begin(); itr != bgs.end(); ++itr)
                {
                    Battleground* arena = itr->second;

                    if (!arena->GetPlayersSize())
                        continue;

                    uint16 mmr = arena->GetArenaMatchmakerRatingByIndex(0) + arena->GetArenaMatchmakerRatingByIndex(1);
                    mmr /= 2;

                    if (isTop && mmr >= TopGamesRating)
                    {
                        highGames++;
                        if (highGames > (page + 1) * GamesOnPage)
                        {
                            haveNextPage = true;
                            break;
                        }

                        if (highGames >= page * GamesOnPage)
                            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, GetGamesStringData(arena, mmr), GOSSIP_SENDER_MAIN, NPC_SPECTATOR_ACTION_SELECTED_PLAYER + GetFirstPlayerGuid(arena));
                    }
                    else if (!isTop && mmr < TopGamesRating)
                    {
                        lowGames++;
                        if (lowGames > (page + 1) * GamesOnPage)
                        {
                            haveNextPage = true;
                            break;
                        }

                        if (lowGames >= page * GamesOnPage)
                            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, GetGamesStringData(arena, mmr), GOSSIP_SENDER_MAIN, NPC_SPECTATOR_ACTION_SELECTED_PLAYER + GetFirstPlayerGuid(arena));
                    }
                }
            }

            if (page > 0)
                player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Prev.", GOSSIP_SENDER_MAIN, NPC_SPECTATOR_ACTION_LIST_GAMES + page - 1);

            if (haveNextPage)
                player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Next.", GOSSIP_SENDER_MAIN, NPC_SPECTATOR_ACTION_LIST_GAMES + page + 1);
        }
};


void AddSC_arena_spectator_script()
{
    new arena_spectator_commands();
    new npc_arena_spectator();
}

I think I'm getting these errors because the script is outdated. Would appreciate some help. :)
 

Tommy

Founder
You could easily fix some of these errors without help. Double click the error, see it, open the auto complete menu to see the actual function then correct it. (Well, for isInCombat and isInFlight only)

'isInCombat' and 'isInFlight' should be: (IsInCombat & IsInFlight) - https://github.com/TrinityCore/Trin.../server/game/Entities/Unit/Unit.h#L1511-L1513

The other errors occur because you don't have the custom patch. You just can't take a random script like this and expect it to work right off the bat. Also, just because people don't answer doesn't mean nobody knows, it just means people are still sleeping, at work, at school, etc. Be patient.
 

Blazeqts

Enthusiast
This script doesn't require a custom patch tho. It just requires some stuff to be written in the battleground.h etc. I think. I thought maybe you would know what to write in there.

- I saw Jamey, Rochet and some others check this thread, and leave after ~30 minutes. So I assumed that no one knew. :p
 

Tommy

Founder
This script doesn't require a custom patch tho. It just requires some stuff to be written in the battleground.h etc. I think. I thought maybe you would know what to write in there.

- I saw Jamey, Rochet and some others check this thread, and leave after ~30 minutes. So I assumed that no one knew. :p

If it didn't require some custom additions - then these other errors wouldn't show. Such as:

'isSpectator' : is not a member of 'Player'

Meaning it needs to be setup in the player class because it isn't a member of Player. This goes for the rest.
 

Rochet2

Moderator / Eluna Dev
I tend to ignore some threads automatically I guess ..
Some of the errors are pretty obvious and could have been solved easily like tommy said.
Also your previous thread was similar to this. (the same error about functions having lowercase letter)

You do not (again?) have the full patch applied nor posted or something, as SpectatorAddonMsg is undefined.
This is the cause to probably all other errors except the one due to the TC update that changed most of the functions to start with a capital letter.
: |
 

Blazeqts

Enthusiast
With patch, you mean a .dif file or something like that, or do you mean like a .MPQ file, such as patch-3.MPQ that you get players to download?
 

Jameyboor

Retired Staff
I tend to ignore some threads automatically I guess ..
Some of the errors are pretty obvious and could have been solved easily like tommy said.
Also your previous thread was similar to this. (the same error about functions having lowercase letter)
Exactly this...

Anyways, here is the commit, you can copy the code of the spectatorAddonMgr to new files and it'll probably work.

https://github.com/walkline/Voodoo/commit/b86040a5b96460748af8c3949ffd1ad18a9a6bc2#commitcom ment-2269639
 

Jameyboor

Retired Staff
You're right, don't know where roch got that from, but its the correct patch though.. Just edit your files and add the code thats in green, and remove code thats in red, then recompile
 

Blazeqts

Enthusiast
Hmm. So I'm trying to apply this SQL query in the World table.

Code:
DELETE FROM `command` WHERE `name` = 'spectate';        
INSERT INTO `command` (`name`, `security`, `help`) VALUES ('spectate', 0, 'Syntax: .spectate $subcommand.\nUse .help sppectate');
DELETE FROM `command` WHERE `name` = 'spectatefrom';    
INSERT INTO `command` (`name`, `security`, `help`) VALUES ('spectate view', 0, 'Syntax: .spectate view #player\nAllow player to spectate arena from anotherplayer.');
DELETE FROM `command` WHERE `name` = 'spectate leav';   
INSERT INTO `command` (`name`, `security`, `help`) VALUES ('spectate leave', 0, 'Syntax: .spectate leave\nDisable spectator mode.');
DELETE FROM `command` WHERE `name` = 'spectate player'; 
INSERT INTO `command` (`name`, `security`, `help`) VALUES ('spectate player', 0, 'Syntax: .spectate player #player\nAllow to spectate player.');
DELETE FROM `command` WHERE `name` = 'spectate reset';  
INSERT INTO `command` (`name`, `security`, `help`) VALUES ('spectate reset', 0, 'Syntax: .spectate reset\nSend addon data.');

UPDATE `gameobject_template` SET `flags` = 36 WHERE entry IN (185918, 185917, 183970, 183971, 183972, 183973, 183977, 183979, 183978, 183980);

DELETE FROM creature_template WHERE entry = '190000'; 
INSERT INTO creature_template (entry, modelid1, name, subname, IconName, gossip_menu_id, minlevel, maxlevel, Health_mod, Mana_mod, Armor_mod, faction_A, faction_H, npcflag, speed_walk, speed_run, scale, rank, dmg_multiplier, unit_class, unit_flags, type, type_flags, InhabitType, RegenHealth, flags_extra, ScriptName) VALUES

and I get this error

Code:
SQL Error (1054): Unknown column 'security' in 'field list'

what to do? :eek:

- - - Updated - - -

also, this is the source: https://github.com/walkline/Voodoo/blob/b86040a5b96460748af8c3949ffd1ad18a9a6bc2/sql/updates/fc_updates_world/arena_spectator.sql
 

Reloac

BETA Tester
Security was removed when RBAC was moved to commands properly, you'll still need to make it IDs defined inside the RBAC.h not 0, as it wont work till you do (atleast from past experience it wont.)
 

Blazeqts

Enthusiast
It says here that I should put

Code:
#include "ArenaTeamMgr.h"

inside
Code:
src/server/game/Chat/Commands/Level0.cpp

but the Commands folder and the Level0.cpp file doesn't exist. What should I do?
 

Rochet2

Moderator / Eluna Dev
Ignore it
The include may be needed, but future compile errors will tell you if its needed somewhere anyways ,,
Likely cs_somethinghere.cpp
 
Status
Not open for further replies.
Top