Flip car - 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: Flip car (
/showthread.php?tid=167281)
Flip car -
FireCat - 11.08.2010
anyone know how can i like when i press caps lock the car turns? in a server they have that and i think its awesome but i dont want the car to jump only flip
_______________________
[GDZ]leader
Re: Flip car -
JaTochNietDan - 11.08.2010
Use a combination of OnPlayerKeyStateChange and SetVehicleZAngle, like so.
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(newkeys & KEY_FIRE)
{
if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return 1;
new
zAngle,
Vehicle = GetPlayerVehicleID(playerid);
GetVehicleZAngle(Vehicle,zAngle);
SetVehicleZAngle(Vehicle,zAngle);
}
return 1;
}
Of course you'll have to change the key to the one you want.
Re: Flip car -
FireCat - 11.08.2010
what is the key for caps?
Re: Flip car -
Hiddos - 11.08.2010
Quote:
Originally Posted by JaTochNietDan
Use a combination of OnPlayerKeyStateChange and SetVehicleZAngle, like so.
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys) { if(newkeys & KEY_FIRE) { if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return 1; new zAngle, Vehicle = GetPlayerVehicleID(playerid); GetVehicleZAngle(Vehicle,zAngle); SetVehicleZAngle(Vehicle,zAngle); } return 1; }
Of course you'll have to change the key to the one you want.
|
The Z angle turns the car around
Try doing something with SetVehicleAngularVelocity,
https://sampwiki.blast.hk/wiki/SetVehicleAngularVelocity
Re: Flip car -
JaTochNietDan - 11.08.2010
Quote:
Originally Posted by Hiddos
|
I'm aware of that, however setting the Z angle of the car using that function also sets the x,y angle of the car to 0, so it is right side up. It is how stunt servers have had a flip command for years.
Also, the angular velocity is the velocity of the car in that direction, not the position.
As regards to the KeyID of "CAPS LOCK" I assume you mean the KeyID of the horn button. OnPlayerKeyStateChange only works with San Andreas keys, not with actual keyboard keys. So if someone changes the horn button to spacebar, then spacebar would be the key to flip the car.
Anyway, the horn KeyID is not actually defined in the a_samp include, so you'll have to go in-game and do some debugging to find it yourself.