SA-MP Forums Archive
Actor animation - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Actor animation (/showthread.php?tid=583121)



Actor animation - SkullFire - 26.07.2015

Hey there.
Well, my actors doesn't load animations at first(OnGameModeInit)
I've preloaded before with the code from someone i do not remember who did this. well, see...

On top of gamemode
PHP Code:
static s_AnimationLibraries[][] = {
        !
"AIRPORT",    !"ATTRACTORS",   !"BAR",                 !"BASEBALL",
        !
"BD_FIRE",    !"BEACH",            !"BENCHPRESS",  !"BF_INJECTION",
        !
"BIKED",          !"BIKEH",        !"BIKELEAP",        !"BIKES",
        !
"BIKEV",          !"BIKE_DBZ",     !"BMX",             !"BOMBER",
        !
"BOX",            !"BSKTBALL",     !"BUDDY",           !"BUS",
        !
"CAMERA",         !"CAR",          !"CARRY",           !"CAR_CHAT",
        !
"CASINO",         !"CHAINSAW",     !"CHOPPA",          !"CLOTHES",
        !
"COACH",          !"COLT45",       !"COP_AMBIENT", !"COP_DVBYZ",
        !
"CRACK",          !"CRIB",         !"DAM_JUMP",         !"DANCING",
        !
"DEALER",         !"DILDO",        !"DODGE",            !"DOZER",
        !
"DRIVEBYS",   !"FAT",          !"FIGHT_B",      !"FIGHT_C",
        !
"FIGHT_D",    !"FIGHT_E",      !"FINALE",               !"FINALE2",
        !
"FLAME",      !"FLOWERS",      !"FOOD",                 !"FREEWEIGHTS",
        !
"GANGS",      !"GHANDS",       !"GHETTO_DB",    !"GOGGLES",
        !
"GRAFFITI",   !"GRAVEYARD",    !"GRENADE",      !"GYMNASIUM",
        !
"HAIRCUTS",   !"HEIST9",       !"INT_HOUSE",    !"INT_OFFICE",
        !
"INT_SHOP",   !"JST_BUISNESS", !"KART",                 !"KISSING",
        !
"KNIFE",      !"LAPDAN1",              !"LAPDAN2",      !"LAPDAN3",
        !
"LOWRIDER",   !"MD_CHASE",     !"MD_END",               !"MEDIC",
        !
"MISC",       !"MTB",                  !"MUSCULAR",     !"NEVADA",
        !
"ON_LOOKERS", !"OTB",                  !"PARACHUTE",    !"PARK",
        !
"PAULNMAC",   !"PED",                  !"PLAYER_DVBYS", !"PLAYIDLES",
        !
"POLICE",     !"POOL",                 !"POOR",                 !"PYTHON",
        !
"QUAD",       !"QUAD_DBZ",     !"RAPPING",      !"RIFLE",
        !
"RIOT",       !"ROB_BANK",     !"ROCKET",               !"RUSTLER",
        !
"RYDER",      !"SCRATCHING",   !"SHAMAL",               !"SHOP",
        !
"SHOTGUN",    !"SILENCED",     !"SKATE",                !"SMOKING",
        !
"SNIPER",     !"SPRAYCAN",     !"STRIP",                !"SUNBATHE",
        !
"SWAT",       !"SWEET",                !"SWIM",                 !"SWORD",
        !
"TANK",       !"TATTOOS",              !"TEC",                  !"TRAIN",
        !
"TRUCK",      !"UZI",                  !"VAN",                  !"VENDING",
        !
"VORTEX",     !"WAYFARER",     !"WEAPONS",      !"WUZI",
        !
"WOP",        !"GFUNK",                !"RUNNINGMAN"
};
stock static PreloadActorAnimations(actorid)
{
        for(new 
0sizeof(s_AnimationLibraries); ++)
        {
            
ApplyActorAnimation(actorids_AnimationLibraries[i], "null"0.000000);
        }
}
new 
ActorMercadoNActorNinho
OnGameModeInit
PHP Code:
    ActorMercadoN CreateActor(1622355.0710,-648.2926,128.0547,91.2342);
    
PreloadActorAnimations(ActorMercadoN);
    
ActorNinho CreateActor(332686.4758,-1425.5580,16.2500,194.1172);
    
PreloadActorAnimations(ActorNinho);
    
ApplyActorAnimation(ActorMercadoN"INT_SHOP""shop_lookA"4.110000);
    
ApplyActorAnimation(ActorNinho"COP_AMBIENT""Coplook_loop"4.110000); 
To test if animation is working, i did this command :
PHP Code:
CMD:test(playerid)
{
ApplyActorAnimation(ActorNinho"COP_AMBIENT""Coplook_loop"4.110000);
ApplyActorAnimation(ActorMercadoN"INT_SHOP""shop_lookA"4.110000);
return 
1;

and yes, it's working.


Re: Actor animation - Abagail - 26.07.2015

Your code is silly! Why do actors need to have animations preloaded? They aren't clients, they aren't real people, they don't need to see their own animations. You need to preload the animation for the player that's going to be viewing the animation, not the actual actor.


Re: Actor animation - SkullFire - 26.07.2015

I'm applying an animation him for players can see he.Is that not the right way?

@sorry, bad english .-.


Re: Actor animation - Onfroi - 26.07.2015

What's the point of the PreloadActorAnimations function? Just use ApplyActorAnimation in OnGameModeInit.


Re: Actor animation - SkullFire - 26.07.2015

Quote:
Originally Posted by Onfroi
View Post
What's the point of the PreloadActorAnimations function? Just use ApplyActorAnimation in OnGameModeInit.
Same shit.
I will use that \/ , maybe works...
https://sampwiki.blast.hk/wiki/OnActorStreamIn


Re: Actor animation - Abagail - 26.07.2015

Well if this code
pawn Code:
ActorMercadoN = CreateActor(162, 2355.0710,-648.2926,128.0547,91.2342);
    PreloadActorAnimations(ActorMercadoN);
    ActorNinho = CreateActor(33, 2686.4758,-1425.5580,16.2500,194.1172);
    PreloadActorAnimations(ActorNinho);


    ApplyActorAnimation(ActorMercadoN, "INT_SHOP", "shop_lookA", 4.1, 1, 0, 0, 0, 0);
    ApplyActorAnimation(ActorNinho, "COP_AMBIENT", "Coplook_loop", 4.1, 1, 0, 0, 0, 0);
Is in OnGameModeInit, your not doing it right because not all players are near and NO players are even connected at the time the callback is called. Try doing something such as this:

pawn Code:
new actorAnimPreloaded;
public OnPlayerSpawn(playerid) {
    if(!actorAnimPreloaded) {
         ApplyAnimation(playerid, "INT_SHOP", "shop_lookA", 4.1, 1, 0, 0, 0, 0);
         ApplyAnimation(playerid, "COP_AMBIENT", "Coplook_loop", 4.1, 1, 0, 0, 0, 0);
         actorAnimPreloaded = 1;
         return 1;
     }

     return 1;
}



Re: Actor animation - SkullFire - 26.07.2015

Quote:
Originally Posted by Abagail
View Post
Well if this code
pawn Code:
ActorMercadoN = CreateActor(162, 2355.0710,-648.2926,128.0547,91.2342);
    PreloadActorAnimations(ActorMercadoN);
    ActorNinho = CreateActor(33, 2686.4758,-1425.5580,16.2500,194.1172);
    PreloadActorAnimations(ActorNinho);


    ApplyActorAnimation(ActorMercadoN, "INT_SHOP", "shop_lookA", 4.1, 1, 0, 0, 0, 0);
    ApplyActorAnimation(ActorNinho, "COP_AMBIENT", "Coplook_loop", 4.1, 1, 0, 0, 0, 0);
Is in OnGameModeInit, your not doing it right because not all players are near and NO players are even connected at the time the callback is called. Try doing something such as this:

pawn Code:
new actorAnimPreloaded;
public OnPlayerSpawn(playerid) {
    if(!actorAnimPreloaded) {
         ApplyAnimation(playerid, "INT_SHOP", "shop_lookA", 4.1, 1, 0, 0, 0, 0);
         ApplyAnimation(playerid, "COP_AMBIENT", "Coplook_loop", 4.1, 1, 0, 0, 0, 0);
         actorAnimPreloaded = 1;
         return 1;
     }

     return 1;
}
Why ApplyAnimation in myself ?


Re: Actor animation - Onfroi - 26.07.2015

Quote:
Originally Posted by SkullFire
View Post
Why ApplyAnimation in myself ?
You don't have to preload the animations. Look at https://sampwiki.blast.hk/wiki/ApplyActorAnimation