AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   confusing output from array (https://forums.alliedmods.net/showthread.php?t=171929)

Shadow Of Death 11-12-2011 14:49

confusing output from array
 
i try to put server informations in a array.
but the output confuse me.

PHP Code:

new server_address[2];

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR);
    
register_clcmd("say /test","test")
    
    
get_cvar_string("ip"server_address[0], 32);
    
get_cvar_string("port"server_address[1], 32);
}

public 
test()
{
    
server_cmd("say IP: %s"server_address[0]);
    
server_cmd("say Port: %s"server_address[1]);
    return 
PLUGIN_CONTINUE;


the output is
Code:

IP: l27015
 Port: 27015

the port is correct but not the ip what i do wrong? o.0

Bugsy 11-12-2011 14:55

Re: confusing output from array
 
new server_address[ 2 ][ 33 ]

Use that

Shadow Of Death 11-12-2011 14:59

Re: confusing output from array
 
Ok thx it work...
can you describe it too for me? ^^

Bugsy 11-12-2011 15:11

Re: confusing output from array
 
You were reading both things into the same string.

Server was read into the string starting at the first position.
"the server"

Then you read port into the same string starting at second position which was overwriting most of the server and showing you the first letter of the server then port for server and port is correct since you read and retrieved both from second position.
"t27015"
"27015"


All times are GMT -4. The time now is 08:26.

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