Distance question - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Distance question (
/showthread.php?tid=627280)
Distance question -
boy - 26.01.2017
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?
Re: Distance question -
StrikerZ - 26.01.2017
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
}