PDA

View Full Version : fly car


None1337
09/01/2018, 12:29 PM
Hello guys, i tried to create a command. when you are in a vehicle and use the cocmmand, the car to jump.

I tried this but I did not succeed

new Float:Pos[4], Float:zPos[3];
new vehicleid = GetPlayerVehicleID(playerid);
GetVehiclePos(vehicleid, Pos[0], Pos[1], Pos[2]);
SetVehiclePos(vehicleid, Pos[0], Pos[1], Pos[2]+20);
GetVehicleZAngle(vehicleid, Pos[3]);
new tt = random(2);
if(tt== 0) SetVehicleZAngle(vehicleid, Pos[3]+10),SCM(playerid, -1, "test 1");
else SetVehicleZAngle(vehicleid, Pos[3]+5),SCM(playerid, -1, "test 2");
GetVehicleVelocity(vehicleid, zPos[0], zPos[1], zPos[2]);
SetVehicleVelocity(vehicleid, zPos[0] + 0.1, zPos[1] + 0.1 , zPos[2] + 0.1);
SetCameraBehindPlayer(playerid);

Any idea?

None1337
10/01/2018, 12:17 PM
bump

denNorske
10/01/2018, 12:36 PM
If you want to make the car fly (jump, in your case) - I recommend that you put it so it executes through OnPlayerKeyStateChange (http://wiki.sa-mp.com/wiki/OnPlayerKeyStateChange), that way all you need to do is to tap a key to jump. But it's up to you how you configure it though.


new Float:Vel[3]; //Float:zPos[3];
new vehicleid = GetPlayerVehicleID(playerid);
//GetVehiclePos(vehicleid, Pos[0], Pos[1], Pos[2]);
//SetVehiclePos(vehicleid, Pos[0], Pos[1], Pos[2]+20);
//GetVehicleZAngle(vehicleid, Pos[3]);
GetVehicleVelocity(vehicleid ,Vel[0],Vel[1],Vel[2]); //get the current velocity
SetVehicleVelocity(vehicleid ,Vel[0],Vel[1],Vel[2]+0.3); //add some velocity upwards, z, to make it lift off the ground, while keeping the current velocity in the plane.
/*new tt = random(2); //I don't know why you did this?
if(tt== 0)
SetVehicleZAngle(vehicleid, Pos[3]+10),SCM(playerid, -1, "test 1");
else
SetVehicleZAngle(vehicleid, Pos[3]+5),SCM(playerid, -1, "test 2");*/
SetCameraBehindPlayer(playerid);





There is no need to get the position of the car, because when you do "SetVehiclePos", the car will remove all of it's Velocity and stand still at one point. Just directly add the upwards velocity, and the car will lift off.
Try this code above, and see how it turns out.

None1337
10/01/2018, 09:40 PM
If you want to make the car fly (jump, in your case) - I recommend that you put it so it executes through OnPlayerKeyStateChange (http://wiki.sa-mp.com/wiki/OnPlayerKeyStateChange), that way all you need to do is to tap a key to jump. But it's up to you how you configure it though.


new Float:Vel[3]; //Float:zPos[3];
new vehicleid = GetPlayerVehicleID(playerid);
//GetVehiclePos(vehicleid, Pos[0], Pos[1], Pos[2]);
//SetVehiclePos(vehicleid, Pos[0], Pos[1], Pos[2]+20);
//GetVehicleZAngle(vehicleid, Pos[3]);
GetVehicleVelocity(vehicleid ,Vel[0],Vel[1],Vel[2]); //get the current velocity
SetVehicleVelocity(vehicleid ,Vel[0],Vel[1],Vel[2]+0.3); //add some velocity upwards, z, to make it lift off the ground, while keeping the current velocity in the plane.
/*new tt = random(2); //I don't know why you did this?
if(tt== 0)
SetVehicleZAngle(vehicleid, Pos[3]+10),SCM(playerid, -1, "test 1");
else
SetVehicleZAngle(vehicleid, Pos[3]+5),SCM(playerid, -1, "test 2");*/
SetCameraBehindPlayer(playerid);





There is no need to get the position of the car, because when you do "SetVehiclePos", the car will remove all of it's Velocity and stand still at one point. Just directly add the upwards velocity, and the car will lift off.
Try this code above, and see how it turns out.

Thanks bro!