Skip to content

Instantly share code, notes, and snippets.

@Hexer10
Created March 23, 2020 19:05
Show Gist options
  • Select an option

  • Save Hexer10/a46bfec7b9f0c2350437719db0b363b1 to your computer and use it in GitHub Desktop.

Select an option

Save Hexer10/a46bfec7b9f0c2350437719db0b363b1 to your computer and use it in GitHub Desktop.
#include <sourcemod>
#include <sdktools>
#include <cstrike>
#define PLUGIN_NAME "ConVar Enforcer"
#define PLUGIN_VERSION "1.0"
#pragma semicolon 1
#pragma newdecls required
public Plugin myinfo =
{
name = PLUGIN_NAME,
author = "Hexah",
description = "",
version = PLUGIN_VERSION,
url = "github.com/Hexer10"
};
ConVar airAccelerate;
public void OnPluginStart()
{
airAccelerate = FindConVar("sv_accelerate");
airAccelerate.AddChangeHook(OnConVarChange);
}
public void OnMapStart()
{
airAccelerate.SetInt(10);
airAccelerate.SetBounds(ConVarBound_Upper, true, 10.0);
airAccelerate.SetBounds(ConVarBound_Lower, true, 10.0);
}
public void OnConVarChange(ConVar convar, const char[] oldValue, const char[] newValue)
{
int val = StringToInt(newValue);
if (val != 10)
{
PrintToServer("[CVAR] sv_accelerate was set to %s, forcing to 10", oldValue);
airAccelerate.SetInt(10);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment