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

[Sven Co-op] Static.cfg restoration


Post New Thread Reply   
 
Thread Tools Display Modes
gabuch2
AlliedModders Donor
Join Date: Mar 2011
Location: Chile
Old 06-29-2016 , 14:26   Re: Static.cfg restoration
Reply With Quote #21

Luckily I added a define to enable/disable the Okapi method in the sma.

Code:
L 06/29/2016 - 18:19:07: [static_cfg_restoration.amxx] [STATIC] The static file was loaded and its cvars applied correctly.
L 06/29/2016 - 18:19:07: [static_cfg_restoration.amxx] [STATIC] amx_static_enforce is 1. Now watchdogging static cvars.
] amx_cvar mp_timelimit 10
[AMXX] Cvar "mp_timelimit" cambiada a "10"
] amx_cvar mp_timelimit 0
[AMXX] Cvar "mp_timelimit" cambiada a "0"
This log message never gets printed, so the hook is not working
PHP Code:
#if defined USING_OKAPI
public OnCvar_DirectSet(const CvarHandle, const CvarValue[])
{
    
log_amx("[STATIC] Something changed a cvar..."
Okapi is running

Code:
] amxx modules
Currently loaded modules:
      name                    version     author               status
 [ 1] Engine                  1.8.3-dev+  AMX Mod X Dev Team   running
 [ 2] MySQL                   1.8.3-dev+  AMX Mod X Dev Team   running
 [ 3] FakeMeta                1.8.3-dev+  AMX Mod X Dev Team   running
 [ 4] Fun                     1.8.3-dev+  AMX Mod X Dev Team   running
 [ 5] Ham Sandwich            1.8.3-dev+  AMX Mod X Dev Team   running
 [ 6] okapi                   1.0         joaquimandrade       running
 [ 7] GeoIP                   1.8.3-dev+  AMX Mod X Dev Team   running
 [ 8] RegEx                   1.8.3-dev+  AMX Mod X Dev Team   running
 [ 9] Sockets                 1.8.3-dev+  HLSW Dev Team        running
9 modules, 9 correct
__________________
gabuch2 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 06-30-2016 , 04:56   Re: Static.cfg restoration
Reply With Quote #22

PHP Code:
amx_cvar mp_timelimit 15
L 06
/30/2016 01:55:13: [admincmd.amxxCmd"Sven Co-op 5.0 server<0><><>" set cvar (name "mp_timelimit") (value "15")
Debug1684552672 15
[AMXXCvar "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_DirectSetSignaturesizeof 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(FunctionAddressarg_voidarg_intarg_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)
        
get_cvar_pointer("mp_timelimit")
    }
    
}

public 
OnCvar_DirectSet(const CvarHandle, const CvarValue[])
{
    if(
== CvarHandle)
    {
        
server_print("Debug: %i %s"CvarHandleCvarValue)
    }

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.
__________________
HamletEagle is offline
Old 07-04-2016, 12:53
Julcoool
This message has been deleted by Julcoool. Reason: Did not check publish date. He beat me to it.
gabuch2
AlliedModders Donor
Join Date: Mar 2011
Location: Chile
Old 07-13-2016 , 15:59   Re: [Sven Co-op] Static.cfg restoration
Reply With Quote #23

Updated!
__________________
gabuch2 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 15:26.


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