fly car
#1

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

bump
Reply
#3

If you want to make the car fly (jump, in your case) - I recommend that you put it so it executes through OnPlayerKeyStateChange (https://sampwiki.blast.hk/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.

PHP код:
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.
Reply
#4

Quote:
Originally Posted by denNorske
Посмотреть сообщение
If you want to make the car fly (jump, in your case) - I recommend that you put it so it executes through OnPlayerKeyStateChange (https://sampwiki.blast.hk/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.

PHP код:
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!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)