Suggestion: OnAnimationFinish - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Suggestion: OnAnimationFinish (
/showthread.php?tid=199169)
Suggestion: OnAnimationFinish -
[NWA]Hannes - 14.12.2010
I think there should be a callback that gets when the players animation is done, so you dont have to use timers. (None-looping anims only.)
Example:
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp(cmdtext, "/startvending", true)==0)
{
ApplyAnimation(playerid, "VENDING", "VEND_Use", 4.0, 0, 0, 0, 0, 0);//The first vending anim
return 1;
}
return 0;
}
public OnAnimationFinish(playerid, animlib[], animname[])
{
if(animlib == "VENDING" && animname == "VEND_Use")//The first vending anim has finished
{
ApplyAnimation(playerid, "VENDING", "VEND_Use_pt2", 4.0, 0, 0, 0, 0, 0);//Start the second one directly after first one is done.
}
if(animlib == "VENDING" && animname == "VEND_Use_pt2")//The second vending anim has finished
{
ApplyAnimation(playerid, "VENDING", "VEND_Drink_P", 4.1, 0, 0, 0, 0, 0);//Start the third and last one directly after the second one is done.
}
if(animlib == "VENDING" && animname == "VEND_Drink_P")//The third vending anim has finished
{
GameTextForPlayer(playerid, "You have finished vending!", 3000, 4);
}
return 1;
}
Or easier: An optional param to the animation.
pawn Код:
new
Anim:Vending1,
Anim:Vending2,
Anim:Vending3;
public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp(cmdtext, "/startvending", true)==0)
{
Vending1 = ApplyAnimation(playerid, "VENDING", "VEND_Use", 4.0, 0, 0, 0, 0, 0);//The first vending anim
return 1;
}
return 0;
}
public OnAnimationFinish(playerid, animationid)
{
if(animationid == Vending1)//The first vending anim has finished
{
Vending2 = ApplyAnimation(playerid, "VENDING", "VEND_Use_pt2", 4.0, 0, 0, 0, 0, 0);//Start the second one directly after first one is done.
}
if(animationid == Vending2)//The second vending anim has finished
{
Vending3 = ApplyAnimation(playerid, "VENDING", "VEND_Drink_P", 4.1, 0, 0, 0, 0, 0);//Start the third and last one directly after the second one is done.
}
if(animationid == Vending3)//The third vending anim has finished
{
GameTextForPlayer(playerid, "You have finished vending!", 3000, 4);
}
return 1;
}
Would be really useful if this was added and i think a lot of players will use it.
Re: Suggestion: OnAnimationFinish -
XePloiT - 14.12.2010
its better if you put it in he 0.3c forum...