/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)
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
This is one thing I keep forgeting to implement in my server.
I realize it only when my car rolls down the hill :D
Quote from: Sebastian on Jun 09, 2018, 11:26 AMThis is one thing I keep forgeting to implement in my server.
I realize it only when my car rolls down the hill :D
Like me ;D
With this, only driver can flip the car ;)
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;
}
This is a much better way of doing it. It'll flip only the vehicle x rotation 180 degrees.
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);
}
}
}
}
Quote from: rww on Jun 09, 2018, 02:24 PMWith this, only driver can flip the car ;)
How about :)
if ( player.VehicleSlot == 0 ) MessagePlayer( "[#ff1111]Error: [#ffffff]You must be a driver." , player );
@BeckzyBoi #4 If I remembered correctly, you can just use player.Vehicle.EulerAngle.x = ... to change it.
Quote from: ysc3839 on Jul 12, 2018, 08: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.
Quote from: Rest on Jul 12, 2018, 12:51 AMQuote from: rww on Jun 09, 2018, 02:24 PMWith this, only driver can flip the car ;)
How about :)
if ( player.VehicleSlot == 0 ) MessagePlayer( "[#ff1111]Error: [#ffffff]You must be a driver." , player );
Layter I check it ;)