Velocity change 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Velocity change problem (
/showthread.php?tid=278277)
Velocity change problem -
Libra_PL - 21.08.2011
I'm now trying to change vehicle velocity (for example from X=1.5 Y=-2 Z=0 to X=-1.5 Y=2 Z=0), but it doesn't work properly... Sometimes it works fine (if the velocity X and Y is higher than 0), but on few directions the velocity doesn't change or my vehicle 'flies' to diffrent ways (not behind me or ahead, but on the left or right). The code I'm using:
Code:
new Float:X, Float:Y, Float:Z;
GetVehicleVelocity(GetPlayerVehicleID(playerid),X,Y,Z);
if(X >= 0)
{
X = -X;
}
if(Y >= 0)
{
Y = -Y;
}
if(Z >= 0)
{
Z = -Z;
}
SetVehicleVelocity(GetPlayerVehicleID(playerid),X,Y,Z);
I hope someone will find what's wrong here and help me
Re: Velocity change problem -
veyron - 21.08.2011
why do you check if those values are greater than zero?
Re: Velocity change problem -
Babul - 21.08.2011
agreed. if you check for positive velocity, then only when driving north or east will trigger that axis. simply dont check for any speed, try:
Code:
new Float:X, Float:Y, Float:Z;
GetVehicleVelocity(GetPlayerVehicleID(playerid),X,Y,Z);
X=-X;
Y=-Y;
Z=-Z;
SetVehicleVelocity(GetPlayerVehicleID(playerid),X,Y,Z);
Re: Velocity change problem -
Libra_PL - 21.08.2011
Oh, thank you Babul

Enjoy your rep