gamemode command for getting info and switching gamemodes

This commit is contained in:
BjossiAlfreds 2021-11-08 17:39:53 +00:00 committed by Yamagi
parent 37cfb61b1f
commit 91e2cfdada

View file

@ -678,9 +678,83 @@ SV_ServerCommand_f(void)
ge->ServerCommand();
}
void
SV_Gamemode_f(void)
{
int none;
char *arg;
if (Cmd_Argc() != 2)
{
Com_Printf("gamemode dm, coop or sp\ngamemode ? to print current info\n");
return;
}
arg = Cmd_Argv(1);
if (*arg == '?')
{
none = 1;
if (Cvar_VariableValue("deathmatch"))
{
Com_Printf("dm ");
none = 0;
}
if (Cvar_VariableValue("coop"))
{
Com_Printf("coop ");
none = 0;
}
if (Cvar_VariableValue("singleplayer"))
{
Com_Printf("sp ");
none = 0;
}
if (none)
{
Com_Printf("none\n");
}
else
{
Com_Printf("\n");
}
return;
}
if (strcmp(arg, "dm") == 0)
{
Cvar_Set("deathmatch", "1");
Cvar_Set("coop", "0");
Cvar_Set("singleplayer", "0");
}
else if (strcmp(arg, "coop") == 0)
{
Cvar_Set("deathmatch", "0");
Cvar_Set("coop", "1");
Cvar_Set("singleplayer", "0");
}
else if (strcmp(arg, "sp") == 0)
{
Cvar_Set("deathmatch", "0");
Cvar_Set("coop", "0");
Cvar_Set("singleplayer", "1");
}
else
{
Com_Printf("unknown gamemode: '%s'\nspecify dm, coop or sp\n", arg);
}
}
void
SV_InitOperatorCommands(void)
{
Cmd_AddCommand("gamemode", SV_Gamemode_f);
Cmd_AddCommand("heartbeat", SV_Heartbeat_f);
Cmd_AddCommand("kick", SV_Kick_f);
Cmd_AddCommand("status", SV_Status_f);