إنتقل إلى المحتوى الرئيسي

NPC_SetRot

warning

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

Description​

Sets an NPC's rotation on all three axes (X, Y, Z).

NameDescription
npcidThe ID of the NPC.
Float:xX-axis rotation in degrees.
Float:yY-axis rotation in degrees.
Float:zZ-axis rotation in degrees.

Returns​

Returns true if the operation was successful, false otherwise.

Examples​

public OnPlayerCommandText(playerid, cmdtext[])
{
if (!strcmp(cmdtext, "/setrandomrot", 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:x = float(random(360));
new Float:y = float(random(360));
new Float:z = float(random(360));

NPC_SetRot(npcid, x, y, z);
SendClientMessage(playerid, 0x00FF00FF, "NPC %d rotation randomized", npcid);

return 1;
}
return 0;
}

Notes​

warning
  • Rotation values are in degrees (0-360).
  • Z-axis rotation affects facing direction (same as NPC_SetFacingAngle).
  • X and Y rotations can create tilted or upside-down NPCs.
  • Use NPC_GetRot to retrieve current rotation values.