IsPlayerInRangeOfPoint

From SA-MP Wiki

Jump to: navigation, search

IsPlayerInRangeOfPoint


Warning: This is a new function working since SA-MP 0.3. It won't work in previous versions.

There are scripted (but slower) alternatives for previous SA-MP versions.


Important note: This could be a native replacement for the PlayerToPoint function, you just need to change the parameters (PlayerToPoint requires float, then playerid, IsPlayerInRangeOfPoint requires playerid and then the Float.


Checks if the player's position is inside a sphere.


Parameters:
(playerid, Float:range, Float:x, Float:y, Float:z)
playeridThe player you want to check for distance.
Float:rangeThe radius of the sphere.
Float:xThe X position of the middle point of the sphere.
Float:yThe Y position of the middle point of the sphere.
Float:zThe Z position of the middle point of the sphere.


Returnstrue if player is inside the sphere, false if not.


if(!strcmp("/stadium",cmdtext))
{
    if(IsPlayerInRangeOfPoint(playerid, 7.0, 2695.6880, -1704.6300, 11.8438))
    SendClientMessage(playerid,0xFFFFFFFF,"You are near the Stadium entrance!");
    return 1;
}

Related Functions

The following functions might be useful as well, as they're related to this function in one way or another.

  • Automatic_Gates: PlayerToPoint function. A slower alternative to this built-in function.