Get/SetVehicleVelocity - 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: Get/SetVehicleVelocity (
/showthread.php?tid=449525)
Get/SetVehicleVelocity -
GrInDzO - 09.07.2013
Hi guys!
I have a little problem with my vehicles velocity. So, the problem is here - i'm starting drive with stafford (for example), i'm driving and when i enter in 2nd cp i need to change my car who save the last car speed. Like i go foward with 100 km/h, enter in CP, automatically change my car to hustler and i'm continue driving with 100 km/h. What can be the problem?
Heres the code:
Код:
if(score == 2)
{
GetPlayerPos(playerid, Tempx1, Tempy1, Tempz1);
GetPlayerFacingAngle(playerid, Tempr);
GetVehiclePos(PlayerCar[playerid], Tempx1, Tempy1, Tempz1);
GetVehicleZAngle(PlayerCar[playerid], Tempr);
GetVehicleVelocity(PlayerCar[playerid], Velocity[0], Velocity[1], Velocity[2]);
Car1[playerid] = CreateVehicle(545, Tempx1, Tempy1, Tempz1, Tempr, -1, -1, -1);
SetVehiclePos(Car1[playerid], Tempx1, Tempy1, Tempz1);
SetVehicleZAngle(Car1[playerid], Tempr);
SetVehicleVelocity(Car1[playerid], Velocity[0], Velocity[1], Velocity[2]);
PutPlayerInVehicle(playerid, Car1[playerid], 0);
DestroyVehicle(PlayerCar[playerid]);
}
Hope, u understand what i'm asking..
Re: Get/SetVehicleVelocity -
feartonyb - 09.07.2013
You need to first put player in vehicle then set velocity. Velocity can't be applied to an empty car.
Use this code:
Код:
if(score == 2)
{
GetPlayerPos(playerid, Tempx1, Tempy1, Tempz1);
GetPlayerFacingAngle(playerid, Tempr);
GetVehiclePos(PlayerCar[playerid], Tempx1, Tempy1, Tempz1);
GetVehicleZAngle(PlayerCar[playerid], Tempr);
GetVehicleVelocity(PlayerCar[playerid], Velocity[0], Velocity[1], Velocity[2]);
Car1[playerid] = CreateVehicle(545, Tempx1, Tempy1, Tempz1, Tempr, -1, -1, -1);
PutPlayerInVehicle(playerid, Car1[playerid], 0);
SetVehicleVelocity(Car1[playerid], Velocity[0], Velocity[1], Velocity[2]);
DestroyVehicle(PlayerCar[playerid]);
}
And you don't need
Код:
SetVehiclePos(Car1[playerid], Tempx1, Tempy1, Tempz1);
SetVehicleZAngle(Car1[playerid], Tempr);
because you set it in CreateVehicle