GetPlayerIp

From SA-MP Wiki

Jump to: navigation, search


Description:

Get the specified player's IP address and store it in a string.


Parameters:
(playerid, ip[], len)
playeridThe ID of the player to get the IP address of.
ip[]The string to store the player's IP address in, passed by reference.
lenThe maximum length of the IP address (recommended 16).


Return Values:

1 on success and 0 on failure.


Image:32px-Ambox_warning_orange.png

Notes

  • PAWN is case-sensitive. GetPlayerIP will not work.
  • This function does not work when used in OnPlayerDisconnect because the player is already disconnected. It will return an invalid IP (255.255.255.255). Save players' IPs under OnPlayerConnect if they need to be used under OnPlayerDisconnect.


public OnPlayerConnect(playerid)
{
    new plrIP[16];
    GetPlayerIp(playerid, plrIP, sizeof(plrIP));
    if(!strcmp(plrIP, "127.0.0.1"))
    SendClientMessage(playerid, 0xFFFFFFFF, "Welcome to your server, master :)");
    return 1;
}

Related Functions

The following functions may be useful, as they are related to this function in one way or another.


Related Callbacks

The following callbacks might be useful as well, as they are related to this callback in one way or another.

Personal tools
In other languages