Distance between two players
#1

Hi guys, i made a cuff command with zcmd but i can use it from anywhere, how to make it to be able to use if i am close to a certain player.

BTW i searched forums and found 2 that did not work.
Reply
#2

GetPlayerPos of the target.

TargetX, TargetY, TargetZ

pawn Код:
if(IsPlayerInRangeOfPoint(playerid, 1.0, TargetX, TargetY, TargetZ))
{
          //CUFF
}
else
{
          //NOT IN RANGE
}
Yeah I suck at coding...I know
Reply
#3

Do i have to make TargetX, Y and Z a float?
Reply
#4

Here is my IsPlayerInRangeOfPlayer(playerid, targetid, Float:distance);
pawn Код:
stock IsPlayerInRangeOfPlayer(playerid, targetid, distance)
{
    new
        Float:X, Float:Y, Float:Z, Float:tX, Float:tY, Float:tZ;
    GetPlayerPos(playerid, X, Y, Z); // Unsure if this is even needed..
    GetPlayerPos(targetid, tX, tY, tZ);
    if(IsPlayerInRangeOfPoint(playerid, distance, tX, tY, tZ)) return 1;
    return 0;
}
Should work fine.
Reply
#5

Should this go anywhere outside a public (at bottom of script?)
Reply
#6

yeah, bottom is perfectly fine.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)