Skip to main content

GetPlayerDistanceFromPoint

คำอธิบาย

Calculate the distance between a player and a map coordinate.

NameDescription
playeridThe ID of the player to calculate the distance from.
Float:XThe X map coordinate.
Float:YThe Y map coordinate.
Float:ZThe Z map coordinate.

ส่งคืน

The distance between the player and the point as a float.

ตัวอย่าง

/* when the player types '/vend' into the chat box, they'll see this.*/
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp(cmdtext, "/vend", true) == 0)
{
new
Float: fDistance = GetPlayerDistanceFromPoint(playerid, 237.9, 115.6, 1010.2),
szMessage[44];

format(szMessage, sizeof(szMessage), "You're %0.2f meters away from the vending machine.", fDistance);
SendClientMessage(playerid, 0xA9C4E4FF, szMessage);

return 1;
}

return 0;
}

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