open.mp forum
[Pawn] [HELP] NPC anim - Printable Version

+ open.mp forum (https://forum.open.mp)
-- Forum: SA-MP (https://forum.open.mp/forumdisplay.php?fid=3)
--- Forum: Pawn Scripting (https://forum.open.mp/forumdisplay.php?fid=10)
--- Thread: [Pawn] [HELP] NPC anim (/showthread.php?tid=1684)



[HELP] NPC anim - spyrothedragon96 - 2021-02-19

Hi everyone, I have a little problem with NPCs.
I have created a fs animations for NPCs?to run via a command: /animname <npcname>
The problem is this: if there are two NPCs called NPC1 and NPC11 in game, when I assign an animation to NPC11 by typing for example /roadcross npc11, the animation is performed on NPC1.
It is as if the command captured NPC1 first.
Same thing happens, for example, if there are NPC2 and NPC21 ... The command is first captured by NPC2
Instead, if I delete NPC1 and now run the command on NPC11 it works.
Maybe there is a need to set the script so that you have to type the full name?
Do you know how I can solve?
This is the example of the script:

PHP Code:
CMD:npc_roadcross(playeridparams[])
{
new 
targetid;
if(
sscanf(params"u"targetid)) return SendClientMessage(playerid, -1"Use: /npc_anim <playerid/npc>");
? ? if(!
IsPlayerConnected(targetid)) return SendClientMessage(playerid, -1"Invalid Player id.");
? ? 
ApplyAnimation(targetid"PED","roadcross",4.0,0,0,0,0,-1);
? ? return 
1;