GetXYInFrontOfVehicle problem? - 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: GetXYInFrontOfVehicle problem? (
/showthread.php?tid=252206)
GetXYInFrontOfVehicle problem? -
Donya - 30.04.2011
GetVehiclePos(id, x, y, z);
GetXYInFrontOfVehicle(playerid, x, y, 1.4249);
ok if a vehicle is facing like > 350 && < 360 and > 0 && < 10 it works fine, but when a vehicle turns, or is facing left or right, the offset is bad?
pawn Код:
stock GetXYInFrontOfVehicle(vehicleid, &Float:x, &Float:y, Float:distance)
{
new Float:a;
GetVehiclePos(vehicleid, x, y, a);
GetVehicleZAngle(vehicleid, a);
x += (distance * floatsin(-a, degrees));
y += (distance * floatcos(-a, degrees));
}
Re: GetXYInFrontOfVehicle problem? -
xir - 30.04.2011
This should be the right stock
pawn Код:
stock GetXYInFrontOfPlayer(playerid, &Float:x2, &Float:y2, Float:distance) // ******
{
new Float:a;
GetPlayerPos(playerid, x2, y2, a);
GetPlayerFacingAngle(playerid, a);
if(GetPlayerVehicleID(playerid))
{
GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
}
x2 += (distance * floatsin(-a, degrees));
y2 += (distance * floatcos(-a, degrees));
}
Re: GetXYInFrontOfVehicle problem? -
Donya - 30.04.2011
... did i mention it WORKS? but when a vehicle is facing left or right it returns a bad x and y!
Re: GetXYInFrontOfVehicle problem? -
fordawinzz - 26.12.2011
solved using:
pawn Код:
stock GetXYBehindOfVehicle(vehicleid, &Float:x, &Float:y, Float:distance)
{
new Float: a;
GetVehiclePos( vehicleid, x, y, a );
GetVehicleZAngle( vehicleid, a );
x += ( distance * floatsin( -a+180, degrees ));
y += ( distance * floatcos( -a+180, degrees ));
}
with distance 3.
woops, wrong topic
Re: GetXYInFrontOfVehicle problem? -
jamesbond007 - 26.12.2011
Quote:
Originally Posted by xir
This should be the right stock
pawn Код:
stock GetXYInFrontOfPlayer(playerid, &Float:x2, &Float:y2, Float:distance) // ****** { new Float:a;
GetPlayerPos(playerid, x2, y2, a); GetPlayerFacingAngle(playerid, a);
if(GetPlayerVehicleID(playerid)) { GetVehicleZAngle(GetPlayerVehicleID(playerid), a); }
x2 += (distance * floatsin(-a, degrees)); y2 += (distance * floatcos(-a, degrees)); }
|
its the same function lolz... just adding spaces and 1 check >_>
-.-"