add vote_mutes

This commit is contained in:
Ryozuki 2019-03-19 20:25:21 +01:00
parent 43a1990e5d
commit e00e9f126a
No known key found for this signature in database
GPG key ID: 848FCC08E5B89681
3 changed files with 34 additions and 0 deletions

View file

@ -43,6 +43,7 @@ CONSOLE_COMMAND("uninvite", "v[id] ?i[team]", CFGFLAG_SERVER, ConUninvite, this,
CONSOLE_COMMAND("vote_mute", "v[id] i[seconds]", CFGFLAG_SERVER, ConVoteMute, this, "Remove v's right to vote for i seconds")
CONSOLE_COMMAND("vote_unmute", "v[id]", CFGFLAG_SERVER, ConVoteUnmute, this, "Give back v's right to vote.")
CONSOLE_COMMAND("vote_mutes", "", CFGFLAG_SERVER, ConVoteMutes, this, "List the current active vote mutes.")
CONSOLE_COMMAND("mute", "", CFGFLAG_SERVER, ConMute, this, "")
CONSOLE_COMMAND("muteid", "v[id] i[seconds]", CFGFLAG_SERVER, ConMuteID, this, "")
CONSOLE_COMMAND("muteip", "s[ip] i[seconds]", CFGFLAG_SERVER, ConMuteIP, this, "")

View file

@ -496,6 +496,38 @@ void CGameContext::ConVoteUnmute(IConsole::IResult *pResult, void *pUserData)
}
}
void CGameContext::ConVoteMutes(IConsole::IResult *pResult, void *pUserData)
{
CGameContext *pSelf = (CGameContext *) pUserData;
if (pSelf->m_NumVoteMutes <= 0)
{
// Just to make sure.
pSelf->m_NumVoteMutes = 0;
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "votemutes",
"There are no active vote mutes.");
return;
}
char aIpBuf[64];
char aBuf[128];
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "votemutes",
"Active vote mutes:");
for (int i = 0; i < pSelf->m_NumVoteMutes; i++)
{
net_addr_str(&pSelf->m_aVoteMutes[i].m_Addr, aIpBuf, sizeof(aIpBuf), false);
str_format(
aBuf,
sizeof aBuf,
"%d: \"%s\", %d seconds left",
i,
aIpBuf,
(pSelf->m_aVoteMutes[i].m_Expire - pSelf->Server()->Tick())
/ pSelf->Server()->TickSpeed());
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "votemutes", aBuf);
}
}
void CGameContext::ConMute(IConsole::IResult *pResult, void *pUserData)
{
CGameContext *pSelf = (CGameContext *) pUserData;

View file

@ -354,6 +354,7 @@ private:
static void ConVoteMute(IConsole::IResult *pResult, void *pUserData);
static void ConVoteUnmute(IConsole::IResult *pResult, void *pUserData);
static void ConVoteMutes(IConsole::IResult *pResult, void *pUserData);
static void ConMute(IConsole::IResult *pResult, void *pUserData);
static void ConMuteID(IConsole::IResult *pResult, void *pUserData);
static void ConMuteIP(IConsole::IResult *pResult, void *pUserData);