Onplayerdeath
#1

Able to make it so when your health reaches 20 you do /crack automaticly and cant get up from animation?

I have a function
TogglePlayerControllable(i, 1);

And when your health reaches 20 it does

GameTextForPlayer(i, "Say /acceptdeath if you want to die. Do /service ems if you want the EMS", 2500, 3);

Onplayerhealthreach something idk lol..

Thank you..
Reply
#2

pawn Код:
public OnPlayerUpdate(playerid)
{
    new Float:player_Health;
    GetPlayerHealth(playerid, player_Health);
    if(player_Health <= 20)
    {
        ApplyAnimation(// You're going to need to place the animation here.
        GameTextForPlayer(playerid, "Say /acceptdeath if you want to die. Do /service ems if you want the EMS", 2500, 3);
        TogglePlayerControllable(playerid, 0);
    }
    return 1;
}
Reply
#3

Quote:
Originally Posted by Skylar Paul
Посмотреть сообщение
pawn Код:
public OnPlayerUpdate(playerid)
{
    new Float:player_Health;
    GetPlayerHealth(playerid, player_Health);
    if(player_Health <= 20)
    {
        ApplyAnimation(// You're going to need to place the animation here.
        GameTextForPlayer(playerid, "Say /acceptdeath if you want to die. Do /service ems if you want the EMS", 2500, 3);
        TogglePlayerControllable(playerid, 0);
    }
    return 1;
}
Do you like spam?
Reply
#4

Quote:
Originally Posted by WackoX
Посмотреть сообщение
Do you like spam?
Yeah, my bad. Haven't coded in a while...
Reply
#5

you would put a time on OnPlayerUpdate and set it for however much time and then check their health

E.x.
pawn Код:
//On Top Of Script
forward HealthCheck();

//Player Update
public OnPlayerUpdate(playerid)
{
SetTimer("HealthCheck",2000,true);
return 1;
}

//Lower Down In Script
public HealthCheck()
{
    new Float:PlayerHealth;
    for(new i=0; i<MAX_PLAYERS;i++)
    {
        GetPlayerHealth(i,PlayerHealth);
        if(PlayerHealth <= 20)
        {
        GameTextForPlayer(i, "Say /acceptdeath if you want to die. Do /service ems if you want the EMS", 2500, 3);
        TogglePlayerControllable(i,1);
        ApplyAnimation(i,CRACK,crckdeth1,3,1,1,1,0,0);
        }
     }
return 1;
}
I might of gotten the animation wrong but lol you can fix that

>:~D its better with timer
Reply
#6

@airsoft

pawn Код:
//Player Update
public OnPlayerUpdate(playerid)
{
SetTimer("HealthCheck",2000,true);
return 1;
}
Should be on

pawn Код:
OnGameModeInit()
{
    SetTimer("HealthCheck",2000,true);
    return 0;
}
You only need to set the timer once (not even per player, because it does already have a loop), and OnPlayerUpdate is called hundreds of timers per second which means an overkill of timers (aka crashes or HUUUUUGE lag).
Reply
#7

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

pawn Код:
//Player Update
public OnPlayerUpdate(playerid)
{
SetTimer("HealthCheck",2000,true);
return 1;
}
Should be on

pawn Код:
OnGameModeInit()
{
    SetTimer("HealthCheck",2000,true);
    return 0;
}
You only need to set the timer once (not even per player, because it does already have a loop), and OnPlayerUpdate is called hundreds of timers per second which means an overkill of timers (aka crashes or HUUUUUGE lag).
Lol i fail...

I f o r g o t t h a t
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)