Skip to content

Commit

Permalink
fix forced bots
Browse files Browse the repository at this point in the history
  • Loading branch information
CrimsonTautology committed Aug 12, 2020
1 parent 34b3fee commit 01c200e
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion addons/sourcemod/scripting/mapfix.sp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ public Plugin:myinfo =

new Handle:g_CachedTargetTrie = INVALID_HANDLE;
new Handle:g_Cvar_Timelimit = INVALID_HANDLE;
new Handle:g_Cvar_BotSlotpct = INVALID_HANDLE;

new bool:g_AutoFlipTimelimit = true;
new bool:g_AutoFlipBotSlotpct = true;

public OnPluginStart()
{
Expand All @@ -45,6 +48,9 @@ public OnPluginStart()
g_Cvar_Timelimit = FindConVar("mp_timelimit");
HookConVarChange(g_Cvar_Timelimit, OnTimelimitChanged);

g_Cvar_BotSlotpct = FindConVar("fof_sv_bot_slotpct");
HookConVarChange(g_Cvar_BotSlotpct, OnBotSlotpctChanged);

SetupTeleports();
}

Expand Down Expand Up @@ -79,8 +85,9 @@ public OnMapStart()
PrecacheSound("weapons/gatling/gattling_fire1.wav", true );
PrecacheSound("weapons/gatling/gattling_fire2.wav", true );

// reset mp_timelimit autoflip checker
// reset mp_timelimit and fof_sv_bot_slotpct autoflip checker
g_AutoFlipTimelimit = true;
g_AutoFlipBotSlotpct = true;
}

public Event_RoundStart(Event:event, const String:name[], bool:dontBroadcast)
Expand All @@ -104,6 +111,21 @@ public OnTimelimitChanged(Handle:convar, const String:oldValue[], const String:n

}

public OnBotSlotpctChanged(Handle:convar, const String:oldValue[], const String:newValue[])
{
// prevent bots from being turned on

// skip if we already did the autoflip
if (!g_AutoFlipBotSlotpct) return;

if (StrEqual(newValue, "0.300000")) {
PrintToServer("[MapFix] prevent auto change to fof_sv_bot_slotpct; reset to \"%s\"", oldValue);
SetConVarString(convar, oldValue);
g_AutoFlipBotSlotpct = false;
}

}

public FixCvarBounds()
{
//Some cvars are blocked from being changed in game; this will remove
Expand Down

0 comments on commit 01c200e

Please sign in to comment.