PHP Code:
] amx_cvar mp_timelimit 15
L 06/30/2016 - 01:55:13: [admincmd.amxx] Cmd: "Sven Co-op 5.0 server<0><><>" set cvar (name "mp_timelimit") (value "15")
Debug: 1684552672 15
[AMXX] Cvar "mp_timelimit" changed to "15
PHP Code:
#include <amxmodx>
#include <okapi>
new p
public plugin_init()
{
new FunctionAddress
new okapi_func:HandleCvar_DirectSetFunc
//Cvar_DirectSetSignature is for identifying the function under windows
//Cvar_DirectSetSymbol is for linux
new const Cvar_DirectSetSignature[] = {0x55,0x8B,0xDFF,0x81,0xDFF,0xDFF,0xDFF,0xDFF,0xDFF,0x53,0x8B,0xDFF,0xDFF,0x56,0x8B,0xDFF,0xDFF,0x85,0xDFF,0x57}
new const Cvar_DirectSetSymbol [] = "Cvar_DirectSet_0"
//okapi_engine_find_sig searches for the signature in the windows binary
//okapi_engine_get_symbol_ptr searches for the signature in linux binary
//this two functions retrieve the address of the function if it is found, 0 otherwise
if
(
(FunctionAddress = okapi_engine_get_symbol_ptr(Cvar_DirectSetSymbol)) ||
(FunctionAddress = okapi_engine_find_sig(Cvar_DirectSetSignature, sizeof Cvar_DirectSetSignature))
)
{
//okapi_build_function attaches okapi to our function
//FunctionAddress is the address we just retrieved
//arg_void is the return type of the Cvar_DirectSet function(it does not return anything, so we use void)
//arg_int is the first param of Cvar_DirectSet(the cvar pointer)
//arg_string is the second param of Cvar_DirectSet(the cvar value, always passed as a string)
HandleCvar_DirectSetFunc = okapi_build_function(FunctionAddress, arg_void, arg_int, arg_string)
//okapi_add_hook hooks the above function
//false means we hook it as pre, so you can block the change
okapi_add_hook(HandleCvar_DirectSetFunc, "OnCvar_DirectSet", false)
p = get_cvar_pointer("mp_timelimit")
}
}
public OnCvar_DirectSet(const CvarHandle, const CvarValue[])
{
if(p == CvarHandle)
{
server_print("Debug: %i %s", CvarHandle, CvarValue)
}
}
Downloaded today a svends server and installed above. It works.
Can you please test with the same plugin?
Did you checked if plugin is running? Are you sure okapi is running? Use amxx modules and see.
__________________