Skip to main content

GetPlayerIp

คำอธิบาย

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

NameDescription
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).

ส่งคืน

The player's IP address is stored in the specified array.

ตัวอย่าง

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;
}

บันทึก

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.

ฟังก์ชั่นที่เกี่ยวข้องกัน