open.mp forum
[Pawn] [Solved] GetAnimationName() is not working properly - 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] [Solved] GetAnimationName() is not working properly (/showthread.php?tid=1800)



[Solved] GetAnimationName() is not working properly - Radical - 2021-03-23

SOLUTION:

Store that animation lib and name in a variable.

e.g. :

Code:
new rAnimLib[MAX_PLAYERS][20];

new rAnimName[MAX_PLAYERS][20];



COMMAND:anim(playerid, params[]) {

? ? ApplyAnimation(playerid, "PED", "IDLE_STANCE", 4.1, 0, 0, 0, 0, 0);

? ? rAnimLib[playerid] = "PED";

? ??rAnimName[playerid] = "IDLE_STANCE";

? ? return 1;

}



GetAnimationNameEx(playerid, Lib[20], Name[20])

{

? ? Lib = rAnimLib[playerid];

? ? Name = rAnimName[playerid];

}

//use this method instead of GetAnimationName.





I use GetAnimationName() function but it only returns PED, IDLE_STANCE or PED,SEAT_IDLE or PED,WOMAN_IDLESTANCE.



When i apply another animations like /eat, /sit, /lay

this function not give me the applied animation animlib and animname but just return PED, IDLE_STANCE.



PHP Code:
ApplyAnimation(playerid,"BEACH","Lay_Bac_Loop",4.1011111); // Sit

ApplyAnimation(playerid,"BEACH""bather",4.1011111); // Lay down



CMD:anim(playerid) {

? ? if(
GetPlayerAnimationIndex(playerid))

{

? ? new 
animlib[32];

? ? new 
animname[32];

? ? new 
msg[128];? ? 

? ? 
GetAnimationName(GetPlayerAnimationIndex(playerid),animlib,32,animname,32);

? ? 
format(msg128"Running anim: %s %s"animlibanimname);

? ? 
SendClientMessage(playerid, -1msg); // output is: PED IDLE_STANCE

}

? ? return 
1;





In other gamemodes that I test, this problem does not occur.



I need to fix this problem quickly.

thanks for the anyone answer.


RE: GetAnimationName() is not working properly - Radical - 2021-03-24

Bump



Does the lagcomp 0 have an effect on this function?


RE: GetAnimationName() is not working properly - DandoRYx - 2021-03-24

Changing the time value fixed this.
I changed it to 4000:
PHP Code:
ApplyAnimation(playerid,"BEACH","Lay_Bac_Loop"4.1011140001); 

The only issue is that you can't exit the animation until 4 seconds (4000 ms) pass.

EDIT: After those 4 seconds, GetAnimationName gives PED, IDLE_STANCE so this won't help you much.
You can lock a player and then check if he pressed ENTER and cancel the animation or something like that.