24.01.2010, 23:35
(
Last edited by StrickenKid; 15/07/2010 at 04:03 PM.
Reason: Fixed bbcode
)
PointToPoint Plugin
Created By Blacklite & Me
FunctionsCreated By Blacklite & Me
- 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);
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);
}
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);
}
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);
}
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);
}
Here are a couple pictures comparing the speeds of the plugin function and a regular pawn function.
Download:
Post Questions And Comments!