SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts

Reply
 
Thread Tools Display Modes
Old 16/11/2017, 06:44 PM   #4671
Eoussama
High-roller
 
Eoussama's Avatar
 
Join Date: Jul 2016
Location: Kingdom of Morocco // Tangier
Posts: 1,117
Reputation: 153
Default Re: Useful Functions

GetClosestLocation


A simple function that takes multiple coordinates packed into an array and returns the closest position index to the player.

- Function

PHP Code:
GetClosestLocation(playeridFloat:_cords[][3], size sizeof(_cords))
{
    new 
closestFloat:lastDist GetPlayerDistanceFromPoint(playerid_cords[closest][0], _cords[closest][1], _cords[closest][2]), Float:dist;

    for(new 
ii<sizei++)
    {
        
dist GetPlayerDistanceFromPoint(playerid_cords[i][0], _cords[i][1], _cords[i][2]);

        if(
dist lastDist)
        {
            
closest i;
            
lastDist dist;
        }
    }

    return 
closest;

- Usage

PHP Code:
main()
{
      new 
Float:_cords[][3] = {
              {
1552.614379,-1675.769287,15.195312},
              {-
1605.645019,711.671936,12.867186},
              {
2288.943603,2429.486083,9.820312}
             },
            
_closest;

      
_closest GetClosestIndex(playerid_cords);

__________________
Eoussama is offline   Reply With Quote
Reply

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
Functions? sciman001 Help Archive 7 19/03/2011 04:03 PM
How to get functions? Twain32 Help Archive 4 08/10/2010 08:37 PM
[Include] [INC] SA:MP New Functions 0.4a DKN ipsBruno Lançamentos/Releases 22 17/06/2010 09:38 AM
[Include] [INC] LSF - Lorenc's Simple Functions (w/ gang/clan functions) Lorenc_ Includes 11 03/05/2010 10:47 PM
What this functions do? harrold Help Archive 2 09/05/2009 12:30 AM


All times are GMT. The time now is 02:22 AM.


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