Closest mission - 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: Closest mission (
/showthread.php?tid=433516)
Closest mission -
NicholasA - 27.04.2013
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?
Re: Closest mission -
Jimmy0wns - 27.04.2013
Help us please c:
AW: Closest mission -
Nero_3D - 27.04.2013
Loop through all mission and check if which distance is the lowest (nearest) to the player
Re: AW: Closest mission -
Jimmy0wns - 27.04.2013
Quote:
Originally Posted by Nero_3D
Loop through all mission and check if which distance is the lowest (nearest) to the player
|
And how do we do that? We're not the best in scripting so yea...
ignore this, post got duplicated for some reason
Re: AW: Closest mission -
Jimmy0wns - 27.04.2013
Quote:
Originally Posted by Nero_3D
Loop through all mission and check if which distance is the lowest (nearest) to the player
|
And how do we do that? We're not the best in scripting so yea...
AW: Closest mission -
Nero_3D - 27.04.2013
Although this had been asked 10 million of times and you just could ****** an example but here another one
I pretend that something like that already exists
pawn Код:
enum eMission {
Float: mX,
Float: mY,
Float: mZ
}
new Mission[][eMission] {
{0.0, 1.0, 2.0},
{1.0, 2.0, 3.0}
};
pawn Код:
// 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);