SA-MP Forums Archive
Spawn cars always in front of player, no matter what direction. - 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: Spawn cars always in front of player, no matter what direction. (/showthread.php?tid=73829)



Spawn cars always in front of player, no matter what direction. - Robbin237 - 18.04.2009

I want to spawn cars always in front of the player, no matter what direction they are facing. Because if i just face forward, it works, it spawns in front of me. But if i look left, it will spawn just near me instead of in front.

Can somebody help?
This is my code;

pawn Код:
new Float:Angle;
GetPlayerFacingAngle(playerid, Angle);
new SpawnedVeh = CreateVehicle(VehicleToSpawn, x, y+4, z, Angle, 0, 0, 99999999999999999999999999999);
VehicleToSpawn is Retrieved from the DCMD params.

Thnx!


Re: Spawn cars always in front of player, no matter what direction. - Rks25 - 18.04.2009

try changing the x.


Re: Spawn cars always in front of player, no matter what direction. - yom - 18.04.2009

pawn Код:
new Float:Angle;
GetPlayerFacingAngle(playerid, Angle);
new SpawnedVeh = CreateVehicle(VehicleToSpawn, x + 3 * floatsin(-Angle, degrees), y + 3 * floatcos(-Angle, degrees), z, Angle, 0, 0, 99999999999999999999999999999);