#1

How to make death animation with Timer. i mean.. When the player has a lower health like -5 percent he will do an animation for 5 seconds with the timer then when the timer ended the player health will be 0 then he dies.
Can anyone show me Code to do this?
Reply
#2

Try this:

PHP код:
public OnPlayerDeath(playeridkilleridreason)
{
ApplyAnimation(playerid,"ANIMATION_KIND""ANIMATIONNAME",4.0,1,1,1,1,1);
return 
1;

Reply
#3

I think the lowest health you can have is 0.0.
If you mean 5.0 rather than -5 then you should first create a global timer which loops through all the players and checks their health. You also need to have a variable for all players to check if the animation already started.
That variable needs to be set to false when a player connects.

PHP код:
new bool:AnimationBegan[MAX_PLAYERS];
public 
OnGameModeInit(){
    
SetTimer("globalTimer",1000,true);
}
public 
OnPlayerConnected(playerid){
    
AnimationBegan[playerid] = false;
}
forward animationDeathTimer(playerid);
public 
animationDeathTimer(playerid){
    
//clear animations
    
ClearAnimations(playerid);
    
//and put player's health to 0
    
SetPlayerHealth(playerid,0.0);
    
//Also clear AnimationBegan variable
    
AnimationBegan[playerid] = false;
    return 
1;
}
forward globalTimer();
public 
globalTimer(){
    for(new 
0;i<MAX_PLAYERS;i++){
    
        if(!
IsPlayerConnected(i))continue;
        
        new 
Float:cHealth;
        
GetPlayerHealth(i,cHealth);
        
        if(
AnimationBegan[i] == false && cHealth <= 5.0){
            
AnimationBegan[i] = true;
            
//I guess thats the proper animation:
            
ApplyAnimation(i"CRACK""crckdeth2"4.010000);
            
//and set the timer to stop the animation
            
SetTimerEx("animationDeathTimer",5*1000,false);
        }
    }
    return 
1;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)