diff options
author | /dev/humancontroller <devhc@example.com> | 2017-04-13 11:30:00 +0000 |
---|---|---|
committer | /dev/humancontroller <devhc@example.com> | 2017-04-15 17:24:22 +0200 |
commit | 91c463d4bfe3e57330e5fbce63c98eb22d5b208e (patch) | |
tree | 9c6ee7b76c0755d59ca48bd91ecb08280285fa06 /src/game | |
parent | 5510cfbeec0bcb59eac770fdb9b5132d7c61b426 (diff) |
implement !setdevmode: an admin command to switch developer mode on or off
Diffstat (limited to 'src/game')
-rw-r--r-- | src/game/g_admin.c | 49 | ||||
-rw-r--r-- | src/game/g_admin.h | 1 |
2 files changed, 50 insertions, 0 deletions
diff --git a/src/game/g_admin.c b/src/game/g_admin.c index 8a77326..99a08e5 100644 --- a/src/game/g_admin.c +++ b/src/game/g_admin.c @@ -351,6 +351,11 @@ g_admin_cmd_t g_admin_cmds[ ] = "[^3name|admin#^7]" }, + {"setdevmode", G_admin_setdevmode, "setdevmode", + "switch developer mode on or off", + "[^3on|off^7]" + }, + {"setlevel", G_admin_setlevel, "setlevel", "sets the admin level of a player", "[^3name|slot#|admin#^7] [^3level^7]" @@ -2973,6 +2978,50 @@ static qboolean admin_create_ban_check_repeats( gentity_t *ent, return qtrue; } +qboolean G_admin_setdevmode( gentity_t *ent, int skiparg ) +{ + char str[ 5 ]; + + if( G_SayArgc() != 2 + skiparg ) + { + ADMP( "^3!setdevmode: ^7usage: !setdevmode [on|off]\n" ); + return qfalse; + } + G_SayArgv( 1 + skiparg, str, sizeof( str ) ); + + if( !Q_stricmp( str, "on" ) ) + { + if( g_cheats.integer ) + { + ADMP( "^3!setdevmode: ^7developer mode is already on\n" ); + return qfalse; + } + trap_Cvar_Set( "sv_cheats", "1" ); + trap_Cvar_Update( &g_cheats ); + AP( va( "print \"^3!setdevmode: ^7%s ^7has switched developer mode on\n\"", + ent ? G_admin_adminPrintName( ent ) : "console" ) ); + } + else if( !Q_stricmp( str, "off" ) ) + { + if( !g_cheats.integer ) + { + ADMP( "^3!setdevmode: ^7developer mode is already off\n" ); + return qfalse; + } + trap_Cvar_Set( "sv_cheats", "0" ); + trap_Cvar_Update( &g_cheats ); + AP( va( "print \"^3!setdevmode: ^7%s ^7has switched developer mode off\n\"", + ent ? G_admin_adminPrintName( ent ) : "console" ) ); + } + else + { + ADMP( "^3!setdevmode: ^7usage: !setdevmode [on|off]\n" ); + return qfalse; + } + + return qtrue; +} + qboolean G_admin_kick( gentity_t *ent, int skiparg ) { int pids[ MAX_CLIENTS ]; diff --git a/src/game/g_admin.h b/src/game/g_admin.h index 7292fb4..93458b6 100644 --- a/src/game/g_admin.h +++ b/src/game/g_admin.h @@ -268,6 +268,7 @@ void G_admin_chat_update( gentity_t *ent, int chan ); // ! command functions qboolean G_admin_time( gentity_t *ent, int skiparg ); qboolean G_admin_setlevel( gentity_t *ent, int skiparg ); +qboolean G_admin_setdevmode( gentity_t *ent, int skiparg ); qboolean G_admin_kick( gentity_t *ent, int skiparg ); qboolean G_admin_adjustban( gentity_t *ent, int skiparg ); qboolean G_admin_subnetban( gentity_t *ent, int skiparg ); |