Flip car
#1

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

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

what is the key for caps?
Reply
#4

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
Reply
#5

Quote:
Originally Posted by Hiddos
Посмотреть сообщение
The Z angle turns the car around

Try doing something with SetVehicleAngularVelocity, https://sampwiki.blast.hk/wiki/SetVehicleAngularVelocity
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.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)