SA-MP Forums Archive
SetVehicleVelocity question - 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: SetVehicleVelocity question (/showthread.php?tid=239363)



SetVehicleVelocity question - Yuval_Baruch - 13.03.2011

hey, is there any way that SetVehicleVelocity function will make the car go in straight line?
iv'e tested this function becouse i wanna use it in my script and when i use it the car is not exactly
going in straight line, its jumping to the sides and not going straight.

Here is my part of code that i use, if you got any idea how to make the car go in straight line i will thank you.

pawn Код:
if(newkeys == KEY_VEHICLE_ACCELERATE)
    {
        if(IsPlayerInAnyVehicle(playerid))
        {
            if(PlayerSpeed[playerid] > 120)
            {
                new Float:x, Float:y, Float:z, Float:f, vid;

                vid = GetPlayerVehicleID(playerid);

                GetVehicleZAngle(vid,f);
                GetVehicleVelocity(vid,x, y, z);

                if (x >= 0.0) { x += 0.2; }
                else { x -= 0.2; }

                if (y >= 0.0) { y += 0.2; }
                else { y -= 0.2; }

                SetVehicleVelocity(vid, x, y, z);
                SetVehicleZAngle(vid,f);
            }
        }
    }



Re: SetVehicleVelocity question - Yuval_Baruch - 14.03.2011

....


Re: SetVehicleVelocity question - Joe Staff - 14.03.2011

Multiply the velocities, don't add them. For an exact speed, use the formula found in GetXYInFrontOfPlayer


Re: SetVehicleVelocity question - Yuval_Baruch - 14.03.2011

thanks man it works perfectly now