Distance between two players - 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: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Distance between two players (
/showthread.php?tid=175741)
Distance between two players -
zack3021 - 10.09.2010
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.
Re: Distance between two players -
vital2k - 10.09.2010
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
Re: Distance between two players -
zack3021 - 10.09.2010
Do i have to make TargetX, Y and Z a float?
Re: Distance between two players -
Toni - 11.09.2010
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.
Re: Distance between two players -
zack3021 - 11.09.2010
Should this go anywhere outside a public (at bottom of script?)
Re: Distance between two players -
Toni - 11.09.2010
yeah, bottom is perfectly fine.