Raised This Month: $32 Target: $400
 8% 

help about cvar


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Saint Sinner
Senior Member
Join Date: Feb 2016
Old 05-13-2019 , 19:55   help about cvar
Reply With Quote #1

What is wrong here ?

Code:
#include <amxmodx>
#include <hamsandwich>

new BlockIP

public plugin_init()
{
    BlockIP = register_cvar("amx_test", "80.49.86.0" );

    RegisterHam(Ham_Spawn, "player", "PlayerSpawn", 1);
}

public PlayerSpawn(id)
{
    new szIP[32]
    
    get_user_ip(id, szIP, charsmax(szIP), 1)

    if(equal(szIP, BlockIP)) 
    {

    }
}
Saint Sinner is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-13-2019 , 20:16   Re: help about cvar
Reply With Quote #2

BlockIP is a pointer to a cvar, not the cvar value. If you use 1.9 you can make life easier using bind_pcvar_string().

You would need this:
PHP Code:
public PlayerSpawn(id)
{
    new 
szIP[32]
    
    
get_user_ip(idszIPcharsmax(szIP), 1)

    new 
szIPCvar32 ];
    
get_pcvar_stringBlockIP szIPCvar charsmaxszIPCvar ) );
    
    if(
equal(szIPszIPCvar)) 
    {

    }

__________________
Bugsy is offline
Saint Sinner
Senior Member
Join Date: Feb 2016
Old 05-14-2019 , 05:08   Re: help about cvar
Reply With Quote #3

Thanks
Saint Sinner 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 06:21.


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