Help In CP Distance
#6

The closest location instead of random that it currently is?

pawn Code:
new closest_location, Float: tmp_cd, Float: closest_distance = GetPlayerDistanceFromPoint(playerid, ALocations[0][LocX], ALocations[0][LocY], ALocations[0][LocZ]);

for (new i = 1; i != sizeof ALocations; i++)
{
    if ((tmp_cd = GetPlayerDistanceFromPoint(playerid, ALocations[i][LocX], ALocations[i][LocY], ALocations[i][LocZ])) < closest_distance)
    {
        closest_distance = tmp_cd;
        closest_location = i;
    }
}

// to set the position to the closest location use:
ALocations[closest_location][LocX], ALocations[closest_location][LocY], ALocations[closest_location][LocZ]
Reply


Messages In This Thread
Help In CP Distance (rep ++ ) - by Shaheen - 16.09.2016, 13:56
Re: Help In CP Distance - by Shaheen - 16.09.2016, 16:48
Re: Help In CP Distance - by Shaheen - 16.09.2016, 20:02
Re: Help In CP Distance - by Shinja - 16.09.2016, 20:13
Re: Help In CP Distance - by Shaheen - 16.09.2016, 20:18
Re: Help In CP Distance - by Konstantinos - 16.09.2016, 21:01
Re: Help In CP Distance - by Shaheen - 17.09.2016, 10:00
Re: Help In CP Distance - by Konstantinos - 17.09.2016, 10:08
Re: Help In CP Distance - by Shaheen - 17.09.2016, 11:52
Re: Help In CP Distance - by Shinja - 17.09.2016, 12:01
Re: Help In CP Distance - by Shaheen - 17.09.2016, 12:03
Re: Help In CP Distance - by Shaheen - 17.09.2016, 16:26
Re: Help In CP Distance - by Shaheen - 18.09.2016, 16:47
Re: Help In CP Distance - by Shaheen - 19.09.2016, 14:48
Re: Help In CP Distance - by Shaheen - 19.09.2016, 16:24

Forum Jump:


Users browsing this thread: 4 Guest(s)