diff --git a/src/game/client/gameclient.cpp b/src/game/client/gameclient.cpp index ceae1b5d7..be791284f 100644 --- a/src/game/client/gameclient.cpp +++ b/src/game/client/gameclient.cpp @@ -192,6 +192,7 @@ void CGameClient::OnConsoleInit() Console()->Register("broadcast", "r", CFGFLAG_SERVER, 0, 0, "Broadcast message"); Console()->Register("say", "r", CFGFLAG_SERVER, 0, 0, "Say in chat"); Console()->Register("set_team", "ii", CFGFLAG_SERVER, 0, 0, "Set team of player to team"); + Console()->Register("set_team_all", "i", CFGFLAG_SERVER, 0, 0, "Set team of all players to team"); Console()->Register("addvote", "r", CFGFLAG_SERVER, 0, 0, "Add a voting option"); Console()->Register("vote", "r", CFGFLAG_SERVER, 0, 0, "Force a vote to yes/no"); diff --git a/src/game/server/gamecontext.cpp b/src/game/server/gamecontext.cpp index 4f494f75e..906b9801f 100644 --- a/src/game/server/gamecontext.cpp +++ b/src/game/server/gamecontext.cpp @@ -904,6 +904,22 @@ void CGameContext::ConSetTeam(IConsole::IResult *pResult, void *pUserData) (void)pSelf->m_pController->CheckTeamBalance(); } +void CGameContext::ConSetTeamAll(IConsole::IResult *pResult, void *pUserData) +{ + CGameContext *pSelf = (CGameContext *)pUserData; + int Team = clamp(pResult->GetInteger(0), -1, 1); + + char aBuf[256]; + str_format(aBuf, sizeof(aBuf), "moved all clients to team %d", Team); + pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", aBuf); + + for(int i = 0; i < MAX_CLIENTS; ++i) + if(pSelf->m_apPlayers[i]) + pSelf->m_apPlayers[i]->SetTeam(Team); + + (void)pSelf->m_pController->CheckTeamBalance(); +} + void CGameContext::ConAddVote(IConsole::IResult *pResult, void *pUserData) { CGameContext *pSelf = (CGameContext *)pUserData; @@ -992,6 +1008,7 @@ void CGameContext::OnConsoleInit() Console()->Register("broadcast", "r", CFGFLAG_SERVER, ConBroadcast, this, ""); Console()->Register("say", "r", CFGFLAG_SERVER, ConSay, this, ""); Console()->Register("set_team", "ii", CFGFLAG_SERVER, ConSetTeam, this, ""); + Console()->Register("set_team_all", "i", CFGFLAG_SERVER, ConSetTeamAll, this, ""); Console()->Register("addvote", "r", CFGFLAG_SERVER, ConAddVote, this, ""); Console()->Register("vote", "r", CFGFLAG_SERVER, ConVote, this, ""); diff --git a/src/game/server/gamecontext.h b/src/game/server/gamecontext.h index f2326af80..55ad520ff 100644 --- a/src/game/server/gamecontext.h +++ b/src/game/server/gamecontext.h @@ -52,6 +52,7 @@ class CGameContext : public IGameServer static void ConBroadcast(IConsole::IResult *pResult, void *pUserData); static void ConSay(IConsole::IResult *pResult, void *pUserData); static void ConSetTeam(IConsole::IResult *pResult, void *pUserData); + static void ConSetTeamAll(IConsole::IResult *pResult, void *pUserData); static void ConAddVote(IConsole::IResult *pResult, void *pUserData); static void ConVote(IConsole::IResult *pResult, void *pUserData); static void ConchainSpecialMotdupdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData);