AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Snippets and Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=112)
-   -   [SNIPPET] How to block the change notification of cvars with NOTIFY flag (https://forums.alliedmods.net/showthread.php?t=144616)

xioSlayer 08-08-2011 06:04

Re: [SNIPPET] How to block the change notification of cvars with NOTIFY flag
 
I tried both methods and couldn't get the 'cvar changed' notifications to go away...

or does this only work on clients and not admins?

berni 08-08-2011 06:09

Re: [SNIPPET] How to block the change notification of cvars with NOTIFY flag
 
Your code + how you change convars please.

xioSlayer 08-08-2011 07:42

Re: [SNIPPET] How to block the change notification of cvars with NOTIFY flag
 
I just ended up editing basecommands.sp to never show cvar changes with sm_cvar.

That should work just fine for now I suppose.

RedSword 05-05-2012 19:29

Re: [SNIPPET] How to block the change notification of cvars with NOTIFY flag
 
Does anyone got it to work recently ?

Code:

public OnPluginStart()
{
        CreateConVar( "testcvar", "1", "Team Scramble version", FCVAR_PLUGIN );
        HookEvent("server_cvar", Event_ServerCvar, EventHookMode_Pre);
}
public Action:Event_ServerCvar(Handle:event, const String:name[], bool:dontBroadcast)
{
        decl String:cvarName[64];
        GetEventString(event, "cvarname", cvarName, sizeof(cvarName));
        PrintToChatAll(cvarName);

        if (StrEqual(cvarName, "testcvar")) {
                PrintToChatAll("string matched and handled");
                return Plugin_Handled;
        }
       
        return Plugin_Continue;
}

Doesn't work. Also it seems that the whole event isn't even triggered.

Is there another way ?

Bacardi 05-06-2012 02:20

Re: [SNIPPET] How to block the change notification of cvars with NOTIFY flag
 
Quote:

Originally Posted by RedSword (Post 1702958)
Doesn't work. Also it seems that the whole event isn't even triggered.

Is there another way ?

I assume you need add this flag to your cvar. Like what have few other srcds cvars... (mp_startmoney, mp_flashlight, sv_cheats)
PHP Code:

FCVAR_NOTIFY /**< Notifies players when changed. */ 


TnTSCS 05-06-2012 12:57

Re: [SNIPPET] How to block the change notification of cvars with NOTIFY flag
 
Saw this from KyleS (I think) a long time ago. This allows you to remove FCVAR_NOTIFY from Cvars

Might need some tweaking, but this is the gist:

PHP Code:


new String:cvars[][] = {"bot_quota""mp_startmoney""mp_flashlight""sv_cheats"};

public 
OnPluginStart()
{
    for(new 
0<sizeof(cvars); i++)
    {
        new 
Handle:CVarHandle FindConVar(cvars[i]);
        if (
CVarHandle != INVALID_HANDLE)
        {
            new 
flags;
            
flags GetConVarFlags(CVarHandle);
            
flags &= ~FCVAR_NOTIFY;
            
SetConVarFlags(CVarHandleflags);
            
CloseHandle(CVarHandle);
            return;
        }
        
ThrowError("Couldn't find %s. What sort of game is this?"cvars[i]);
        return;
    }


Or what about SetEventBroadcast(event, true);

KyleS 05-06-2012 16:29

Re: [SNIPPET] How to block the change notification of cvars with NOTIFY flag
 
Quote:

Originally Posted by TnTSCS (Post 1703502)
Saw this from KyleS (I think) a long time ago. This allows you to remove FCVAR_NOTIFY from Cvars

Might need some tweaking, but this is the gist:

PHP Code:


new String:cvars[][] = {"bot_quota""mp_startmoney""mp_flashlight""sv_cheats"};

public 
OnPluginStart()
{
    for(new 
0<sizeof(cvars); i++)
    {
        new 
Handle:CVarHandle FindConVar(cvars[i]);
        if (
CVarHandle != INVALID_HANDLE)
        {
            new 
flags;
            
flags GetConVarFlags(CVarHandle);
            
flags &= ~FCVAR_NOTIFY;
            
SetConVarFlags(CVarHandleflags);
            
CloseHandle(CVarHandle);
            return;
        }
        
ThrowError("Couldn't find %s. What sort of game is this?"cvars[i]);
        return;
    }


Or what about SetEventBroadcast(event, true);

If I did write that, my bad >.< That return should be a continue in the for.

minimoney1 05-07-2012 05:18

Re: [SNIPPET] How to block the change notification of cvars with NOTIFY flag
 
Why not use the same method in the OT and use SetEventBroadcast?


All times are GMT -4. The time now is 18:51.

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