14.12.2010, 17:39
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:
Or easier: An optional param to the animation.
Would be really useful if this was added and i think a lot of players will use it.
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;
}
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;
}