[solved] - 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: [solved] (
/showthread.php?tid=140183)
[solved] -
RyDeR` - 07.04.2010
Hi, like in the subject.. How can I do this?
I tried:
Код:
new
Float: vX,
Float: vY,
Float: vZ
;
GetVehicleVelocity(GetPlayerVehicleID(playerid), vX, vY, vZ);
if(vY < 0) // vehicle is driving backwards
This worked for a part, only in a specified direction..
I don't get the san andreas world
Regards,
Re: Check if vehicle is driving backwards -
shady91 - 07.04.2010
I wanna know this as well.
Re: Check if vehicle is driving backwards -
NeRoSiS - 07.04.2010
Check the angle of the vehicle with the velocity, im guessing if the angle was the opposite way round to the velocity's co-ordinates then it would be in reverse?
Just check using GetVehicleZAngle that the vehicle isn't facing the way it's going.
Re: Check if vehicle is driving backwards -
Nero_3D - 08.04.2010
pawn Код:
stock bool:IsVehicleDrivingBackwards(vehicleid)
{
new Float:Float[3];
if(GetVehicleVelocity(vehicleid, Float[1], Float[2], Float[0])) {
GetVehicleZAngle(vehicleid, Float[0]);
if(Float[0] < 90) {
if(Float[1] > 0 && Float[2] < 0) return true;
} else if(Float[0] < 180) {
if(Float[1] > 0 && Float[2] > 0) return true;
} else if(Float[0] < 270) {
if(Float[1] < 0 && Float[2] > 0) return true;
} else if(Float[1] < 0 && Float[2] < 0) return true;
}
return false;
}
Not tested but basically it should work (if there isnt any mistake)
Re: Check if vehicle is driving backwards -
shady91 - 08.04.2010
just tested it and it work's man thanks this actually came in very useful to me thank you.
Re: Check if vehicle is driving backwards -
RyDeR` - 08.04.2010
Quote:
Originally Posted by ♣ Joker ♠
pawn Код:
stock bool:IsVehicleDrivingBackwards(vehicleid) { new Float:Float[3]; if(GetVehicleVelocity(vehicleid, Float[1], Float[2], Float[0])) { GetVehicleZAngle(vehicleid, Float[0]); if(Float[0] < 90) { if(Float[1] > 0 && Float[2] < 0) return true; } else if(Float[0] < 180) { if(Float[1] > 0 && Float[2] > 0) return true; } else if(Float[0] < 270) { if(Float[1] < 0 && Float[2] > 0) return true; } else if(Float[1] < 0 && Float[2] < 0) return true; } return false; }
Not tested but basically it should work (if there isnt any mistake)
|
Thanks Joker, it works =)