[Plugin] [REL] PointToPoint Plugin
#1

PointToPoint Plugin
Created By Blacklite & Me
Functions
  • native Float:PointToPoint2D(Float: x1, Float: y1, Float: x2, Float: y2);
  • native Float:PointToPoint3D(Float: x1, Float: y1, Float: z1, Float: x2, Float: y2, Float: z2);
This plugin is a simple bit of code designed to speed up the commonly used (and somewhat inefficient) pawn function, GetPlayerToPoint.

All it does, is calculates the distance from one point to another, and returns it as a float.

This can be used to create many different functions. Here are some examples. Note I have used PointToPoint3D, which accepts 6 parameters, and compares the height (z) between the two points. The 2D version of the function (PointToPoint2D), takes 4 parameters and only compares X and Y.

GetPlayerToPoint(playerid, Float: x, Float: y, Float: z)

pawn Code:
function Float:GetPlayerToPoint(playerid, Float:x, Float:y, Float:z)
{
    new Float:px, Float:py, Float:pz;
    GetPlayerPos(playerid, px, py, pz);
    return PointToPoint3D(px, py, pz, x, y, z);
}
GetPointToPoint(Float: x, Float: y, Float: z, Float: x2, Float: y2, Float: z2)

pawn Code:
function Float:GetPointToPoint(Float:x, Float:y, Float:z, Float:x2, Float:y2, Float:z2)
{
    return PointToPoint3D(x, y, z, x2, y2, z2);
}
GetPlayerDistanceToPlayer(playerid, targetid)

pawn Code:
stock Float:GetPlayerDistanceToPlayer(playerid, targetid)
{
    new Float:x, Float:y, Float:z, Float:x2, Float:y2, Float:z2;
    GetPlayerPos(playerid, x, y, z);
    GetPlayerPos(targetid, x2, y2, z2);
    return PointToPoint3D(x, y, z, x2, y2, z2);
}
A 2D example of GetPlayerDistanceToPlayer:

pawn Code:
stock Float:GetPlayerDistanceToPlayer(playerid, targetid)
{
    new Float:x, Float:y, Float:z, Float:x2, Float:y2, Float:z2;
    GetPlayerPos(playerid, x, y, z);
    GetPlayerPos(targetid, x2, y2, z2);
    return PointToPoint2D(x, y, x2, y2);
}
Pictures:

Here are a couple pictures comparing the speeds of the plugin function and a regular pawn function.
Download:
Post Questions And Comments!
Reply


Messages In This Thread
[REL] PointToPoint Plugin - by StrickenKid - 24.01.2010, 23:35
Re: [REL] PointToPoint Plugin - by pliva_sb - 24.01.2010, 23:49
Re: [REL] PointToPoint Plugin - by StrickenKid - 24.01.2010, 23:53
Re: [REL] PointToPoint Plugin - by GTA967 - 25.01.2010, 00:25
Re: [REL] PointToPoint Plugin - by joemomma53 - 25.01.2010, 00:38
Re: [REL] PointToPoint Plugin - by Jay_ - 25.01.2010, 10:28
Re: [REL] PointToPoint Plugin - by [03]Garsino - 02.03.2010, 18:59
Re: [REL] PointToPoint Plugin - by BeckzyBoi - 15.03.2010, 05:29
Re: [REL] PointToPoint Plugin - by Deat_Itself - 15.03.2010, 14:39
Re: [REL] PointToPoint Plugin - by BeckzyBoi - 21.03.2010, 22:43
Re: [REL] PointToPoint Plugin - by Jay_ - 21.03.2010, 23:25
Re: [REL] PointToPoint Plugin - by Brian_Furios - 22.03.2010, 19:29
Re: [REL] PointToPoint Plugin - by DiDok - 29.03.2010, 22:34
Re: [REL] PointToPoint Plugin - by Chaprnks - 30.03.2010, 02:31
Re: [REL] PointToPoint Plugin - by ping - 21.04.2010, 11:56
Re: [REL] PointToPoint Plugin - by Stas92 - 21.04.2010, 12:23
Re: [REL] PointToPoint Plugin - by Fro1sha - 08.05.2010, 10:38
Re: [REL] PointToPoint Plugin - by Trooper[Y] - 16.06.2010, 14:53
Re: [REL] PointToPoint Plugin - by bpeterson - 16.06.2010, 17:32
Re: [REL] PointToPoint Plugin - by Trooper[Y] - 16.06.2010, 21:14
Re: [REL] PointToPoint Plugin - by bpeterson - 17.06.2010, 09:38
Re: [REL] PointToPoint Plugin - by jonrb - 15.07.2010, 09:53
Re: [REL] PointToPoint Plugin - by ft941 - 03.08.2010, 16:50
AW: [REL] PointToPoint Plugin - by Bubelbub - 19.01.2011, 14:48
Re: [REL] PointToPoint Plugin - by kurta999 - 19.01.2011, 15:25
Re: [REL] PointToPoint Plugin - by HyperZ - 19.01.2011, 16:07
Re: [REL] PointToPoint Plugin - by WillyP - 19.01.2011, 16:31
Re: [REL] PointToPoint Plugin - by snoob - 19.01.2011, 17:35
Re: [REL] PointToPoint Plugin - by Elviss - 19.01.2011, 17:57
Re: [REL] PointToPoint Plugin - by Burridge - 19.01.2011, 18:46
Re: [REL] PointToPoint Plugin - by cyber_punk - 19.01.2011, 22:40
Re: [REL] PointToPoint Plugin - by Mike Garber - 20.01.2011, 08:14
Re: [REL] PointToPoint Plugin - by Elviss - 20.01.2011, 10:47
Re: [REL] PointToPoint Plugin - by Slice - 20.01.2011, 11:02
Re: [REL] PointToPoint Plugin - by Double-O-Seven - 20.01.2011, 16:23
Re: [REL] PointToPoint Plugin - by Hiddos - 20.01.2011, 17:10
Re: [REL] PointToPoint Plugin - by [Ask]Terminator - 20.01.2011, 18:13
Re: [REL] PointToPoint Plugin - by Slice - 21.01.2011, 08:49
Re: [REL] PointToPoint Plugin - by Minokon - 21.01.2011, 19:48
Re: [REL] PointToPoint Plugin - by kurta999 - 21.01.2011, 20:12
AW: [REL] PointToPoint Plugin - by Akmet - 22.01.2011, 10:44
Re: [REL] PointToPoint Plugin - by lpiob - 04.02.2011, 13:58
Re: [REL] PointToPoint Plugin - by Hal - 18.03.2011, 19:26
Re: [REL] PointToPoint Plugin - by cyber_punk - 15.04.2011, 06:24
Re: [REL] PointToPoint Plugin - by VIRUXE - 02.08.2011, 00:25
Re: [REL] PointToPoint Plugin - by Blacklite - 02.08.2011, 00:32
Re: [REL] PointToPoint Plugin - by Famalamalam - 02.08.2011, 01:19
Re: [REL] PointToPoint Plugin - by Gamer_Z - 02.08.2011, 08:40
Re: [REL] PointToPoint Plugin - by Famalamalam - 02.08.2011, 13:15
Re: [REL] PointToPoint Plugin - by Blacklite - 16.08.2011, 06:51
Re: [REL] PointToPoint Plugin - by BeckzyBoi - 16.08.2011, 07:11
Re: [REL] PointToPoint Plugin - by GangsTa_ - 16.08.2011, 08:45
Re: [REL] PointToPoint Plugin - by Blacklite - 16.08.2011, 10:19
[No subject] - by ][Noname][ - 13.04.2012, 00:54
Re: [REL] PointToPoint Plugin - by -Prodigy- - 13.04.2012, 01:43
Re: [REL] PointToPoint Plugin - by JM_Millers - 17.04.2012, 16:49
Re: [REL] PointToPoint Plugin - by BeckzyBoi - 17.04.2012, 17:10
Re: [REL] PointToPoint Plugin - by Jay_ - 17.04.2012, 17:50
[No subject] - by ][Noname][ - 18.04.2012, 09:03
Re: [REL] PointToPoint Plugin - by Blacklite - 19.04.2012, 10:17
Re: [REL] PointToPoint Plugin - by pawlak - 01.11.2012, 16:39
Re: [REL] PointToPoint Plugin - by NoahF - 01.11.2012, 21:14

Forum Jump:


Users browsing this thread: 2 Guest(s)