SA-MP Forums Archive
PlayerDeath - 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)
+--- Thread: PlayerDeath (/showthread.php?tid=411532)



PlayerDeath - Zex Tan - 29.01.2013

Can I see the example of the Player's Death . Like If the player gets shot and injured till they have 20 HP, drunk emotions will appear and if they will decrease HP for losing blood. Show me the example of scripting it... Thanks


Re: PlayerDeath - CBCandyBoy - 29.01.2013

man you can search it through filterscripts section i hope you will find one


Re: PlayerDeath - DaRk_RaiN - 29.01.2013

You can use the call back OnPlayerTakeDamage to detect if the player got shot, and for the drunk level use SetPlayerDrunkLevel
E.g:
pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
    if(issuerid != INVALID_PLAYER_ID)
    {
     if(GetPlayerHealth(playerid) <50)
     {
    SetPlayerDrunkLevel(playerid,50);
    }
     else if(GetPlayerHealth(playerid) <20)
     {
    SetPlayerDrunkLevel(playerid,150);
    }
    }
    return 1;
}



Re: PlayerDeath - Youice - 29.01.2013

Here is an another example using OnPlayerUpdate

PHP код:
new DeathTimer;
public 
OnPlayerUpdate(playerid)
{
    new 
Float:hp;
    
GetPlayerHealth(playeridhp);
    if(
hp 20)
    {
        
SetPlayerDrunkLevel(playerid2000);
        
DeathTimer SetTimerExx(playerid"LoseBlood"6000true);
    }
    else if(
hp <= 0)
    {
        
KillTimer(DeathTimer);
    }
    return 
1;
}
forward public LoseBlood(playerid);
public 
LoseBlood(playerid)
{
    new 
Float:hp;
    
GetPlayerHealth(playeridhp);
    
SetPlayerHealth(playeridhp -5);
    return 
1;
}
stock SetTimerExx(playeridfuncname[], intervalrepeating)
{
    
SetTimerEx(funcnameintervalrepeating"i"playerid);
    return 
1;