View Single Post
Ilusion9
Veteran Member
Join Date: Jun 2018
Location: Romania
Old 02-13-2019 , 05:35   Re: To hook or not to hook, that is the question.
Reply With Quote #9

Quote:
Originally Posted by Crasher_3637 View Post
To add more to this, we hook a cvar handle to a changehook if we want something to happen as soon as the value of that cvar is changed.
Or to block that change to happen.

PHP Code:

public void OnPluginStart() 

    
g_cvMPGameMode FindConVar("mp_gamemode"); 

    if (
g_cvMPGameMode != null
    { 
        
g_cvMPGameMode.AddChangeHook(vMPGameModeHook); 
    } 



public 
void vMPGameModeHook(ConVar convar, const char[] oldVal, const char[] newVal

    if (!
StrEqual(newVal"versus")) 
    { 
        
g_cvMPGameMode.SetString("versus"));
    } 

__________________
Ilusion9 is offline