SA-MP Forums Get distance between 2 points.
 New Account Members List Search Today's Posts Mark Forums Read

 20/02/2011, 01:46 AM #1 -=SR=- Little Clucker   Join Date: Aug 2010 Posts: 5 Reputation: 0 Get distance between 2 points. I been trying to figure this out, and cannot think of a way to do this. I need to get a distance between 2 points. Anybody have any idea or some suggestions on how to do this? Thanks, SR
 20/02/2011, 01:51 AM #2 bigcomfycouch Huge Clucker   Join Date: Feb 2009 Location: Illinois Posts: 305 Reputation: -2 Re: Get distance between 2 points. pawn Code: `stock GetDistance( Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2 ){    return floatround( floatsqroot( ( ( x1 - x2 ) * ( x1 - x2 ) ) + ( ( y1 - y2 ) * ( y1 - y2 ) ) + ( ( z1 - z2 ) * ( z1 - z2 ) ) ) ) );}`
 20/02/2011, 02:10 AM #3 -=SR=- Little Clucker   Join Date: Aug 2010 Posts: 5 Reputation: 0 Re: Get distance between 2 points. thanks, gona give it a try, will post back here with results
 23/02/2011, 04:03 PM #4 -=SR=- Little Clucker   Join Date: Aug 2010 Posts: 5 Reputation: 0 Re: Get distance between 2 points. It works for what I needed, thanks a lot.
 07/03/2011, 06:53 PM #5 Stefan_Toretto Huge Clucker   Join Date: Apr 2010 Location: Romania Posts: 341 Reputation: 0 Re: Get distance between 2 points. This is in meters? or Kilometers? __________________ Code: `mysql_query("DELETE `stupidity` FROM `earth`") OR die("idiots");`
 04/09/2011, 09:26 PM #6 [DRD]Rodney Big Clucker   Join Date: Jan 2010 Posts: 126 Reputation: 0 Re: Get distance between 2 points. I failed. wrong post.
02/03/2016, 05:59 AM   #7
rt-2
Huge Clucker

Join Date: Jun 2011
Posts: 284
Reputation: 26
Re: Get distance between 2 points.

Quote:
 Originally Posted by bigcomfycouch pawn Code: `stock GetDistance( Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2 ){    return floatround( floatsqroot( ( ( x1 - x2 ) * ( x1 - x2 ) ) + ( ( y1 - y2 ) * ( y1 - y2 ) ) + ( ( z1 - z2 ) * ( z1 - z2 ) ) ) ) );}`
Quote:
 Originally Posted by -=SR=- It works for what I needed, thanks a lot.

The code is actually:
Code:
```
pawn Code:
stock GetDistance( Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2 ){    return floatround( floatsqroot( ( ( x1 - x2 ) * ( x1 - x2 ) ) + ( ( y1 - y2 ) * ( y1 - y2 ) ) + ( ( z1 - z2 ) * ( z1 - z2 ) ) )  );}
```
You had one too many ')'
__________________
rt-2
-------------------------------------------------

02/03/2016, 09:11 AM   #8
Sascha
High-roller

Join Date: Jul 2009
Location: Germany
Posts: 1,494
Reputation: 70
Re: Get distance between 2 points.

Quote:
 Originally Posted by blinkpnk The code is actually: Code: ``` pawn Code: stock GetDistance( Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2 ){    return floatround( floatsqroot( ( ( x1 - x2 ) * ( x1 - x2 ) ) + ( ( y1 - y2 ) * ( y1 - y2 ) ) + ( ( z1 - z2 ) * ( z1 - z2 ) ) )  );} ``` You had one too many ')'
Not really, with 3 ) at the end you just close the "floatsqroot" function
the 4th ) closes the "floatround"
__________________
Don't bother to contact me, I'm out of SA-MP

 05/03/2016, 02:44 AM #9 rt-2 Huge Clucker     Join Date: Jun 2011 Location: Montréal, Québec, Canada Posts: 284 Reputation: 26 Re: Get distance between 2 points. IDK but I had to remove one in my code because of error. But again, PAWNO is a very mysterious world. __________________ rt-2 -------------------------------------------------
 05/03/2016, 06:18 AM #10 AbyssMorgan Banned   Join Date: Apr 2015 Location: Poland Posts: 1,208 Reputation: 352 Re: Get distance between 2 points. distance in integer, wtf PHP Code: ``` stock Float:GetDistanceBetweenPoints3D(Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2){    return VectorSize(x1-x2,y1-y2,z1-z2);}  ```

 Thread Tools Display Modes Linear Mode

 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 Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post AleksandarAdzic Help Archive 4 25/04/2010 09:13 PM ziomal432 Help Archive 1 16/04/2010 08:45 PM Despare Help Archive 2 27/12/2009 01:35 PM Lajko1 Help Archive 3 12/12/2009 03:29 PM NtCat Help Archive 2 27/04/2009 05:32 PM

All times are GMT. The time now is 06:10 PM.

 -- (EN) English -- (RU) Русски SA-MP - Archive - Top