[Ajuda] settimer
#1

Estou com uma duvida em um sistema q estou fazendo, coloquei um settimer de 1s para verificar se a vida do player estб a baixo de uma % se estiver й aplicado uma animaзгo, atй ai tudo bem, porйm a animaзгo fica se repetindo e quando eu coloco um KillTimer ele nгo executa a animaзгo, se alguйm souber uma forma pra que isso nгo ocorra ficarei grato <3
Reply
#2


"Me mostrar o cуdigo vocк deve"
Reply
#3

Quote:
Originally Posted by Ermanhaut
Посмотреть сообщение

"Me mostrar o cуdigo vocк deve"
PHP код:
TimerVida SetTimer("CheckVida",1000,true);
KillVida 1
forward CheckVida
(playerid);
public 
CheckVida(playerid)
{
    new 
Float:vida;
    
GetPlayerHealth(playeridvida);
    if(
KillVida == 1)
    {
        if(
vida <= 100.0)
        {
             
ApplyAnimation(playerid"PED""KO_shot_stom",5.0,1,0,0,0,0);
             
KillTimer(TimerVida);
        }
    }
    return 
1;

Reply
#4

PHP код:
SetTimer("CheckVida"1000false); 
KillVida 

forward CheckVida
(playerid); 
public 
CheckVida(playerid

    new 
Float:vida
    
GetPlayerHealth(playeridvida); 

    if(
KillVida == 1
    { 
        if(
vida <= 100.0
        { 
             
ApplyAnimation(playerid"PED""KO_shot_stom",5.0,1,0,0,0,0); 
        } 
    } 
    return 
1

assim?
Reply
#5

Quando o timer й chamado?
Reply
#6

Quote:
Originally Posted by AutoMatic2
Посмотреть сообщение
PHP код:
SetTimer("CheckVida"1000false); 
KillVida 
forward CheckVida
(playerid); 
public 
CheckVida(playerid

    new 
Float:vida
    
GetPlayerHealth(playeridvida); 
    if(
KillVida == 1
    { 
        if(
vida <= 100.0
        { 
             
ApplyAnimation(playerid"PED""KO_shot_stom",5.0,1,0,0,0,0); 
        } 
    } 
    return 
1

assim?
Se o timer nгo se repetir ele vai checar apenas uma vez se a vida do player й aquela
Reply
#7

Quote:
Originally Posted by Ermanhaut
Посмотреть сообщение
Quando o timer й chamado?
OnPlayerSpawn
Reply
#8

Acho que assim vai funcionar do jeito que vocк quer:
Код:
public OnPlayerGiveDamage(playerid, damagedid, Float:amount, weaponid, bodypart){

	new Float:targethp;
	GetPlayerHealth(damagedid, targethp);
	if(amount > targethp) SetPlayerHealth(damagedid, 1.0);
	if(targethp == 1.0){

		ApplyAnimation(playerid, "PED", "KO_shot_stom",5.0,1,0,0,0,0);
                /*Variбvel que diz que o player estб incapacitado*/ = true;
	}
	
	return 1;
}
Reply
#9

Quote:
Originally Posted by Ermanhaut
Посмотреть сообщение
Acho que assim vai funcionar do jeito que vocк quer:
Код:
public OnPlayerGiveDamage(playerid, damagedid, Float:amount, weaponid, bodypart){

	new Float:targethp;
	GetPlayerHealth(damagedid, targethp);
	if(amount > targethp) SetPlayerHealth(damagedid, 1.0);
	if(targethp == 1.0){

		ApplyAnimation(playerid, "PED", "KO_shot_stom",5.0,1,0,0,0,0);
                /*Variбvel que diz que o player estб incapacitado*/ = true;
	}
	
	return 1;
}
Vai funcionar com qualquer tipo de dano certo ?
Reply
#10

Quote:
Originally Posted by iWiNeR
Посмотреть сообщение
Vai funcionar com qualquer tipo de dano certo ?
Na verdade este callback sу й chamado quando o dano й de jogador para jogador.

Use o OnPlayerTakeDamage que funciona para todos os danos.

pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart) {

    new Float:targethp;
    GetPlayerHealth(playerid, targethp);
    if(targethp < 100.0){

        ApplyAnimation(playerid, "PED", "KO_shot_stom",5.0,1,0,0,0,0);
                /*Variбvel que diz que o player estб incapacitado*/
    }

    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)