SA-MP Forums Archive
[Plugin] [REL] PointToPoint Plugin - 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: Plugin Development (https://sampforum.blast.hk/forumdisplay.php?fid=18)
+--- Thread: [Plugin] [REL] PointToPoint Plugin (/showthread.php?tid=123251)

Pages: 1 2 3 4


[REL] PointToPoint Plugin - StrickenKid - 24.01.2010

PointToPoint Plugin
Created By Blacklite & Me
Functions
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!


Re: [REL] PointToPoint Plugin - pliva_sb - 24.01.2010

I create same plugin but more function.Nice work ethan.


Re: [REL] PointToPoint Plugin - StrickenKid - 24.01.2010

Quote:
Originally Posted by [CH
pliva♪ ]
I create same plugin but more function.Nice work ethan.
You mean "Nice work ethan and Blacklite"


Re: [REL] PointToPoint Plugin - GTA967 - 25.01.2010

[me=GTA967]StrickenKid moo[/me]


Re: [REL] PointToPoint Plugin - joemomma53 - 25.01.2010

Nice Work, i'll have to try this out.


Re: [REL] PointToPoint Plugin - Jay_ - 25.01.2010

Holy crap! The test results of that pawn version are really slow. Thanks, I'll most definitely be using this


Re: [REL] PointToPoint Plugin - [03]Garsino - 02.03.2010

Nice work StrickenKid & Blacklite. Much faster than the pawn function GetPlayerToPoint as you said
Using it


Re: [REL] PointToPoint Plugin - beckzy - 15.03.2010

How reliable is this plugin? I can't seem to find a PAWN version of this.


Re: [REL] PointToPoint Plugin - Deat_Itself - 15.03.2010

Awesome i really liked it


Re: [REL] PointToPoint Plugin - beckzy - 21.03.2010

Linux doesn't work


Re: [REL] PointToPoint Plugin - Jay_ - 21.03.2010

Works fine here.


Re: [REL] PointToPoint Plugin - Brian_Furios - 22.03.2010

this is awesome


Re: [REL] PointToPoint Plugin - DiDok - 29.03.2010

Does 77ms on 100000 iterations is really a difference? -________-'


Re: [REL] PointToPoint Plugin - Chaprnks - 30.03.2010

Quote:
Originally Posted by DiDok
Does 77ms on 100000 iterations is really a difference? -________-'
For servers that use this function alot, yes.


Re: [REL] PointToPoint Plugin - ping - 21.04.2010

Quote:
Originally Posted by DiDok
Does 77ms on 100000 iterations is really a difference? -________-'
if you make your own object streamer, yes


Re: [REL] PointToPoint Plugin - Stas92 - 21.04.2010

You're right, ping.
This could be usefull, if you've a server with many players, too.


Re: [REL] PointToPoint Plugin - Fro1sha - 08.05.2010

Don't work on Linux!


Re: [REL] PointToPoint Plugin - Trooper[Y] - 16.06.2010

Rly ?
Thats bad, indeed...


Got some buggy issue:
Код:
printf("comview : x:%f y:%f baut: x:%f y:%f dist:%f",comview[player[playerid][team]-1][0],comview[player[playerid][team]-1][1],gebaude[srch2][player[playerid][team]-1][placex],gebaude[srch2][player[playerid][team]-1][placey],PointToPoint2D(comview[player[playerid][team]-1][0], comview[player[playerid][team]-1][1], gebaude[srch2][player[playerid][team]-1][placex], gebaude[srch2][player[playerid][team]-1][placex]));
Quote:

[16:49:09] comview : x:267.092193 y:2515.401123 baut: x:217.092193 y:2515.401123 dist:2298.852539

Thats mysterious...
Can you help me with it ?
The Coordinates are close together, but the distance is so big...


Re: [REL] PointToPoint Plugin - bpeterson - 16.06.2010

Fixed version for linux:

http://upload.bp-dev.net/uploads/PointToPoint.so


Re: [REL] PointToPoint Plugin - Trooper[Y] - 16.06.2010

Tested ?