Player to point - 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: Player to point (
/showthread.php?tid=90970)
Player to point -
Geekzor - 11.08.2009
Guys i forget, where i can get Player to point function ? can someone give a link or post it here please
Re: Player to point -
Basss - 11.08.2009
Код:
forward PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z);
Код:
public PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
{
if(IsPlayerConnected(playerid))
{
new Float:oldposx, Float:oldposy, Float:oldposz;
new Float:tempposx, Float:tempposy, Float:tempposz;
GetPlayerPos(playerid, oldposx, oldposy, oldposz);
tempposx = (oldposx -x);
tempposy = (oldposy -y);
tempposz = (oldposz -z);
if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
{
return true;
}
}
return false;
}
cheerz
Re: Player to point -
Joe Staff - 11.08.2009
That one sucks and is inaccurate.
pawn Код:
Float:DistFromPlayerToPoint(playerid,Float:X,Float:Y,Float:Z) //Slower, but gives you the distance
{
new Float:tmpx,Float:tmpy,Float:tmpz;
GetPlayerPos(playerid,tmpx,tmpy,tmpz);
return floatsqroot(floatpower(X-tmpx,2)+floatpower(Y-tmpy,2)+floatpower(Z-tmpz,2));
}
IsPlayerNearPoint(playerid,Float:X,Float:Y,Float:Z,Float:radius) //Faster to compute
{
new Float:tmpx,Float:tmpy,Float:tmpz;
GetPlayerPos(playerid,tmpx,tmpy,tmpz);
return ((X-tmpx)*(X-tmpx))+((Y-tmpy)*(Y-tmpy))+((Z-tmpz)*(Z-tmpz))<(radius*radius);
}
EDIT* Windows 7 messed up my post pretty bad lol, *cleaned*
Re: Player to point -
Geekzor - 11.08.2009
ty but 1 more problem , how i can check if the player is at checkpoint ?