add /modhelp chat command

This commit is contained in:
Ryozuki 2018-01-21 01:32:55 +01:00
parent fd7d1463fc
commit 79fedff12d
6 changed files with 46 additions and 0 deletions

View file

@ -1363,6 +1363,45 @@ void CGameContext::ConProtectedKill(IConsole::IResult *pResult, void *pUserData)
//pSelf->SendChatTarget(pResult->m_ClientID, aBuf); //pSelf->SendChatTarget(pResult->m_ClientID, aBuf);
} }
} }
void CGameContext::ConModHelp(IConsole::IResult *pResult, void *pUserData)
{
CGameContext *pSelf = (CGameContext *) pUserData;
if (!CheckClientID(pResult->m_ClientID))
return;
CPlayer *pPlayer = pSelf->m_apPlayers[pResult->m_ClientID];
if (!pPlayer)
return;
if(pPlayer->m_ModHelpTick > pSelf->Server()->Tick())
{
char aBuf[126];
str_format(aBuf, sizeof(aBuf), "You must wait %d seconds to execute this command again.",
(pPlayer->m_ModHelpTick - pSelf->Server()->Tick()) / pSelf->Server()->TickSpeed());
pSelf->SendChatTarget(pResult->m_ClientID, aBuf);
return;
}
pPlayer->m_ModHelpTick = pSelf->Server()->Tick() + g_Config.m_SvModHelpDelay * pSelf->Server()->TickSpeed();
char aBuf[512];
str_format(aBuf, sizeof(aBuf), "Moderator help is requested by %s (ID: %d):",
pSelf->Server()->ClientName(pResult->m_ClientID),
pResult->m_ClientID);
// Send the request to all authed clients.
for ( int i = 0; i < MAX_CLIENTS; i++ )
{
if(pSelf->m_apPlayers[i] && pSelf->m_apPlayers[i]->m_Authed)
{
pSelf->SendChatTarget(pSelf->m_apPlayers[i]->GetCID(), aBuf);
pSelf->SendChatTarget(pSelf->m_apPlayers[i]->GetCID(), pResult->GetString(0));
}
}
}
#if defined(CONF_SQL) #if defined(CONF_SQL)
void CGameContext::ConPoints(IConsole::IResult *pResult, void *pUserData) void CGameContext::ConPoints(IConsole::IResult *pResult, void *pUserData)
{ {

View file

@ -47,6 +47,8 @@ CHAT_COMMAND("rescue", "", CFGFLAG_CHAT|CFGFLAG_SERVER, ConRescue, this, "Telepo
CHAT_COMMAND("kill", "", CFGFLAG_CHAT|CFGFLAG_SERVER, ConProtectedKill, this, "Kill yourself") CHAT_COMMAND("kill", "", CFGFLAG_CHAT|CFGFLAG_SERVER, ConProtectedKill, this, "Kill yourself")
CHAT_COMMAND("modhelp", "r[message]", CFGFLAG_CHAT|CFGFLAG_SERVER, ConModHelp, this, "Request the help of a moderator with a description of the problem")
#if defined(CONF_SQL) #if defined(CONF_SQL)
CHAT_COMMAND("times", "?s[player name] ?i[number of times to skip]", CFGFLAG_CHAT|CFGFLAG_SERVER, ConTimes, this, "/times ?s?i shows last 5 times of the server or of a player beginning with name s starting with time i (i = 1 by default)") CHAT_COMMAND("times", "?s[player name] ?i[number of times to skip]", CFGFLAG_CHAT|CFGFLAG_SERVER, ConTimes, this, "/times ?s?i shows last 5 times of the server or of a player beginning with name s starting with time i (i = 1 by default)")
CHAT_COMMAND("points", "?r[player name]", CFGFLAG_CHAT|CFGFLAG_SERVER, ConPoints, this, "Shows the global points of a player beginning with name r (your rank by default)") CHAT_COMMAND("points", "?r[player name]", CFGFLAG_CHAT|CFGFLAG_SERVER, ConPoints, this, "Shows the global points of a player beginning with name r (your rank by default)")

View file

@ -343,6 +343,7 @@ private:
static void ConUnmute(IConsole::IResult *pResult, void *pUserData); static void ConUnmute(IConsole::IResult *pResult, void *pUserData);
static void ConMutes(IConsole::IResult *pResult, void *pUserData); static void ConMutes(IConsole::IResult *pResult, void *pUserData);
static void ConModerate(IConsole::IResult *pResult, void *pUserData); static void ConModerate(IConsole::IResult *pResult, void *pUserData);
static void ConModHelp(IConsole::IResult *pResult, void *pUserData);
static void ConList(IConsole::IResult *pResult, void *pUserData); static void ConList(IConsole::IResult *pResult, void *pUserData);
static void ConSetDDRTeam(IConsole::IResult *pResult, void *pUserData); static void ConSetDDRTeam(IConsole::IResult *pResult, void *pUserData);

View file

@ -70,6 +70,7 @@ void CPlayer::Reset()
m_LastWhisperTo = -1; m_LastWhisperTo = -1;
m_LastSetSpectatorMode = 0; m_LastSetSpectatorMode = 0;
m_TimeoutCode[0] = '\0'; m_TimeoutCode[0] = '\0';
m_ModHelpTick = 0;
m_TuneZone = 0; m_TuneZone = 0;
m_TuneZoneOld = m_TuneZone; m_TuneZoneOld = m_TuneZone;

View file

@ -177,6 +177,7 @@ public:
int m_ChatScore; int m_ChatScore;
bool m_Moderating; bool m_Moderating;
int m_ModHelpTick;
bool AfkTimer(int new_target_x, int new_target_y); //returns true if kicked bool AfkTimer(int new_target_x, int new_target_y); //returns true if kicked
void AfkVoteTimer(CNetObj_PlayerInput *NewTarget); void AfkVoteTimer(CNetObj_PlayerInput *NewTarget);

View file

@ -164,6 +164,8 @@ MACRO_CONFIG_INT(SvSendVotesPerTick, sv_send_votes_per_tick, 5, 1, 15, CFGFLAG_S
MACRO_CONFIG_INT(SvRescue, sv_rescue, 0, 0, 1, CFGFLAG_SERVER, "Allow /rescue command so players can teleport themselves out of freeze") MACRO_CONFIG_INT(SvRescue, sv_rescue, 0, 0, 1, CFGFLAG_SERVER, "Allow /rescue command so players can teleport themselves out of freeze")
MACRO_CONFIG_INT(SvRescueDelay, sv_rescue_delay, 5, 0, 1000, CFGFLAG_SERVER, "Number of seconds inbetween two rescues") MACRO_CONFIG_INT(SvRescueDelay, sv_rescue_delay, 5, 0, 1000, CFGFLAG_SERVER, "Number of seconds inbetween two rescues")
MACRO_CONFIG_INT(SvModHelpDelay, sv_modhelp_delay, 60, 0, 0, CFGFLAG_SERVER, "Number of seconds to wait before executing /modhelp again")
// debug // debug
#ifdef CONF_DEBUG // this one can crash the server if not used correctly #ifdef CONF_DEBUG // this one can crash the server if not used correctly
MACRO_CONFIG_INT(DbgDummies, dbg_dummies, 0, 0, 15, CFGFLAG_SERVER, "") MACRO_CONFIG_INT(DbgDummies, dbg_dummies, 0, 0, 15, CFGFLAG_SERVER, "")