PlayerDeath
#1

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
Reply
#2

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

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;
}
Reply
#4

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;

Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)