mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Merge pull request #8356 from furo321/split-practice-commands
Add `/practicecmdlist`
This commit is contained in:
commit
da0df30497
|
@ -695,22 +695,34 @@ void CGameContext::ConPractice(IConsole::IResult *pResult, void *pUserData)
|
||||||
{
|
{
|
||||||
Teams.SetPractice(Team, true);
|
Teams.SetPractice(Team, true);
|
||||||
pSelf->SendChatTeam(Team, "Practice mode enabled for your team, happy practicing!");
|
pSelf->SendChatTeam(Team, "Practice mode enabled for your team, happy practicing!");
|
||||||
|
pSelf->SendChatTeam(Team, "See /practicecmdlist for a list of all avaliable practice commands. Most commonly used ones are /telecursor, /lasttp and /rescue");
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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)
|
void CGameContext::ConSwap(IConsole::IResult *pResult, void *pUserData)
|
||||||
{
|
{
|
||||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||||
|
|
|
@ -3667,6 +3667,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("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("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("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("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("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");
|
Console()->Register("load", "?r[code]", CFGFLAG_CHAT | CFGFLAG_SERVER, ConLoad, this, "Load with code r. /load to check your existing saves");
|
||||||
|
|
|
@ -432,6 +432,7 @@ private:
|
||||||
static void ConMapInfo(IConsole::IResult *pResult, void *pUserData);
|
static void ConMapInfo(IConsole::IResult *pResult, void *pUserData);
|
||||||
static void ConTimeout(IConsole::IResult *pResult, void *pUserData);
|
static void ConTimeout(IConsole::IResult *pResult, void *pUserData);
|
||||||
static void ConPractice(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 ConSwap(IConsole::IResult *pResult, void *pUserData);
|
||||||
static void ConSave(IConsole::IResult *pResult, void *pUserData);
|
static void ConSave(IConsole::IResult *pResult, void *pUserData);
|
||||||
static void ConLoad(IConsole::IResult *pResult, void *pUserData);
|
static void ConLoad(IConsole::IResult *pResult, void *pUserData);
|
||||||
|
|
Loading…
Reference in a new issue