Raised This Month: $51 Target: $400
 12% 

Trouble modifying cvar flags


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
IceCucumber
Member
Join Date: Dec 2011
Old 10-17-2014 , 08:47   Trouble modifying cvar flags
Reply With Quote #1

Edit: I believe this answers my question: https://forums.alliedmods.net/showthread.php?t=92289
Pardon me, should've googled more intensively before making a thread.

I'm trying to toggle whether or not the cvar "fog_enable" is sv_cheats protected or not. Tried following the wiki at https://wiki.alliedmods.net/ConVars_...pting%29#Flags but I'm getting this error:
Quote:
[SM] Native "GetConVarFlags" reported: Invalid convar handle 0 (error 4)
[SM] Displaying call stack trace for plugin "flagstest.smx":
[SM] [0] Line 21, flagstest.sp::UnsetCheatVar()
[SM] [1] Line 14, flagstest.sp::Command_Fog()
Here's my code:
Code:
#include <sourcemod>

new Handle:fogEnable;

public OnPluginStart()
{
    fogEnable = FindConVar("fog_enable");
    
    RegConsoleCmd("sm_fog_test", Command_Fog);
}

public Action:Command_Fog(client, args)
{
    UnsetCheatVar(fogEnable);
    PrintToChat(client, "fog_enable should no longer be sv_cheats protected.");
    return Plugin_Handled;
}

UnsetCheatVar(Handle:hndl)
{
    new flags = GetConVarFlags(hndl);
    flags &= ~FCVAR_CHEAT;
    SetConVarFlags(hndl, flags);
}
I'm assuming this is because FindConVar("fog_enable") doesn't find the cvar. Why is that? Am I doing something wrong?

Last edited by IceCucumber; 10-17-2014 at 09:01.
IceCucumber is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 13:40.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode