AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Check server address (https://forums.alliedmods.net/showthread.php?t=123642)

Touch 04-07-2010 12:47

Check server address
 
Hello!
Prompt please how to find IP-address, and server port via script?
Address and port written to the variable about this form:
PHP Code:

new String:srv[255];
srv ServerAddress// format 192.168.1.1:27015 

It is necessary to determine the IP and PORT of the server that is running the script.

Thanks :wink:

Scone 04-07-2010 13:59

Re: Check server address
 
As far as I'm aware, both the port and IP address are server CVARs:

PHP Code:

new Handle:port_cvar FindConVar("hostport");
new 
port GetConVarInt(port_cvar);

new 
Handle:ip_cvar FindConVar("hostip");
new 
String:ip[64];
GetConVarString(ip_cvaripsizeof(ip)); 

To get them in the format you want just use the Format() function:

PHP Code:

new String:srv[64];
Format(srvsizeof(srv), "%s:%d"ipport); 

I haven't tested the above, but I hope it helps!

Touch 04-07-2010 14:04

Re: Check server address
 
Thank you! It helped!


All times are GMT -4. The time now is 04:58.

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