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

what is wrong?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Saint Sinner
Senior Member
Join Date: Feb 2016
Old 12-20-2017 , 05:44   what is wrong?
Reply With Quote #1

Code:
#include <amxmodx> 

new cvar_ip

public plugin_init()  
{ 
    cvar_ip = register_cvar( "test", "132.168.1.103:27015" );
}

public test( ) 
{ 
    new szIP[20]; 
    get_user_ip(0, szIP, charsmax(szIP), false); 
     
    if(!equal(szIP, cvar_ip)) 
    { 
        server_cmd("quit")
        return 
    } 
}
Code:
error 035: argument type mismatch (argument 2)
warning 204: symbol is assigned a value that is never used: "cvar_ip"

Last edited by Saint Sinner; 12-20-2017 at 05:47.
Saint Sinner is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 12-20-2017 , 05:53   Re: what is wrong?
Reply With Quote #2

You have to properly retrieve the value of a cvar.
Read https://wiki.alliedmods.net/Scripting_Cvars_(AMX_Mod_X)
__________________
klippy is offline
Saint Sinner
Senior Member
Join Date: Feb 2016
Old 12-20-2017 , 07:33   Re: what is wrong?
Reply With Quote #3

that not work

if(!equal(szIP, get_pcvar_num(cvar_ip))
Saint Sinner is offline
zmd94
Veteran Member
Join Date: Nov 2013
Location: Malaysia (9w2zow).
Old 12-20-2017 , 08:14   Re: what is wrong?
Reply With Quote #4

Try get_pcvar_string.
zmd94 is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 12-20-2017 , 08:54   Re: what is wrong?
Reply With Quote #5

The cvar value is a string, the IP is a string, so get the string from the cvar and compare strings.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Saint Sinner
Senior Member
Join Date: Feb 2016
Old 12-20-2017 , 16:48   Re: what is wrong?
Reply With Quote #6

this is hard to make it...
Saint Sinner is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 12-20-2017 , 18:13   Re: what is wrong?
Reply With Quote #7

Really? If this is hard for you, retire yourself from programming. You know what the problem is? You've at least tried and are waiting for someone to do it for you, but, that's where you fell off the horse, because no one here is going to help you with that, or rather, they've already helped you.
__________________








CrazY. is offline
Depresie
Veteran Member
Join Date: Nov 2013
Old 12-20-2017 , 21:48   Re: what is wrong?
Reply With Quote #8

What you miss is that to him this simple task looks like an UFO since he is not a programmer

PHP Code:
#include <amxmodx> 

new cvar_ip

public plugin_init()  

    
cvar_ip register_cvar"test""132.168.1.103:27015" );
}

public 
test( ) 

    new 
szIP[20]; 
    
get_user_ip(0szIPcharsmax(szIP), false); 
   
    new 
szCV[20]
    
get_pcvar_string(cvar_ipszCVcharsmax(szCV)) // cvar handler, string to store to, max chars of string
     
    
if(!equal(szIPszCV))
    { 
        
server_cmd("quit")
        return 
    } 

__________________

Last edited by Depresie; 12-20-2017 at 21:48.
Depresie is offline
Saint Sinner
Senior Member
Join Date: Feb 2016
Old 12-21-2017 , 02:19   Re: what is wrong?
Reply With Quote #9

Quote:
What you miss is that to him this simple task looks like an UFO since he is not a programmer
the code not work...just test him before post
Saint Sinner is offline
zmd94
Veteran Member
Join Date: Nov 2013
Location: Malaysia (9w2zow).
Old 12-21-2017 , 05:34   Re: what is wrong?
Reply With Quote #10

It is not work because you do not register test( ) function.
zmd94 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 07:21.


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