Skip to content

Commit

Permalink
#261 - requires testing
Browse files Browse the repository at this point in the history
  • Loading branch information
safalin1 committed Feb 18, 2024
1 parent 0f68af4 commit 5539160
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/scripting/ConVars.sp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ ConVar g_hConVarPluginForceMinigame;
ConVar g_hConVarPluginForceBossgame;
ConVar g_hConVarPluginForceBossgameThreshold;
ConVar g_hConVarPluginMaxRounds;
ConVar g_hConVarWaitingForPlayersTime;

void InitializeConVars()
{
Expand All @@ -44,6 +45,7 @@ void InitializeConVars()
g_hConVarPluginIntermissionEnabled = CreateConVar("mtf2_intermission_enabled", "1", "Controls whether or not intermission is to be held half way through the maximum round count. Having Intermission enabled assumes you have a intermission integration enabled - for example the SourceMod Mapchooser integration.", 0, true, 0.0, true, 1.0);
g_hConVarPluginBonusPoints = CreateConVar("mtf2_bonuspoints", "0", "Controls whether or not minigames should have a bonus point.", 0, true, 0.0, true, 1.0);
g_hConVarPluginAllowCosmetics = CreateConVar("mtf2_cosmetics_enabled", "0", "Allows cosmetics to be worn by players. NOTE: This mode is explicitly not supported and may cause visual bugs and possible server lag spikes.", 0, true, 0.0, true, 1.0);
g_hConVarWaitingForPlayersTime = CreateConVar("mtf2_waitingforplayers_time", "60", "Sets the amount of time (in seconds) to wait for players to join after the map loads.", 0, true, 10.0);

if (g_hConVarPluginMaxRounds != INVALID_HANDLE)
{
Expand All @@ -55,6 +57,11 @@ void InitializeConVars()
HookConVarChange(g_hConVarPluginAllowCosmetics, OnAllowCosmeticsChanged);
}

if (g_hConVarWaitingForPlayersTime != INVALID_HANDLE)
{
HookConVarChange(g_hConVarWaitingForPlayersTime, OnWaitingForPlayersTimeChanged);
}

// Debugging ConVars / Commands. You don't really want these set all the time.
g_hConVarPluginForceMinigame = CreateConVar("mtf2_debug_forceminigame", "0", "Forces a minigame to always be played. If 0, no minigame will be forced. This cvar is used only when debugging.", 0, true, 0.0);
g_hConVarPluginForceBossgame = CreateConVar("mtf2_debug_forcebossgame", "0", "Forces a bossgame to always be played. If 0, no bossgame will be forced. This cvar is used only when debugging.", 0, true, 0.0);
Expand Down Expand Up @@ -96,7 +103,7 @@ void PrepareConVars()
// Multiplayer ConVars
SetConVarInt(FindConVar("mp_stalemate_enable"), 0);
SetConVarInt(FindConVar("mp_friendlyfire"), 1);
SetConVarInt(FindConVar("mp_waitingforplayers_time"), 90);
SetConVarInt(FindConVar("mp_waitingforplayers_time"), g_hConVarWaitingForPlayersTime.IntValue);
SetConVarInt(FindConVar("mp_disable_respawn_times"), 0);
SetConVarInt(FindConVar("mp_respawnwavetime"), 9999);
SetConVarInt(FindConVar("mp_idlemaxtime"), 8);
Expand Down Expand Up @@ -127,6 +134,16 @@ public void OnAllowCosmeticsChanged(Handle cvar, const char[] oldVal, const char
g_bAllowCosmetics = value == 1;
}

public void OnWaitingForPlayersTimeChanged(Handle cvar, const char[] oldVal, const char[] newVal)
{
if (g_bIsPluginEnabled)
{
int value = StringToInt(newVal);

SetConVarInt(FindConVar("mp_waitingforplayers_time"), value);
}
}

public bool Config_BonusPointsEnabled()
{
return g_hConVarPluginBonusPoints.BoolValue;
Expand Down

0 comments on commit 5539160

Please sign in to comment.