Add /practicecmdlist

This commit is contained in:
furo 2024-05-12 00:14:52 +02:00
parent d34fc96049
commit 4e552d0f98
3 changed files with 27 additions and 13 deletions

View file

@ -695,22 +695,34 @@ void CGameContext::ConPractice(IConsole::IResult *pResult, void *pUserData)
{
Teams.SetPractice(Team, true);
pSelf->SendChatTeam(Team, "Practice mode enabled for your team, happy practicing!");
char aPracticeCommands[256];
mem_zero(aPracticeCommands, sizeof(aPracticeCommands));
str_append(aPracticeCommands, "Available practice commands: ");
for(const IConsole::CCommandInfo *pCmd = pSelf->Console()->FirstCommandInfo(IConsole::ACCESS_LEVEL_USER, CMDFLAG_PRACTICE);
pCmd; pCmd = pCmd->NextCommandInfo(IConsole::ACCESS_LEVEL_USER, CMDFLAG_PRACTICE))
{
char aCommand[64];
str_format(aCommand, sizeof(aCommand), "/%s%s", pCmd->m_pName, pCmd->NextCommandInfo(IConsole::ACCESS_LEVEL_USER, CMDFLAG_PRACTICE) ? ", " : "");
str_append(aPracticeCommands, aCommand);
}
pSelf->SendChatTeam(Team, aPracticeCommands);
pSelf->SendChatTeam(Team, "See /practicecmdlist for a list of all avaliable practice commands. Most commonly used ones are /telecursor, /lasttp and /rescue");
}
}
void CGameContext::ConPracticeCmdList(IConsole::IResult *pResult, void *pUserData)
{
CGameContext *pSelf = (CGameContext *)pUserData;
char aPracticeCommands[256];
mem_zero(aPracticeCommands, sizeof(aPracticeCommands));
str_append(aPracticeCommands, "Available practice commands: ");
for(const IConsole::CCommandInfo *pCmd = pSelf->Console()->FirstCommandInfo(IConsole::ACCESS_LEVEL_USER, CMDFLAG_PRACTICE);
pCmd; pCmd = pCmd->NextCommandInfo(IConsole::ACCESS_LEVEL_USER, CMDFLAG_PRACTICE))
{
char aCommand[64];
str_format(aCommand, sizeof(aCommand), "/%s%s", pCmd->m_pName, pCmd->NextCommandInfo(IConsole::ACCESS_LEVEL_USER, CMDFLAG_PRACTICE) ? ", " : "");
if(str_length(aCommand) + str_length(aPracticeCommands) > 255)
{
pSelf->SendChatTarget(pResult->m_ClientId, aPracticeCommands);
mem_zero(aPracticeCommands, sizeof(aPracticeCommands));
}
str_append(aPracticeCommands, aCommand);
}
pSelf->SendChatTarget(pResult->m_ClientId, aPracticeCommands);
}
void CGameContext::ConSwap(IConsole::IResult *pResult, void *pUserData)
{
CGameContext *pSelf = (CGameContext *)pUserData;

View file

@ -3656,6 +3656,7 @@ void CGameContext::RegisterChatCommands()
Console()->Register("mapinfo", "?r[map]", CFGFLAG_CHAT | CFGFLAG_SERVER, ConMapInfo, this, "Show info about the map with name r gives (current map by default)");
Console()->Register("timeout", "?s[code]", CFGFLAG_CHAT | CFGFLAG_SERVER, ConTimeout, this, "Set timeout protection code s");
Console()->Register("practice", "?i['0'|'1']", CFGFLAG_CHAT | CFGFLAG_SERVER, ConPractice, this, "Enable cheats (currently only /rescue) for your current team's run, but you can't earn a rank");
Console()->Register("practicecmdlist", "", CFGFLAG_CHAT | CFGFLAG_SERVER, ConPracticeCmdList, this, "List all commands that are avaliable in practice mode");
Console()->Register("swap", "?r[player name]", CFGFLAG_CHAT | CFGFLAG_SERVER, ConSwap, this, "Request to swap your tee with another team member");
Console()->Register("save", "?r[code]", CFGFLAG_CHAT | CFGFLAG_SERVER, ConSave, this, "Save team with code r.");
Console()->Register("load", "?r[code]", CFGFLAG_CHAT | CFGFLAG_SERVER, ConLoad, this, "Load with code r. /load to check your existing saves");

View file

@ -431,6 +431,7 @@ private:
static void ConMapInfo(IConsole::IResult *pResult, void *pUserData);
static void ConTimeout(IConsole::IResult *pResult, void *pUserData);
static void ConPractice(IConsole::IResult *pResult, void *pUserData);
static void ConPracticeCmdList(IConsole::IResult *pResult, void *pUserData);
static void ConSwap(IConsole::IResult *pResult, void *pUserData);
static void ConSave(IConsole::IResult *pResult, void *pUserData);
static void ConLoad(IConsole::IResult *pResult, void *pUserData);