spawn car infront of me - 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 car infront of me (
/showthread.php?tid=124435)
spawn car infront of me -
~Dangun! - 30.01.2010
currently i have this:
But now it spawns left of me. But what's the correct coordinates to make it spawn infront of me?
Re: spawn car infront of me -
ray187 - 30.01.2010
^^ awesome. Depending on where you currently look at - meaning whether you character faces north, south, west... whatever - the car will spawn left, right, behind or infront of you. Now think about that very carefully
Re: spawn car infront of me -
GaGlets(R) - 30.01.2010
first of all you need to get player cordinates then you can only set items to spawn infront..
GetPlayerZangle or smth .. etc..
then
AddStaticVehicleEx(blablabla and with goten z angle)
Код:
new get;
get = GetPlayerZAngel ( or smth )
blablabla...
AddStaticVehicle/Ex(x+bla,y+bla+bla,z+bla,get+3 , blalbalba)
hope understood
Re: spawn car infront of me -
wafffllesss - 30.01.2010
pawn Код:
forward Float:GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance);
stock 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;
}
Usage:
pawn Код:
new Float:x,Float:y,Float:z;
GetPlayerPos(playerid,x,y,z); // to get Z
GetXYInFrontOfPlayer(playerid,x,y,2.0);
CreateVehicle(blablabla X,Y,Z...);