SetPlayerBehindID - 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)
+--- Thread: SetPlayerBehindID (
/showthread.php?tid=481759)
SetPlayerBehindID -
ajwar - 17.12.2013
Is it possible to make this function?
stock SetPlayerBehindPlayer(playerid, Player2)
I want that Player2 teleports behind playerid.
Re: SetPlayerBehindID -
Jefff - 17.12.2013
pawn Код:
stock SetPlayerBehindPlayer(playerid, Player2, Float:Distance = 2.0)
{
new Float:P[4];
GetPlayerPos(playerid, P[0], P[1], P[2]);
GetPlayerFacingAngle(playerid, P[3]);
P[0] -= (Distance * floatsin(-P[3], degrees));
P[1] -= (Distance * floatcos(-P[3], degrees));
SetPlayerPos(Player2, P[0], P[1], P[2]);
SetPlayerFacingAngle(Player2, P[3]);
}
Re: SetPlayerBehindID -
ajwar - 17.12.2013
P[0] -= (Distance * floatsin(-P[3], degrees));
P[1] -= (Distance * floatcos(-P[3], degrees));
those return tag mismatch
Re: SetPlayerBehindID -
ajwar - 18.12.2013
fixed
Re: SetPlayerBehindID -
Tayab - 18.12.2013
Quote:
Originally Posted by Jefff
pawn Код:
stock SetPlayerBehindPlayer(playerid, Player2, Float:Distance = 2.0) { new Float:P[4]; GetPlayerPos(playerid, P[0], P[1], P[2]); GetPlayerFacingAngle(playerid, P[3]); P[0] -= (Distance * floatsin(-P[3], degrees)); P[1] -= (Distance * floatcos(-P[3], degrees)); SetPlayerPos(Player2, P[0], P[1], P[2]); SetPlayerFacingAngle(Player2, P[3]); }
|
Just out of curiosity, I wanna know what does floatcos and floatsin do here?
Couldn't we just do simply like that? Please explain.
pawn Код:
stock SetPlayerBehindPlayer(playerid, Player2)
{
new Float:P[4];
GetPlayerPos(playerid, P[0], P[1], P[2]);
GetPlayerFacingAngle(playerid, P[3]);
SetPlayerPos(Player2, P[0]-2, P[1], P[2]);
SetPlayerFacingAngle(Player2, P[3]);
return 1;
}
Re: SetPlayerBehindID -
CutX - 18.12.2013
Quote:
Originally Posted by Tayab
Just out of curiosity, I wanna know what does floatcos and floatsin do here?
|
cuz here we also set the correct angle, not just the position.
see
https://sampwiki.blast.hk/wiki/Floatcos
'n
https://sampwiki.blast.hk/wiki/Floatsin
if we also set the angle, the player who'll be teleported will face the direction of the player who ported em.