AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   what is wrong? (https://forums.alliedmods.net/showthread.php?t=303753)

Saint Sinner 12-20-2017 05:44

what is wrong?
 
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"


klippy 12-20-2017 05:53

Re: what is wrong?
 
You have to properly retrieve the value of a cvar.
Read https://wiki.alliedmods.net/Scripting_Cvars_(AMX_Mod_X)

Saint Sinner 12-20-2017 07:33

Re: what is wrong?
 
that not work

if(!equal(szIP, get_pcvar_num(cvar_ip))

zmd94 12-20-2017 08:14

Re: what is wrong?
 
Try get_pcvar_string.

OciXCrom 12-20-2017 08:54

Re: what is wrong?
 
The cvar value is a string, the IP is a string, so get the string from the cvar and compare strings.

Saint Sinner 12-20-2017 16:48

Re: what is wrong?
 
this is hard to make it...

CrazY. 12-20-2017 18:13

Re: what is wrong?
 
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.

Depresie 12-20-2017 21:48

Re: what is wrong?
 
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 
    } 



Saint Sinner 12-21-2017 02:19

Re: what is wrong?
 
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

zmd94 12-21-2017 05:34

Re: what is wrong?
 
It is not work because you do not register test( ) function.


All times are GMT -4. The time now is 09:24.

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