[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
#2

I create same plugin but more function.Nice work ethan.
Reply
#3

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

[me=GTA967]StrickenKid moo[/me]
Reply
#5

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

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

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

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

Awesome i really liked it
Reply
#10

Linux doesn't work
Reply
#11

Works fine here.
Reply
#12

this is awesome
Reply
#13

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

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

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

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

Don't work on Linux!
Reply
#18

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...
Reply
#19

Fixed version for linux:

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

Tested ?
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)