Get/SetVehicleVelocity
#1

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..
Reply
#2

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)