AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved hook_cvar_change and RH_Cvar_DirectSet not working (https://forums.alliedmods.net/showthread.php?t=338171)

LiZou Mapper 06-13-2022 15:07

hook_cvar_change and RH_Cvar_DirectSet not working
 
Hi everyone!
I searched a lot before doing this Thread.
The problem is forward hook_cvar_change() not working.
I used RH_Cvar_DirectSet from ReAPI, It doesn't work either.

hook_cvar_change(): I changed the value in cvar, I don't see any message:

This message appears when a server is activated:
PHP Code:

L 06/13/2022 19:50:55client_disconnected and client_remove forwards have been disabled check your gamedata files.
L 06/13/2022 19:50:55Binding/Hooking cvars have been disabled check your gamedata file 

RH_Cvar_DirectSet:
PHP Code:

L 06/13/2022 19:50:57: [ReAPIRegisterHookChain: function (Cvar_DirectSetis not availableReHLDS required.
L 06/13/2022 19:50:57: [AMXXRun time error 10 (plugin "cstrike.amxx") (native "RegisterHookChain") - debug not enabled!
L 06/13/2022 19:50:57: [AMXXTo enable debug modeadd "debug" after the plugin name in plugins.ini (without quote 

Plugin:
PHP Code:

#include <amxmodx>
#include <reapi>

// Global Variables.
new g_pCvar_iValue

// Forward called after server activation.
public plugin_init()
{
    
// Load plugin.
    
register_plugin("[ZE] Set Rendering""1.0""z0h1r-LK")

    
// Hook Chains.
    
RegisterHookChain(RH_Cvar_DirectSet"fw_Cvar_DirectSet_Post"1)

    
// Cvars.
    
g_pCvar_iValue register_cvar("amx_value""1")
    
hook_cvar_change(g_pCvar_iValue"fw_CvarChange_Post")
}

// Forward called when change value from cvar "amx_value".
public fw_CvarChange_Post(pCvar, const szOldVal[], const szNewVal[])
{
    
// Print message on server console.
    
server_print("[AMXX] cvar: %d | old value: %s | new value: %s"pCvarszOldValszNewVal)
}

// Hook called when change value in any cvar.
public fw_Cvar_DirectSet_Post(pCvar, const szVal[])
{
    
// Print message on server console.
    
server_print("[ReAPI] cvar: %d | value: %d"pCvarszVal)


I use:
OS: Windows
AMX Mod X v1.10.0.5461
ReAPI v5.21.0.252-dev
MetaMod-R v1.3.0.86
ReHLDS v3.10.0.759


Please help!!
Thanks in advance

iceeedr 06-13-2022 16:35

Re: hook_cvar_change and RH_Cvar_DirectSet not working
 
I think the logs are as clear as possible.

Code:

client_disconnected and client_remove forwards have been disabled - check your gamedata files.
Code:

RegisterHookChain: function (Cvar_DirectSet) is not available, ReHLDS required.

LiZou Mapper 06-13-2022 17:57

Re: hook_cvar_change and RH_Cvar_DirectSet not working
 
Quote:

Originally Posted by iceeedr (Post 2781632)
I think the logs are as clear as possible.

Code:

client_disconnected and client_remove forwards have been disabled - check your gamedata files.
Code:

RegisterHookChain: function (Cvar_DirectSet) is not available, ReHLDS required.

ReHLDS is exists.
The latest version of ReHLDS no longer supports Windows!

I have reviewed the gamedata, it exists
HTML Code:

"SV_DropClient" // void SV_DropClient(client_t *cl, qboolean crash, const char *fmt, ...);
{
        "library"  "engine"
        "windows"  "\x55\x8B\x2A\x81\x2A\x2A\x2A\x2A\x2A\x8B\x2A\x2A\x53\x56\x8D"
        "linux"    "@SV_DropClient"
        "mac"      "@SV_DropClient"
}
"Cvar_DirectSet" // void Cvar_DirectSet(struct cvar_s *var, char *value);
{
        "library"  "engine"
        "windows"  "\x55\x8B\x2A\x81\x2A\x2A\x2A\x2A\x2A\x56\x8B\x2A\x2A\x57\x8B\x2A\x2A\x85"
        "linux"    "@Cvar_DirectSet"
        "mac"      "@Cvar_DirectSet"
}


iceeedr 06-13-2022 18:03

Re: hook_cvar_change and RH_Cvar_DirectSet not working
 
You can grab the latest version of rehlds for windows from github under the Actions tab (not recommended, but definitely possible) and I would redo the entire installation process to eliminate any corrupted files.

LiZou Mapper 06-13-2022 18:55

Re: hook_cvar_change and RH_Cvar_DirectSet not working
 
* Solved! *
Solution: These hooks do not work in listenserver or in old HLDS version <= 6xxx


All times are GMT -4. The time now is 10:32.

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