Hello everyone!
I'm trying to get some ConVars to work. The problem is - they do not work O_o
In the beginning of my code I set every cvar to a global var. For some reason the cvar always gets it's default value (given in CreateConVar).
If I check the cvar later (with GetConVarInt), it is the correct value. What am I doing wrong?
PHP Code:
new Handle:LRsenabled;
// ConVar-stuff
new Handle:sm_hosties_knife_enable = INVALID_HANDLE;
new Handle:sm_hosties_s4s_enable = INVALID_HANDLE;
new Handle:sm_hosties_guntoss_enable = INVALID_HANDLE;
new Handle:sm_hosties_chickenfight_enable = INVALID_HANDLE;
public OnPluginStart()
{
RegConsoleCmd("sm_cvarcheck", Command_CvarCheck);
// Create ConVars
sm_hosties_knife_enable = CreateConVar("sm_hosties_knife_enable", "1", "Enable LR Knife Fight; 0 - disable, 1 - enable")
sm_hosties_s4s_enable = CreateConVar("sm_hosties_s4s_enable", "1", "Enable LR Shot4Shot; 0 - disable, 1 - enable")
sm_hosties_guntoss_enable = CreateConVar("sm_hosties_guntoss_enable", "1", "Enable LR Gun Toss; 0 - disable, 1 - enable")
sm_hosties_chickenfight_enable = CreateConVar("sm_hosties_chickenfight_enable", "1", "Enable LR Chicken Fight; 0 - disable, 1 - enable")
AutoExecConfig(true, "sm_hosties")
knife_enable = GetConVarInt(sm_hosties_knife_enable);
s4s_enable = GetConVarInt(sm_hosties_s4s_enable);
guntoss_enable = GetConVarInt(sm_hosties_guntoss_enable);
chickenfight_enable = GetConVarInt(sm_hosties_chickenfight_enable);
LRsenabled = CreateArray(2);
// THESE ARE ALWAYS == 1, whatever I set the cvars to -.- (here's some problem)
if (knife_enable == 1)
{
PushArrayCell(LRsenabled, 0);
}
if (s4s_enable == 1)
{
PushArrayCell(LRsenabled, 1);
}
if (guntoss_enable == 1)
{
PushArrayCell(LRsenabled, 2);
}
if (chickenfight_enable == 1)
{
PushArrayCell(LRsenabled, 3);
}
}
public Action:Command_CvarCheck(client, args)
{
if (GetConVarInt(sm_hosties_guntoss_enable) == 0) // THIS works just like I want it to
{
PrintToChatAll("GetConVarInt(sm_hosties_guntoss_enable) was 0.");
}
return Plugin_Handled;
}