Spawn in front of vehicle - 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: Spawn in front of vehicle (
/showthread.php?tid=656257)
Spawn in front of vehicle -
Osamakurdi - 11.07.2018
How I can spawn in front of vehicle if I have coordinates of it (x, y, z)?
Thanks in advanced.
Re: Spawn in front of vehicle -
coool - 11.07.2018
search 'GetXYInFrontOFPlayer'
Re: Spawn in front of vehicle -
Caessius - 11.07.2018
As said by cool, use GetXYInFrontOfPlayer function to achieve it.
pawn Код:
Float:GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance)
{
new Float:a;
GetPlayerPos(playerid, x, y, a);
if (IsPlayerInAnyVehicle(playerid)) GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
else GetPlayerFacingAngle(playerid, a);
x += (distance * floatsin(-a, degrees));
y += (distance * floatcos(-a, degrees));
return a;
}
Re: Spawn in front of vehicle -
Osamakurdi - 13.07.2018
Thanks both +REP