animation loop
#1

How can I stop looping the animation on OnPlayerUpdate(playerid). Animation repeat constantly...

Код:
new Float:Health;
    GetPlayerHealth(playerid, Health);
    if (Health <= 20.0)
    {
        LOWHP[playerid] = 0;
        if(LOWHP[playerid] == 0)
		{
	 		ApplyAnimation(playerid, "KNIFE", "KILL_Knife_Ped_Die",9.1,0,1,1,1,1);
	 		LOWHP[playerid] = 1;
	 		return 1;
		}
		if(LOWHP[playerid] == 1)
		{
		    return 1;
  		}
	}
Reply
#2

anyone?
Reply
#3

Код:
while(LOWHP[playerid] == 0){
     ApplyAnimation(playerid, "KNIFE", "KILL_Knife_Ped_Die",9.1,0,1,1,1,1);
}
Reply
#4

Just remove the first

LOWHP[playerid] = 0;


You force it to become 0 everytime OnPlayerUpdate is called, and therefore it to execute the animation.
After the animation, you set it to 1, which is ok, but the next time it's forced back to 0 again, running the animation again.

You can also remove the second if-statement because it's never executed.
If the LOWHP is 0, you execute the first if-statement and exit the callback using the "return 1;".
pawn Код:
new Float:Health;
    GetPlayerHealth(playerid, Health);
    if (Health <= 20.0)
    {
        if(LOWHP[playerid] == 0)
        {
            ApplyAnimation(playerid, "KNIFE", "KILL_Knife_Ped_Die",9.1,0,1,1,1,1);
            LOWHP[playerid] = 1;
        }
    }
    else
        LOWHP[playerid] = 0;

    return 1;
This should work.
Reply
#5

Quote:
Originally Posted by PowerPC603
Посмотреть сообщение
Just remove the first

LOWHP[playerid] = 0;


You force it to become 0 everytime OnPlayerUpdate is called, and therefore it to execute the animation.
After the animation, you set it to 1, which is ok, but the next time it's forced back to 0 again, running the animation again.

You can also remove the second if-statement because it's never executed.
If the LOWHP is 0, you execute the first if-statement and exit the callback using the "return 1;".
pawn Код:
new Float:Health;
    GetPlayerHealth(playerid, Health);
    if (Health <= 20.0)
    {
        if(LOWHP[playerid] == 0)
        {
            ApplyAnimation(playerid, "KNIFE", "KILL_Knife_Ped_Die",9.1,0,1,1,1,1);
            LOWHP[playerid] = 1;
        }
    }
    else
        LOWHP[playerid] = 0;

    return 1;
This should work.
Working! REP+ and thank you.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)