[KM]Helathien

  • Newbie
  • Posts: 15
/flip Command for cars.
«  »
/FLIP COMMAND.

I have not been able to find this command on the forum , so I thought I'd paste it here for help.
Credits: [KM]Helathien.

Code:
Add this in onPlayerCommand( player, cmd, text)

Code: [Select]
if ( cmd == "flip" )
{
if ( !player.Vehicle ) MessagePlayer( "[#ff1111]Error: [#ffffff]You need to be in a Vehicle to use this command." , player )
else
{
local veh = player.Vehicle;
veh.Rotation = Quaternion( 0.0, 0.0, 0.0, 0.0 );
MessagePlayer( "[#00ff00][INFO] [#ffffff]You have flipped your car." , player )
}
}

Hope it helps :D
Feel free to PM me for any help.
If I am not available on the forum come to VKs Official Server I am usually there.

Sebastian

  • VC:MP Beta Tester
  • Something like this: hga hga hga
  • Posts: 826
Re: /flip Command for cars.
« Reply #1,  »
This is one thing I keep forgeting to implement in my server.
I realize it only when my car rolls down the hill :D

Mohamed

  • Full Member
  • Regards, We3da
  • Posts: 238
Feel Free To PM Me For Any Support, I'm Care.
Anyway u can Contact Me Ingame!
Ingame Name: [AFt]We3da^
My Own Server: ViceEvil Server

rww

  • VC:MP Beta Tester
  • LU-DM Team
  • Posts: 324
Re: /flip Command for cars.
« Reply #3,  »
With this, only driver can flip the car ;)

Code: [Select]
PlayerEnteringVehicle <- array(GetMaxPlayers(), 0);

function onPlayerPart(player,reason)
{
if (PlayerEnteringVehicle[player.ID] != 0) PlayerEnteringVehicle[player.ID] = 0;
return 1;
}

function onPlayerEnteringVehicle(player,vehicle,door)
{
PlayerEnteringVehicle[player.ID] = 1;
return 1;
}

function onPlayerEnterVehicle(player,vehicle,seat)
{
PlayerEnteringVehicle[player.ID] = 0;
return 1;
}

function onPlayerExitVehicle(player,vehicle)
{
if (PlayerEnteringVehicle[player.ID] > 0) PlayerEnteringVehicle[player.ID] = 0;
return 1;
}

function onPlayerCommand(player,cmd,text)
{
if (cmd) cmd = cmd.tolower();
local veh = player.Vehicle;

if ( cmd == "flip" )
{
if ( !veh ) MessagePlayer( "[#ff1111]Error: [#ffffff]You need to be in a Vehicle to use this command." , player );
else if ( PlayerEnteringVehicle[player.ID] > 0 || player.State == 4 ) MessagePlayer( "[#ff1111]Error: [#ffffff]You must be a driver." , player );
else
{
veh.EulerAngle = Vector(0.0,0.0,0.0);
MessagePlayer( "[#00ff00][INFO] [#ffffff]You have flipped your car." , player );
}
}
else MessagePlayer( "[#ff1111]Error: [#ffffff]This command doesn't exist." , player );
return 1;
}

BeckzyBoi

  • Jr. Member
  • Posts: 52
Re: /flip Command for cars.
« Reply #4,  »
This is a much better way of doing it. It'll flip only the vehicle x rotation 180 degrees.

Code: [Select]
function onPlayerCommand(player, command, arguments)
{
    if (cmd == "flip")
    {
            if (player.State != 3) MessagePlayer("Error: You must be the driver of a vehicle.", player)
            else
            {
                local ax = player.Vehicle.EulerAngle.x, ay = player.Vehicle.EulerAngle.y, az = player.Vehicle.EulerAngle.z;
                player.Vehicle.EulerAngle = Vector(ax < 0 ? ax + 3.14159 : ax - 3.14159, ay, az);
                MessagePlayer("ACTION: You have flipped the vehicle.", player);
            }
        }
    }
}

Rest

  • Jr. Member
  • V
  • Posts: 89
Re: /flip Command for cars.
« Reply #5,  »
Quote from rww on June 9th, 03:24 PM
With this, only driver can flip the car ;)
How about :)
Code: [Select]
if  ( player.VehicleSlot == 0 ) MessagePlayer( "[#ff1111]Error: [#ffffff]You must be a driver." , player );

ysc3839

  • VC:MP Beta Tester
  • Posts: 567

BeckzyBoi

  • Jr. Member
  • Posts: 52
Re: /flip Command for cars.
« Reply #7,  »
Quote from ysc3839 on July 12th, 09:12 AM
@BeckzyBoi #4 If I remembered correctly, you can just use player.Vehicle.EulerAngle.x = ... to change it.
You actually can't. Doing that will reset the y and z angles also. I've got no idea why. The way I posted to do it is the only accurate way.

rww

  • VC:MP Beta Tester
  • LU-DM Team
  • Posts: 324