SA-MP Forums Archive
Onplayerdeath - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Onplayerdeath (/showthread.php?tid=244828)



Onplayerdeath - Bam23 - 28.03.2011

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..


Re: Onplayerdeath - Skylar Paul - 28.03.2011

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;
}



Re: Onplayerdeath - WackoX - 28.03.2011

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?


Re: Onplayerdeath - Skylar Paul - 28.03.2011

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


Re: Onplayerdeath - airsoft - 28.03.2011

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


Re: Onplayerdeath - gamer931215 - 28.03.2011

@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).


Re: Onplayerdeath - airsoft - 29.03.2011

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