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

Check server address


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Touch
Member
Join Date: Apr 2010
Location: Ukraine
Old 04-07-2010 , 12:47   Check server address
Reply With Quote #1

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
Touch is offline
Send a message via Skype™ to Touch
Scone
Senior Member
Join Date: Apr 2010
Location: England
Old 04-07-2010 , 13:59   Re: Check server address
Reply With Quote #2

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!
Scone is offline
Touch
Member
Join Date: Apr 2010
Location: Ukraine
Old 04-07-2010 , 14:04   Re: Check server address
Reply With Quote #3

Thank you! It helped!
Touch is offline
Send a message via Skype™ to Touch
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 16:44.


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