SA-MP Forums Archive
Injury system, not working, OnPlayerTakeDamage. - 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: Injury system, not working, OnPlayerTakeDamage. (/showthread.php?tid=617104)



Injury system, not working, OnPlayerTakeDamage. - Dokins - 15.09.2016

Nothing happens until the player reaches 0 hp.
pawn Код:
if(LoggedIn[playerid] == 1 && Health <= 35 && KnockedOut[playerid] == 0 && GetPlayerState(playerid) != 9)
    {
        if(IsPlayerInAnyVehicle(playerid))
        {
            RemovePlayerFromVehicle(playerid);
            ApplyAnimation(playerid, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0,1);
            TogglePlayerControllable(playerid, 0);
        }
            KnockedOut[playerid] = 1;
        TogglePlayerControllable(playerid, 0);
            ApplyAnimation(playerid, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0,1);
        SendClientMessage(playerid, COLOUR_REALRED, "You have been knocked out, unless someone revives you, you may die.");
        format(string, sizeof(string), "* %s has lost consciousness due to their injuries *", GetNameEx(playerid));
        ProxDetector(30.0, playerid, string, COLOUR_PURPLE, COLOUR_PURPLE, COLOUR_PURPLE, COLOUR_PURPLE, COLOUR_PURPLE);
        return 1;
    }
Under OnPlayerTakeDamage.


Re: Injury system, not working, OnPlayerTakeDamage. - GoldenLion - 15.09.2016

What about OnPlayerUpdate? Also if you get player's health under OnPlayerTakeDamage, then it will get the health before the default damage will be applied so it will only work right now if you are below 35 health and get shot from a weapon with a low damage.


Re: Injury system, not working, OnPlayerTakeDamage. - Dokins - 15.09.2016

Going to revert to OnPlayerUpdate.


Re: Injury system, not working, OnPlayerTakeDamage. - Shinja - 15.09.2016

Very bad idea
PHP код:
Health -= amout;
if(
LoggedIn[playerid] == && Health <= 35 && KnockedOut[playerid] == && GetPlayerState(playerid) != 9)
    {
        if(
IsPlayerInAnyVehicle(playerid))
        {
            
RemovePlayerFromVehicle(playerid);
              
ApplyAnimation(playerid"CRACK""crckdeth2"4.010000,1);
              
TogglePlayerControllable(playerid0);
        }
            
KnockedOut[playerid] = 1;
        
TogglePlayerControllable(playerid0);
            
ApplyAnimation(playerid"CRACK""crckdeth2"4.010000,1);
        
SendClientMessage(playeridCOLOUR_REALRED"You have been knocked out, unless someone revives you, you may die.");
        
format(stringsizeof(string), "* %s has lost consciousness due to their injuries *"GetNameEx(playerid));
        
ProxDetector(30.0playeridstringCOLOUR_PURPLECOLOUR_PURPLECOLOUR_PURPLECOLOUR_PURPLECOLOUR_PURPLE);
        return 
1;
    }