SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 15/06/2010, 07:30 PM   #1
WThieves
Huge Clucker
 
Join Date: Nov 2009
Posts: 200
Reputation: 0
Default [HELP]Get nearest to farthest

I got myself this script, out of another script but see this:
pawn Code:
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!!
__________________


Click and register --> http://wthieves.mybrute.com
WThieves is offline  
Old 15/06/2010, 07:37 PM   #2
Jefff
Banned
 
Join Date: Dec 2007
Posts: 2,594
Reputation: 326
Default Re: [HELP]Get nearest to farthest

pawn Code:
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;
}
Jefff is offline  
Old 15/06/2010, 08:13 PM   #3
WThieves
Huge Clucker
 
Join Date: Nov 2009
Posts: 200
Reputation: 0
Default Re: [HELP]Get nearest to farthest

Quote:
Originally Posted by Jefff
pawn Code:
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!
__________________


Click and register --> http://wthieves.mybrute.com
WThieves is offline  
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to destroy nearest vehicle? [SsC11]MAVERIK Help Archive 1 18/04/2010 12:08 PM
Show the nearest checkpoint Takumi.WS Help Archive 0 04/04/2010 12:52 AM
SetPlayerAngle to nearest player.. wiilweer Help Archive 1 09/01/2010 12:19 PM
How can I get the vehicle which is the nearest to a player =? KIDUL Help Archive 1 04/11/2009 03:29 PM


All times are GMT. The time now is 06:18 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.