Posts: 647
Threads: 34
Joined: Apr 2009
Reputation:
0
Most of the time animations wont work on first attempt ..maybe if you set a small timer after it spawned
the animation should work.
Anyway, do it twice ..at onplayerspawn ..you already have and with a timer
Edit: it might have to do something with if the npc is streamed in or not.
Posts: 89
Threads: 15
Joined: Feb 2010
Reputation:
0
I've tryed the timer with the applyanimation there too, but still nothing?
i added this:
forward animtimer(playerid);
public animtimer(playerid)
{
ApplyAnimation(playerid,"PED","IDLE_CHAT",2.1,1,1, 1,1,0);
ApplyAnimation(playerid,"PED","IDLE_CHAT",2.1,1,1, 1,1,0);
}
public OnPlayerSpawn(playerid)
{
if(IsPlayerNPC(playerid))
{
new npcname[MAX_PLAYER_NAME];
GetPlayerName(playerid, npcname, sizeof(npcname));
if(!strcmp(npcname, "NPC", true))
{
ApplyAnimation(playerid,"PED","IDLE_CHAT",2.1,1,1, 1,1,0);
ApplyAnimation(playerid,"PED","IDLE_CHAT",2.1,1,1, 1,1,0);
SetTimer("animtimer", 1000, true);
return 1;
}
}
}
Do the NPC Animations work if they are in a building that was added and that it isn't on the floor?
Do they have to be on the ground for it to work?
I just thought of this because when i'm far away and my line of sight can't see the building, but can see the NPC he does the falling animation, but it doesn't really fall.
Posts: 273
Threads: 4
Joined: Nov 2007
Reputation:
0
That Is Player Streamed idea might actually work, but if not, this is the solution I came up when I had trouble with Animations & NPCs when I searched a while back for it over the SA-MP Forums:
Animations for NPCs must be looped so the NPC does the animation over and over again, only then does it work... But with that information, I tried looping animations for only about 3-5 seconds which then stops but kept the animation for the NPC. That was on a NPC that didn't move or anything though
But there was a helpful topic on this somewhere on these forums about NPC Animations, just search it out
Posts: 1,896
Threads: 102
Joined: Oct 2008
You need to pre load the animations.
Top of script:
pawn Код:
new gPlayerUsingLoopingAnim[MAX_PLAYERS];
new gPlayerAnimLibsPreloaded[MAX_PLAYERS];
Somewhere else:
pawn Код:
LoopingAnim(playerid,animlib[],animname[], Float:Speed, looping, lockx, locky, lockz, lp)
{
gPlayerUsingLoopingAnim[playerid] = 1;
ApplyAnimation(playerid, animlib, animname, Speed, looping, lockx, locky, lockz, lp);
}
PreloadAnimLib(playerid, animlib[])
{
ApplyAnimation(playerid,animlib,"null",0.0,0,0,0,0,0);
}
Add these to OnPlayerConnect:
pawn Код:
public OnPlayerConnect(playerid)
{
gPlayerUsingLoopingAnim[playerid] = 0;
gPlayerAnimLibsPreloaded[playerid] = 0;
return 1;
}
Example OnPlayerSpawn:
pawn Код:
public OnPlayerSpawn(playerid)
{
if(!gPlayerAnimLibsPreloaded[playerid]) {
PreloadAnimLib(playerid,"DANCING");
gPlayerAnimLibsPreloaded[playerid] = 1;
}
if(!IsPlayerNPC(playerid)) return 0;
new playername[64];
GetPlayerName(playerid,playername,64);
if(!strcmp(playername,"Example",true)) {
SetSpawnInfo( playerid, 0, 87, 1203.9446,16.5226,1000.9219, 344.9598, 0, 0, 0, 0, 0, 0 );
ShowPlayerMarkers(0);
LoopingAnim(playerid,"DANCING","DAN_Loop_A",4.1,1,1,1,1,0);
}
return 1;
}
Hope this helps.