AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Snippets and Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=112)
-   -   Get Server Ip (https://forums.alliedmods.net/showthread.php?t=193333)

K.K.Lv 08-18-2012 11:28

Get Server Ip
 
Hi all, I'm a new on SourceMod.
and this is a simple snippet to get server ip.
I have been try to type "ip" in server console
and the result is
Code:

"ip" = "localhost"
 - Overrides IP for multihomed hosts

so I try to type "hostip"
result:
Code:

"hostip" = "989727350" ( def. "" )
 - Host game server ip

so I make this code convert into a ip type
Code:
stock GetServerIp(String:ip[], maxlen) {     new Handle:hHostIp = FindConVar("hostip");     new iHostIp = GetConVarInt(hHostIp);     return Format(ip, maxlen, "%d.%d.%d.%d", ((iHostIp & 0xFF000000) >>0x18), ((iHostIp & 0x00FF0000)>>0x10), ((iHostIp & 0x0000FF00)>>0x8), (iHostIp & 0x000000FF)); }

Mitchell 08-18-2012 14:02

Re: Get Server Ip
 
SMLIB already has a similar function.

thetwistedpanda 08-18-2012 14:26

Re: Get Server Ip
 
Keep in mind, if you're behind a NAT or something similar, the IP that is reported by hostip will be incorrect. You'll need to use SteamTools to get the actual address.

minimoney1 08-31-2012 07:03

Re: Get Server Ip
 
Quote:

Originally Posted by annymac (Post 1787576)
This tool will find out the IP address of a website as well as website's country (hosting location).If you are using apache in front of a mongrel, then remote_ip will return the source address of the request..

Oh...


All times are GMT -4. The time now is 18:34.

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