From ae6184b1739bd2fa47b3acd3547063d6df1f1e31 Mon Sep 17 00:00:00 2001 From: BidyBiddle Date: Fri, 24 Sep 2021 19:17:19 +0200 Subject: [PATCH] added sv_forceGear Allow server admins to set a specific gear for all players. Co-Authored-By: Taras Mykhailovych <6552671+tarquas@users.noreply.github.com> --- code/server/server.h | 1 + code/server/sv_client.c | 8 ++++++++ code/server/sv_init.c | 1 + code/server/sv_main.c | 1 + 4 files changed, 11 insertions(+) diff --git a/code/server/server.h b/code/server/server.h index 5e851eb169..e6f1a2b7c1 100644 --- a/code/server/server.h +++ b/code/server/server.h @@ -351,6 +351,7 @@ extern cvar_t *sv_sayprefix; extern cvar_t *sv_tellprefix; extern cvar_t *sv_teamSwitch; // allow players to switch teams (0, Default = players must wait 5 seconds, 1 = no restriction) extern cvar_t *sv_substitute; // allow players to use /sub in matchmode (1, Default = substitutes enabled, 0 = disabled) +extern cvar_t *sv_forceGear; // Every client's gear will be set to this value ("", Default = empty string meaning no restriction) #ifdef USE_VOIP extern cvar_t *sv_voip; diff --git a/code/server/sv_client.c b/code/server/sv_client.c index ec187596e3..328bc79451 100644 --- a/code/server/sv_client.c +++ b/code/server/sv_client.c @@ -1155,6 +1155,10 @@ void SV_UpdateUserinfo_f( client_t *cl ) { Q_strncpyz( cl->userinfo, Cmd_Argv(1), sizeof(cl->userinfo) ); + if (sv_forceGear && Q_stricmp(sv_forceGear->string, "")) { + Info_SetValueForKey(cl->userinfo, "gear", sv_forceGear->string); + } + SV_UserinfoChanged( cl ); // call prog code to allow overrides VM_Call( gvm, GAME_CLIENT_USERINFO_CHANGED, cl - svs.clients ); @@ -1399,6 +1403,10 @@ void SV_ClientThink (client_t *cl, usercmd_t *cmd) { return; // may have been kicked during the last usercmd } + if (sv_forceGear && Q_stricmp(sv_forceGear->string, "")) { + Info_SetValueForKey(cl->userinfo, "gear", sv_forceGear->string); + } + #ifdef USE_SKEETMOD SV_SkeetBackupPowerups(cl); #endif diff --git a/code/server/sv_init.c b/code/server/sv_init.c index bb77a4f6aa..2a7800ea7c 100644 --- a/code/server/sv_init.c +++ b/code/server/sv_init.c @@ -930,6 +930,7 @@ void SV_Init (void) sv_tellprefix = Cvar_Get ("sv_tellprefix", "console_tell: ", CVAR_ARCHIVE ); sv_teamSwitch = Cvar_Get("sv_teamSwitch", "0", CVAR_ARCHIVE ); sv_substitute = Cvar_Get ("sv_substitute", "1", CVAR_ARCHIVE ); + sv_forceGear = Cvar_Get ("sv_forceGear", "", CVAR_ARCHIVE ); sv_extraPaks = Cvar_Get ("sv_extraPaks", "", CVAR_ARCHIVE | CVAR_LATCH); sv_extraPure = Cvar_Get ("sv_extraPure", "0", CVAR_ARCHIVE | CVAR_LATCH); diff --git a/code/server/sv_main.c b/code/server/sv_main.c index 0c1bdcf7ae..48286bfa39 100644 --- a/code/server/sv_main.c +++ b/code/server/sv_main.c @@ -65,6 +65,7 @@ cvar_t *sv_tellprefix; cvar_t *sv_sayprefix; cvar_t *sv_teamSwitch; // allow players to switch teams (0, Default = players must wait 5 seconds to switch, 1 = no restriction) cvar_t *sv_substitute; // allow players to use /sub in matchmode (1, Default = substitutes enabled, 0 = disabled) +cvar_t *sv_forceGear; // Every client's gear will be set to this value ("", Default = empty string meaning no restriction) #ifdef USE_VOIP cvar_t *sv_voip;