summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIronClawTrem <louie.nutman@gmail.com>2019-08-25 17:30:51 +0100
committerIronClawTrem <louie.nutman@gmail.com>2019-08-25 17:30:51 +0100
commit3db203fdc9906d700507056b837364e000dc5a7c (patch)
tree785a3dc7c3e3131a1fdb861dc0642fa9a1d2dc63
parent9fb9596cfa00676e94b69076d442091a23750f18 (diff)
add scrim command
-rw-r--r--src/game/g_admin.c46
-rw-r--r--src/game/g_admin.h3
-rw-r--r--src/game/g_client.c5
-rw-r--r--src/game/g_cmds.c26
-rw-r--r--src/game/g_local.h1
-rw-r--r--src/game/g_main.c4
6 files changed, 82 insertions, 3 deletions
diff --git a/src/game/g_admin.c b/src/game/g_admin.c
index ff65e70..05f43f4 100644
--- a/src/game/g_admin.c
+++ b/src/game/g_admin.c
@@ -389,6 +389,11 @@ g_admin_cmd_t g_admin_cmds[ ] =
{"bubble", G_admin_bubble, "bubble",
"continuously spawn bubbles around a player",
"[^3name|slot#^7]"
+ },
+
+ {"scrim", G_admin_scrim, "scrim",
+ "toggles scrim mode",
+ "[on|off]",
}
};
@@ -2331,6 +2336,7 @@ static AdminFlagListEntry_t adminFlagList[] =
{ ADMF_TEAMCHANGEFREE, "keeps credits on team switch" },
{ ADMF_TEAMCHAT_CMD, "can run commands from team chat" },
{ ADMF_UNACCOUNTABLE, "does not need to specify reason for kick/ban" },
+ { ADMF_NOSCRIMRESTRICTION, "team joining, vote and chat restrictions during scrims do not apply" },
{ ADMF_NO_BUILD, "can not build" },
{ ADMF_NO_CHAT, "can not talk" },
{ ADMF_NO_VOTE, "can not call votes" }
@@ -7589,3 +7595,43 @@ qboolean G_admin_bubble( gentity_t *ent, int skiparg )
return qtrue;
}
+
+qboolean G_admin_scrim(gentity_t *ent, int skiparg )
+{
+ char state[5];
+
+ if( G_SayArgc() < 2 + skiparg )
+ {
+ ADMP( "^3!scrim: ^7usage: !scrim [on|off]\n" );
+ return qfalse;
+ }
+
+ G_SayArgv( 1 + skiparg, state, sizeof( state ) );
+
+ if( !Q_stricmp(state, "on") )
+ {
+ if( g_scrimMode.integer != 0 )
+ {
+ ADMP( "^3!scrim: ^7scrim mode is already enabled.\n" );
+ return qfalse;
+ }
+ AP( va( "print \"^3!scrim: ^7%s ^7turned scrim mode ^2on^7\n\"", ( ent ) ? G_admin_adminPrintName( ent ) : "console" ) );
+ trap_Cvar_Set( "g_scrimMode", "1" );
+ }
+ else if( !Q_stricmp(state, "off") )
+ {
+ if( g_scrimMode.integer == 0 )
+ {
+ ADMP( "^3!scrim: ^7scrim mode is already disabled.\n" );
+ return qfalse;
+ }
+ AP( va( "print \"^3!scrim: ^7%s ^7turned scrim mode ^1off^7\n\"", ( ent ) ? G_admin_adminPrintName( ent ) : "console" ) );
+ trap_Cvar_Set( "g_scrimMode", "0" );
+
+ } else {
+ ADMP( "^3!scrim: ^7usage: !scrim [on|off]\n" );
+ return qfalse;
+ }
+
+ return qtrue;
+}
diff --git a/src/game/g_admin.h b/src/game/g_admin.h
index 602406a..f921d2e 100644
--- a/src/game/g_admin.h
+++ b/src/game/g_admin.h
@@ -98,6 +98,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#define ADMF_SPECIAL "SPECIAL"
#define ADMF_SPECIALNAME "SPECIALNAME"
+#define ADMF_NOSCRIMRESTRICTION "NOSCRIMRESTRICTION"
+
#define ADMF_NO_BUILD ".NOBUILD"
#define ADMF_NO_CHAT ".NOCHAT"
#define ADMF_NO_VOTE ".NOVOTE"
@@ -265,6 +267,7 @@ qboolean G_admin_setdevmode( gentity_t *ent, int skiparg );
qboolean G_admin_hstage( gentity_t *ent, int skiparg );
qboolean G_admin_astage( gentity_t *ent, int skiparg );
qboolean G_admin_bubble( gentity_t *ent, int skiparg );
+qboolean G_admin_scrim( gentity_t *ent, int skiparg );
void G_admin_print( gentity_t *ent, char *m );
void G_admin_buffer_print( gentity_t *ent, char *m );
diff --git a/src/game/g_client.c b/src/game/g_client.c
index b0751de..7a27f64 100644
--- a/src/game/g_client.c
+++ b/src/game/g_client.c
@@ -1619,6 +1619,11 @@ void ClientBegin( int clientNum )
// name can change between ClientConnect() and ClientBegin()
G_admin_namelog_update( client, qfalse );
+ if( g_scrimMode.integer == 1 )
+ {
+ ADMP( "^5Scrim mode is enabled. Teams are locked and you can only use spectator chat.\n" );
+ }
+
// request the clients PTR code
trap_SendServerCommand( ent - g_entities, "ptrcrequest" );
}
diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c
index 39ac73f..5ff0259 100644
--- a/src/game/g_cmds.c
+++ b/src/game/g_cmds.c
@@ -768,7 +768,14 @@ void Cmd_Team_f( gentity_t *ent )
va( "print \"You cannot join a team while invisible\n\"" ) );
return;
}
-
+
+ if( g_scrimMode.integer != 0 && !G_admin_permission( ent, ADMF_NOSCRIMRESTRICTION ) )
+ {
+ trap_SendServerCommand( ent-g_entities,
+ va( "print \"You can't join a team when scrim mode is enabled\n\"" ) );
+ return;
+ }
+
if( oldteam == PTE_ALIENS )
aliens--;
else if( oldteam == PTE_HUMANS )
@@ -992,7 +999,8 @@ static void G_SayTo( gentity_t *ent, gentity_t *other, int mode, int color, cons
}
if( mode == SAY_ADMINS &&
- (!G_admin_permission( other, ADMF_ADMINCHAT ) || other->client->pers.ignoreAdminWarnings ) )
+ (!G_admin_permission( other, ADMF_ADMINCHAT ) || other->client->pers.ignoreAdminWarnings ||
+ ( g_scrimMode.integer != 0 && !G_admin_permission( ent, ADMF_NOSCRIMRESTRICTION ) ) ) )
return;
if( mode == SAY_HADMINS &&
@@ -1037,6 +1045,12 @@ void G_Say( gentity_t *ent, gentity_t *target, int mode, const char *chatText )
return;
}
+ if( ent && ent->client->pers.teamSelection == PTE_NONE && g_scrimMode.integer != 0 && !G_admin_permission( ent, ADMF_NOSCRIMRESTRICTION ) && mode != SAY_TEAM )
+ {
+ trap_SendServerCommand( ent-g_entities, "print \"You can't chat when scrim mode is enabled.\n\"" );
+ return;
+ }
+
// Spam limit: If they said this message recently, ignore it.
if( g_spamTime.integer )
{
@@ -1581,6 +1595,14 @@ void Cmd_CallVote_f( gentity_t *ent )
return;
}
+ if( !G_admin_permission( ent, ADMF_NOSCRIMRESTRICTION ) && g_scrimMode.integer != 0 &&
+ ent->client->pers.teamSelection == PTE_NONE )
+ {
+ trap_SendServerCommand( ent - g_entities,
+ "print \"You can't call votes when scrim mode is enabled\n\"" );
+ return;
+ }
+
// make sure it is a valid command to vote on
trap_Argv( 1, arg1, sizeof( arg1 ) );
trap_Argv( 2, arg2, sizeof( arg2 ) );
diff --git a/src/game/g_local.h b/src/game/g_local.h
index 58a11eb..5a41a78 100644
--- a/src/game/g_local.h
+++ b/src/game/g_local.h
@@ -1485,6 +1485,7 @@ extern vmCvar_t g_aimbotAdvertBanTime;
extern vmCvar_t g_aimbotAdvertBanReason;
extern vmCvar_t g_Bubbles;
+extern vmCvar_t g_scrimMode;
void trap_Printf( const char *fmt );
void trap_Error( const char *fmt );
diff --git a/src/game/g_main.c b/src/game/g_main.c
index ef86b2c..5386f9f 100644
--- a/src/game/g_main.c
+++ b/src/game/g_main.c
@@ -236,6 +236,7 @@ vmCvar_t g_aimbotAdvertBanTime;
vmCvar_t g_aimbotAdvertBanReason;
vmCvar_t g_Bubbles;
+vmCvar_t g_scrimMode;
static cvarTable_t gameCvarTable[ ] =
{
@@ -449,7 +450,8 @@ static cvarTable_t gameCvarTable[ ] =
{ &g_aimbotAdvertBanTime, "g_aimbotAdvertBanTime", "0", CVAR_ARCHIVE, 0, qfalse },
{ &g_aimbotAdvertBanReason, "g_aimbotAdvertBanReason", "AUTOBAN: AIMBOT", CVAR_ARCHIVE, 0, qfalse },
- { &g_Bubbles, "g_Bubbles", "1", CVAR_ARCHIVE, 0, qfalse }
+ { &g_Bubbles, "g_Bubbles", "1", CVAR_ARCHIVE, 0, qfalse },
+ { &g_scrimMode, "g_scrimMode", "0", CVAR_ARCHIVE, 0, qfalse }
};
static int gameCvarTableSize = sizeof( gameCvarTable ) / sizeof( gameCvarTable[ 0 ] );