added command to move all players to a team. Closes #384

This commit is contained in:
oy 2011-01-06 13:37:28 +01:00
parent 73010e7d2e
commit 1306b62ce2
3 changed files with 19 additions and 0 deletions

View file

@ -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");

View file

@ -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, "");

View file

@ -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);