diff options
| author | Marius "Teelevision" Neugebauer <marius@teele.eu> | 2014-05-07 20:01:01 +0200 |
|---|---|---|
| committer | Marius "Teelevision" Neugebauer <marius@teele.eu> | 2014-05-07 20:01:01 +0200 |
| commit | 67187219aae6a9071845e380b43128abdf53f617 (patch) | |
| tree | f53dc64d8c6b78dfb14d9b343df8e110184ca298 /src | |
| parent | 25c71282cf26948001a9d01678f97ccc07ae138e (diff) | |
| download | zcatch-67187219aae6a9071845e380b43128abdf53f617.tar.gz zcatch-67187219aae6a9071845e380b43128abdf53f617.zip | |
added rcon command to kill a player
Diffstat (limited to 'src')
| -rw-r--r-- | src/game/server/gamecontext.cpp | 23 | ||||
| -rw-r--r-- | src/game/server/gamecontext.h | 2 |
2 files changed, 25 insertions, 0 deletions
diff --git a/src/game/server/gamecontext.cpp b/src/game/server/gamecontext.cpp index f9158eb5..f2c51fc5 100644 --- a/src/game/server/gamecontext.cpp +++ b/src/game/server/gamecontext.cpp @@ -1917,6 +1917,27 @@ void CGameContext::ConUnmuteIP(IConsole::IResult *pResult, void *pUserData) } } +void CGameContext::ConKill(IConsole::IResult *pResult, void *pUserData) +{ + CGameContext *pSelf = (CGameContext *)pUserData; + int CID = pResult->GetInteger(0); + if(CID < 0 || CID >= MAX_CLIENTS || !pSelf->m_apPlayers[CID]) + { + pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "Server", "Invalid ClientID"); + return; + } + if(pSelf->m_apPlayers[CID]->GetCharacter() == 0) + { + pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "Server", "Player is already dead"); + return; + } + pSelf->m_apPlayers[CID]->KillCharacter(); + // message to console and chat + char aBuf[128]; + str_format(aBuf, sizeof(aBuf), "'%s' has been killed by admin.", pSelf->Server()->ClientName(CID)); + pSelf->SendChatTarget(-1, aBuf); +} + void CGameContext::OnConsoleInit() { m_pServer = Kernel()->RequestInterface<IServer>(); @@ -1948,6 +1969,8 @@ void CGameContext::OnConsoleInit() Console()->Register("unmuteid", "i", CFGFLAG_SERVER, ConUnmuteID, this, "Unmutes a player by its client id"); Console()->Register("unmuteip", "i", CFGFLAG_SERVER, ConUnmuteIP, this, "Removes a mute by its index"); Console()->Register("mutes", "", CFGFLAG_SERVER, ConMutes, this, "Show all mutes"); + + Console()->Register("kill", "i", CFGFLAG_SERVER, ConKill, this, "Kill a player by id"); Console()->Chain("sv_motd", ConchainSpecialMotdupdate, this); } diff --git a/src/game/server/gamecontext.h b/src/game/server/gamecontext.h index 1b980a6f..b4435dfb 100644 --- a/src/game/server/gamecontext.h +++ b/src/game/server/gamecontext.h @@ -72,6 +72,8 @@ class CGameContext : public IGameServer static void ConUnmuteID(IConsole::IResult *pResult, void *pUserData); static void ConUnmuteIP(IConsole::IResult *pResult, void *pUserData); static void ConMutes(IConsole::IResult *pResult, void *pUserData); + + static void ConKill(IConsole::IResult *pResult, void *pUserData); CGameContext(int Resetting); void Construct(int Resetting); |