Skip to main content

NPC_GetRot

warning

This function was added in omp v1.5.8.3079 and will not work in earlier versions!

Description​

Gets the rotation of an NPC in 3D space.

NameDescription
npcidThe ID of the NPC.
&Float:xVariable to store the X rotation (pitch), passed by reference.
&Float:yVariable to store the Y rotation (yaw), passed by reference.
&Float:zVariable to store the Z rotation (roll), passed by reference.

Returns​

Returns true if the rotation was retrieved successfully, false otherwise.

Examples​

public OnPlayerCommandText(playerid, cmdtext[])
{
if (!strcmp(cmdtext, "/checkrot", true))
{
new npcid = PlayerNPC[playerid];
if (npcid == INVALID_NPC_ID)
return SendClientMessage(playerid, 0xFF0000FF, "You are not debugging a NPC.");

if (!NPC_IsValid(npcid))
return SendClientMessage(playerid, 0xFF0000FF, "Invalid NPC.");

new Float:rotX, Float:rotY, Float:rotZ;
NPC_GetRot(npcid, rotX, rotY, rotZ);

SendClientMessage(playerid, 0x00FF00FF, "NPC %d rotation: X=%.2f, Y=%.2f, Z=%.2f", npcid, rotX, rotY, rotZ);
return 1;
}
return 0;
}

Notes​

warning
  • All rotation parameters are passed by reference and will be modified.
  • X = pitch (up/down), Y = yaw (left/right), Z = roll (banking).
  • For simple facing direction, use NPC_GetFacingAngle instead.