sm-plugins/ForceConvars/scripting/ForceConvars.sp

57 lines
1.8 KiB
SourcePawn
Raw Normal View History

2019-03-02 15:22:14 +01:00
#pragma newdecls required
#include <sourcemod>
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public Plugin myinfo =
{
2019-03-02 15:59:17 +01:00
name = "Force ConVars",
2019-03-02 15:22:14 +01:00
author = "zaCade",
2019-03-02 15:59:17 +01:00
description = "Force ConVars to specific values.",
2019-03-02 15:22:14 +01:00
version = "1.0.0"
};
2019-03-02 15:59:17 +01:00
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
{
if(GetEngineVersion() != Engine_CSGO)
{
strcopy(error, err_max, "This plugin is only required on CS:GO!");
return APLRes_Failure;
}
return APLRes_Success;
}
2019-03-02 15:22:14 +01:00
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnPluginStart()
{
RegServerCmd("sm_forcevar", Command_ForceCVar);
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public Action Command_ForceCVar(int args)
{
char sArguments[2][128];
GetCmdArg(1, sArguments[0], sizeof(sArguments[]));
GetCmdArg(2, sArguments[1], sizeof(sArguments[]));
2019-03-02 15:59:17 +01:00
2019-03-02 15:22:14 +01:00
ConVar CVar;
if ((CVar = FindConVar(sArguments[0])) != null)
{
float fValue = StringToFloat(sArguments[1]);
2019-03-02 15:59:17 +01:00
2019-03-02 15:22:14 +01:00
CVar.SetBounds(ConVarBound_Lower, true, fValue);
CVar.SetBounds(ConVarBound_Upper, true, fValue);
2019-03-02 15:59:17 +01:00
2019-03-02 15:22:14 +01:00
CVar.SetFloat(fValue, true, false);
}
}