How I can get server's IP
#1

Hi, I want to know how I can get server's IP, something like:
Код:
new string[ 128 ];
format( string, 128, "Server's IP is: %s", GetServerVarAsString("ip", string, 128) );
SendClientMessage( playerid, -1, string );
So ... how I can get server's IP ?
Reply
#2

pawn Код:
new mess[256],IP[256];
    GetPlayerIp(playerid,IP,sizeof(IP));

format(mess,sizeof(mess),"IP: %s ",IP);
SendClientMessageToAll(COLOR_LIGHTBLUE,mess);
Reply
#3

Quote:
Originally Posted by SmileyForCheat
Посмотреть сообщение
pawn Код:
format(mess,sizeof(mess),"IP: %s ",IP);
    SendClientMessageToAll(COLOR_LIGHTBLUE,mess);
Lol, I think this don't work, IP is not defined ... and I don't want player's IP, I want server's IP.
Reply
#4

Player Can See it In SAMP The IP
Or maybe you mean Obtain an IP
START>RUN>In Run Type>"CMD"(Without("))>In CMD Type "IPCONFIG(Without("))>Show The IP Adress You Understand??
Reply
#5

256 sized strings, I'm not sure if smiley is joking or serious.

you can put in the server.cfg
"nosign ipaddress"
and then use GetServerVarAsString("nosign",string,sizeof(string ));
afaik nosign doesn't do anything but you can retrieve it from the cfg
Reply
#6

No, I want to get server's IP, to make a secure script, if server's IP is not my IP, or IP of the host, the server will exit ( SendRconCommand("exit"); )

I know, I'm not the best at english xD
Reply
#7

Quote:
Originally Posted by cessil
Посмотреть сообщение
256 sized strings, I'm not sure if smiley is joking or serious.

you can put in the server.cfg
"nosign ipaddress"
and then use GetServerVarAsString("nosign",string,sizeof(string ));
afaik nosign doesn't do anything but you can retrieve it from the cfg
That is just one worthless solution, you could #define the IP in that case in the script as well instead of doing that.
Reply
#8

Quote:
Originally Posted by Jochemd
Посмотреть сообщение
That is just one worthless solution, you could #define the IP in that case in the script as well instead of doing that.
I want to do something like this:
Код:
public OnGameModeInit( )
{
    SERVER_IP = GetServerIP( );
    if( SERVER_IP != MY_IP && SERVER_IP != HOST_IP )
        SendRconCommand( "exit" );
}
A define don't detect current server IP.
Reply
#9

This is probably a really bad idea, but you could make a NPC join, grab its IP, then kick it.
Reply
#10

Quote:
Originally Posted by SmileyForCheat
Посмотреть сообщение
pawn Код:
new mess[256],IP[256];
    GetPlayerIp(playerid,IP,sizeof(IP));

format(mess,sizeof(mess),"IP: %s",IP);
SendClientMessageToAll(COLOR_LIGHTBLUE,mess);
Here, you are using 2KB of memory...

IP has 16 cells, not 256, "mess" has 21, in total that is 340 bytes if I calculated correctly.
So, here you are wasting 1708 (2048 - 340) extra bytes of memory in that code... This code needs 340 bytes, yours is 2048 bytes.
The calculation might not be correct, but you are wasting hell lot of memory! I suggest you to read this.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)