Distance question
#1

Okay so my coordinates are:
Code:
2305.2930,-1385.6023,24.1008
2404.2930,-1382.6025,246.1008
Does anyone know how I could make it so it finds whichever coordinate is the nearest?
Reply
#2

Use https://sampwiki.blast.hk/wiki/IsPlayerInRangeOfPoint
Lemme make you a stock for easier using of it
PHP Code:
stock NearestCoord(playerid)
{
    new 
coord;
    if(
IsPlayerInRangeOfPoint(playerid,3.0,2305.2930,-1385.6023,24.1008))
    {
        
coord 1;
    }
    else if(
IsPlayerInRangeOfPoint(playerid,3.0,2404.2930,-1382.6025,246.1008))
    {
        
coord 2;
    }
    return 
coord;

Example usage:-
PHP Code:
if(NearestCoord(playerid) == 1// 1 = He's near the 1st coord
{
   
//code
}
else if(
NearestCoord(playerid) == 2// 2 = He's near the 2nd coord
{
   
//code

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)