GetVehicleRotationQuat

GetVehicleRotationQuat

Description:
Function GetVehicleRotationQuat returns a vehicle's rotation on all axes as a quaternion (https://en.wikipedia.org/wiki/Quaternions%20and%20spatial%20rotation).


Function GetVehicleRotationQuat was added in 0.3 and will not work in earlier versions!
  • There is no 'set' variation of this function; you can not SET a vehicle's rotation (apart from the Z angle)
  • This function may return incorrect values for unoccupied vehicles. The reason is that the third row of the vehicle's internal rotation matrix gets corrupted if it gets updated while unoccupied.


Parameters:
(vehicleid, &Float:w, &Float:x, &Float:y, &Float:z)
int vehicleid The ID of the vehicle to get the rotation of.
float w A float variable in which to store the first quaternion angle, passed by reference.
float x A float variable in which to store the second quaternion angle, passed by reference.
float y A float variable in which to store the third quaternion angle, passed by reference.
float z A float variable in which to store the fourth quaternion angle, passed by reference.


Return Values:
  • 1: The function was executed successfully.
  • 0: The function failed to execute. This means the vehicle specified does not exist.
  • The vehicle's rotation is stored in the specified variables.


Examples:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp(cmdtext, "/flip", true) == 0)
    {
        new currentveh;
        new Float:angle;
        currentveh = GetPlayerVehicleID(playerid);
        GetVehicleZAngle(currentveh, angle);
        SetVehicleZAngle(currentveh, angle);
        SendClientMessage(playerid, 0xFFFFFFFF, "Your vehicle has been flipped.");
        return 1;
    }
 
     return 0;
}


Related Functions
The following functions may be useful, as they are related to this function in one way or another.