View Single Post
root88
Senior Member
Join Date: May 2016
Old 03-05-2021 , 09:25   Re: SourceMod extension: how to get server's IP?
Reply With Quote #5

Thank you, I hadn't noticed this category at first. I've figured out how to do it, in case someone need this:
PHP Code:
    char serverip[32];
    
int ip g_pCvar->FindVar("hostip")->GetInt();
    
int port g_pCvar->FindVar("hostport")->GetInt();
    
    
int iips[4];
    
iips[0] = (ip >> 24) & 0x000000FF;
    
iips[1] = (ip >> 16) & 0x000000FF;
    
iips[2] = (ip >> 8) & 0x000000FF;
    
iips[3] = ip 0x000000FF;

    
snprintf(serveripsizeof(serverip), "%d.%d.%d.%d:%d"iips[0], iips[1], iips[2], iips[3], port); 
__________________

Last edited by root88; 03-05-2021 at 09:26.
root88 is offline