Saltar al contenido principal

NPC_ApplyAnimation

aviso

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

Description

Applies a specific animation to an NPC using animation library and name.

NameDescription
npcidThe ID of the NPC
animlib[]The animation library name
animname[]The animation name within the library
deltaThe speed of the animation (typically 4.1)
loopWhether the animation should loop
lockXLock movement on the X axis
lockYLock movement on the Y axis
freezeFreeze the NPC at the end of animation
timeTime in milliseconds to play the animation

Returns

Returns true if the operation was successful, false otherwise.

Examples

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

NPC_ApplyAnimation(npcid, "DANCING", "dance_loop", 4.1, true, false, false, false, 0);
SendClientMessage(playerid, 0x00FF00FF, "NPC %d has been applied animation.", npcid);

return 1;
}
return 0;
}

Notes

  • Use time parameter to set animation duration
  • Lock parameters prevent movement on specific axes during animation
  • Use NPC_ClearAnimations to stop all animations
  • Delta typically ranges from 1.0 to 10.0 (4.1 is standard)