warning Not Translated
This page has not been translated into the language that your browser requested yet. The English content is being shown as a fallback.
If you want to contribute a translation for this page then please click here.
GetPlayerIp
Description
Get the specified player's IP address and store it in a string.
Name | Description |
---|---|
playerid | The ID of the player to get the IP address of. |
ip[] | The string to store the player's IP address in, passed by reference. |
len = sizeof (ip) | The maximum length of the IP address (recommended 16). |
Returns
The player's IP address is stored in the specified array.
Examples
public OnPlayerConnect(playerid)
{
new ipAddress[16];
GetPlayerIp(playerid, ipAddress, sizeof(ipAddress));
if (!strcmp(ipAddress, "127.0.0.1"))
{
SendClientMessage(playerid, 0xFFFFFFFF, "Welcome to your server, masterĀ :)");
}
return 1;
}
Notes
tip
PAWN is case-sensitive. GetPlayerIP will not work.
warning
SA-MP server: 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.
open.mp server: This function work when used in OnPlayerDisconnect.
Related Functions
- NetStats_GetIpPort: Get a player's IP and port.
- GetPlayerRawIp: Get a player's Raw IP.
- GetPlayerName: Get a player's name.
- GetPlayerPing: Get the ping of a player.
- GetPlayerVersion: Get a player's client-version.
Related Callbacks
- OnIncomingConnection: Called when a player is attempting to connect to the server.
- OnPlayerConnect: Called when a player connects to the server.
- OnPlayerDisconnect: Called when a player leaves the server.