View Single Post
SourceMod Moderator
Join Date: Apr 2012
Old 03-03-2021 , 12:05   Re: SourceMod extension: how to get server's IP?
Reply With Quote #2

PHP Code:
#include <SteamWorks>

// [... all your other code ...]
char sPublicIP[64];
int iPublicIP[4];
    if (
SteamWorks_GetPublicIP(iPublicIP)) {
Format(sPublicIPsizeof(sPublicIP), "%d.%d.%d.%d:%d"iPublicIP[0], iPublicIP[1], iPublicIP[2], iPublicIP[3], GetConVarInt(FindConVar("hostport")));
    } else {
LogError("Appears like we had an error on getting the Public IP address.");
// [... all your other code ...] 
Now, the string variable "sPublicIP" holds the data "", assuming that the Steam network sees the public IP as "", and the port is "27015".

PHP Code:
    Format(sPublicIPsizeof(sPublicIP), "%d.%d.%d.%d"iPublicIP[0], iPublicIP[1], iPublicIP[2], iPublicIP[3])); 
can eventually be used, if you don't like the port number to be a part of it.
Mostly known as "DarkDeviL".

Dropbox FastDL: Public folder will no longer work after March 15, 2017!
For more info, see the [SRCDS Thread], or the [HLDS Thread].
DarkDeviL is offline