27.04.2013, 16:18
I want the player to be able to type /work and it will choose the most near mission of him. How can i do this?
enum eMission {
Float: mX,
Float: mY,
Float: mZ
}
new Mission[][eMission] {
{0.0, 1.0, 2.0},
{1.0, 2.0, 3.0}
};
// Your /work command
new
i,
mission,
Float: distance,
Float: lowest = Float: 0x7F800000
;
while(++i < sizeof Mission) {
if((distance = GetPlayerDistanceFromPoint(playerid, Mission[i][X], Mission[i][mY], Missions[i][mZ])) < lowest) {
lowest = distance;
mission = i;
}
}
printf("Nearest mission is %d with the distance %f", mission, lowest);