[HELP]Get nearest to farthest - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [HELP]Get nearest to farthest (
/showthread.php?tid=154823)
[HELP]Get nearest to farthest -
WThieves - 15.06.2010
I got myself this script, out of another script but see this:
pawn Код:
getNearestPizzeria(Float:X1,Float:Y1,Float:Z1)
{
new index;
new Float:distOld=9999.0;
new Float:distNew=0.0;
for (new i=0;i<cantidadPizzerias;i++)
{
distNew=floatsqroot(floatpower(floatabs(floatsub(Pizzerias[i][X],X1)),2)+floatpower(floatabs(floatsub(Pizzerias[i][Y],Y1)),2)+floatpower(floatabs(floatsub(Pizzerias[i][Z],Z1)),2));
if (distNew<distOld)
{
distOld=distNew;
index=i;
}
}
return index;
}
Pizzeria = airport
But that doesn't matter.
What matters is there are 3 airports and if you enter a checkpoint at these you get money, now your first checkpoint is the nearest airport, so if you go stand on the runway in the checkpoint and keep starting/stopping the job, you get tons of money without doing anything, thats why i want you to ask me if you could give me a way te get the Farthest one and not the Nearest.
Could you help me please?
Thanks in advance!!
Re: [HELP]Get nearest to farthest -
Jefff - 15.06.2010
pawn Код:
getNearestPizzeria(Float:X1,Float:Y1,Float:Z1)
{
new index;
new Float:distOld;
new Float:distNew;
for(new i; i<cantidadPizzerias; i++)
{
distNew=floatsqroot(floatpower(floatabs(floatsub(Pizzerias[i][X],X1)),2)+floatpower(floatabs(floatsub(Pizzerias[i][Y],Y1)),2)+floatpower(floatabs(floatsub(Pizzerias[i][Z],Z1)),2));
if(distNew > distOld)
{
distOld=distNew;
index=i;
}
}
return index;
}
Re: [HELP]Get nearest to farthest -
WThieves - 15.06.2010
Quote:
Originally Posted by Jefff
pawn Код:
getNearestPizzeria(Float:X1,Float:Y1,Float:Z1) { new index; new Float:distOld; new Float:distNew; for(new i; i<cantidadPizzerias; i++) { distNew=floatsqroot(floatpower(floatabs(floatsub(Pizzerias[i][X],X1)),2)+floatpower(floatabs(floatsub(Pizzerias[i][Y],Y1)),2)+floatpower(floatabs(floatsub(Pizzerias[i][Z],Z1)),2)); if(distNew > distOld) { distOld=distNew; index=i; } } return index; }
|
Thanks man! Didn't see that :P, just looked over it
You're the best!