Aller au contenu principal

NPC_SetAnimation

attention

La fonctionnalité de type fonction a été ajoutée dans la version omp v1.5.8.3079 et ne fonctionne pas avec les versions antérieures !

Description​

Sets an animation for an NPC using animation ID.

NameDescription
npcidThe ID of the NPC
animationidThe animation ID to set
deltaAnimation speed (typically 4.1)
loopWhether the animation should loop
lockXLock movement on X axis during animation
lockYLock movement on Y axis during animation
freezeFreeze the NPC after animation
timeAnimation duration in milliseconds (0 = infinite)

Returns​

Returns true if the operation was successful, false otherwise.

Examples​

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

NPC_SetAnimation(npcid, 405, 4.1, true, false, false, false, 0);
SendClientMessage(playerid, 0x00FF00FF, "NPC %d has been set to animate.", npcid);

SetTimerEx("ClearNPCAnimations", 25000, false, "ii", playerid, npcid);

return 1;
}
return 0;
}

forward ClearNPCAnimations(playerid, npcid);
public ClearNPCAnimations(playerid, npcid)
{

NPC_ClearAnimations(npcid);
SendClientMessage(playerid, 0x00FF00FF, "NPC %d animations were cleared.", npcid);
}

Notes​

  • Animation IDs correspond to GTA San Andreas animation indices
  • Use NPC_ApplyAnimation for animations by library and name