SA-MP Forums Archive
OnPlayerAnimationEnd(); based on animation length - 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: OnPlayerAnimationEnd(); based on animation length (/showthread.php?tid=569456)



OnPlayerAnimationEnd(); based on animation length - SerejaN - 30.03.2015

Hello guys, i have a little question. Is it possible to dump all animations length from game archives to an array for best animation time accuracy and future using it in custom function "ApplyAnimationEx();" (for example), that triggers custom callback "OnPlayerAnimationEnd", after animation end?

Sorry for my bad English. I hope you undestand me :3


AW: OnPlayerAnimationEnd(); based on animation length - Kaliber - 30.03.2015

Quote:
Originally Posted by SerejaN
Посмотреть сообщение
Sorry for my bad English. I hope you undestand me :3
You can do this easily:

PHP код:
new bool:aCheck[MAX_PLAYERS char],aIDX[MAX_PLAYERS];
//Under OnPlayerUpdate
switch(aCheck{playerid}) {
    case 
true: {
        if(!
GetPlayerAnimationIndex(playerid)) OnPlayerAnimationEnd(playerid,aIDX[playerid]),aCheck{playerid}=false;
    }
    case 
false: {
        if(
GetPlayerAnimationIndex(playerid)) {
            
aCheck{playerid} = true;
            
aIDX[playerid] = GetPlayerAnimationIndex(playerid);
        }
    }
}
//In the Script:
stock OnPlayerAnimationEnd(playerididx)
{
    new 
animlib[32],animname[32],msg[128];
    
GetAnimationName(idx,animlib,32,animname,32);
    
format(msg128"Anim ended: %s %s"animlibanimname);
    
SendClientMessage(playerid0xFFFFFFFFmsg);
    return 
1;

If you don't like OnPlayerUpdate, use a timer..with ~150ms