SA-MP Forums Archive
Help me fix injured system - 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: Help me fix injured system (/showthread.php?tid=649123)



Help me fix injured system - Dirda - 03.02.2018

The Injured system in my server is to prevent a player respawning after they die (I meant, respawning in his death place and cant move)

And the problem is, how to make the player invulnerable, so they don't get to the hospital when they got shot/hurt while the player is injured?

Please help me edit this OnPlayerTakeDamage
PHP код:
public OnPlayerTakeDamage(playeridissueridFloat:amountweaponidbodypart)
{
    if(
bodypart == 3PlayerInfo[playerid][pBodyStatus][0] -= frandom(1.0);
    if(
bodypart == 4PlayerInfo[playerid][pBodyStatus][1] -= frandom(1.0);
    if(
bodypart == 5PlayerInfo[playerid][pBodyStatus][3] -= frandom(1.0);
    if(
bodypart == 6PlayerInfo[playerid][pBodyStatus][2] -= frandom(1.0);
    if(
bodypart == 7PlayerInfo[playerid][pBodyStatus][5] -= frandom(1.0);
    if(
bodypart == 8PlayerInfo[playerid][pBodyStatus][4] -= frandom(1.0);
    
ShowBloodScreen(playeridamount);
    new 
status[64], Float:healthFloat:armorstring[128];
    
GetPlayerHealth(playeridhealth);
    
GetPlayerArmour(playeridarmor);
    
format(statussizeof(status), "Stranger_%d\n{ff0000}H: %.1f\n{ffffff}A: %.1f"RandMask[playerid], healtharmor);
    
UpdateDynamic3DTextLabelText(MaskText[playerid], 0xFFFFFFFFstatus);
    if(
issuerid != INVALID_PLAYER_ID && weaponid == 31 && bodypart == 9)
    {
        if(!
PlayerInfo[playerid][pHS])
        {
            
PlayerInfo[playerid][pHS] = 1;
            
ProxDetector(30.0playeridstringCOLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
            
SetTimerEx("KillPlayer",2000,0,"i",playerid);
        }
    }
    if(
issuerid != INVALID_PLAYER_ID && weaponid == 34 && bodypart == 9)
    {
        if(!
PlayerInfo[playerid][pHS])
        {
            
PlayerInfo[playerid][pHS] = 1;
            
ProxDetector(30.0playeridstringCOLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
            
SetTimerEx("KillPlayer",2000,0,"i",playerid);
        }
    }
    if(
issuerid != INVALID_PLAYER_ID && weaponid == 24 && bodypart == 9)
    {
        if(!
PlayerInfo[playerid][pHS])
        {
            
PlayerInfo[playerid][pHS] = 1;
            
ProxDetector(30.0playeridstringCOLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
            
SetTimerEx("KillPlayer",2000,0,"i",playerid);
        }
    }
    if(
issuerid != INVALID_PLAYER_ID && weaponid == 30 && bodypart == 9)
    {
        if(!
PlayerInfo[playerid][pHS])
        {
            
PlayerInfo[playerid][pHS] = 1;
            
ProxDetector(30.0playeridstringCOLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
            
SetTimerEx("KillPlayer",2000,0,"i",playerid);
        }
    }
    if(
issuerid != INVALID_PLAYER_ID && weaponid == 25 && bodypart == 9)
    {
        if(!
PlayerInfo[playerid][pHS])
        {
            
PlayerInfo[playerid][pHS] = 1;
            
ProxDetector(30.0playeridstringCOLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
            
SetTimerEx("KillPlayer",2000,0,"i",playerid);
        }
    }
    if(
issuerid != INVALID_PLAYER_ID && weaponid == 27 && bodypart == 9)
    {
        if(!
PlayerInfo[playerid][pHS])
        {
            
PlayerInfo[playerid][pHS] = 1;
            
ProxDetector(30.0playeridstringCOLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
            
SetTimerEx("KillPlayer",2000,0,"i",playerid);
        }
    }
    if(
issuerid != INVALID_PLAYER_ID && bodypart == 7)
    {
        if(!
PlayerInfo[playerid][pLLS])
        {
            
PlayerInfo[playerid][pLLS] = 1;
            
ProxDetector(30.0playeridstringCOLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
            
ApplyAnimation(playerid,"CRACK""crckdeth2"4.11001600);
        }
    }
    if(
issuerid != INVALID_PLAYER_ID && bodypart == 8)
    {
        if(!
PlayerInfo[playerid][pRLS])
        {
            
PlayerInfo[playerid][pRLS] = 1;
            
ProxDetector(30.0playeridstringCOLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
            
ApplyAnimation(playerid,"CRACK""crckdeth2"4.11001600);
        }
    }
    if(
issuerid != INVALID_PLAYER_ID && bodypart == 5)
    {
        if(!
PlayerInfo[playerid][pLAS])
        {
            
PlayerInfo[playerid][pLAS] = 1;
            
ProxDetector(30.0playeridstringCOLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
        }
    }
    if(
issuerid != INVALID_PLAYER_ID && bodypart == 6)
    {
        if(!
PlayerInfo[playerid][pRAS])
        {
            
PlayerInfo[playerid][pRAS] = 1;
            
ProxDetector(30.0playeridstringCOLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
        }
    }
    if(
issuerid != INVALID_PLAYER_ID && bodypart == 4)
    {
        if(!
PlayerInfo[playerid][pCS])
        {
            if(
health 15)
            {
                
PlayerInfo[playerid][pCS] = 1;
                
ProxDetector(30.0playeridstringCOLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                
SetTimerEx("KillPlayer",3000,0,"i",playerid);
            }
        }
    }
    if(
issuerid != INVALID_PLAYER_ID && bodypart == 3)
    {
        if(!
PlayerInfo[playerid][pTS])
        {
            if(
health 15)
            {
                
PlayerInfo[playerid][pTS] = 1;
                
ProxDetector(30.0playeridstringCOLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                
SetTimerEx("KillPlayer",3000,0,"i",playerid);
                }
                if(
GetPlayerState(playerid) == PLAYER_STATE_ONFOOT && GetPVarInt(playerid"Injured") == 1)
        {
        
SetPlayerHealth(playerid19.0);
            }
        }
    }
    return 
1;

In the end:
PHP код:
                if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT && GetPVarInt(playerid"Injured") == 1)
        {
        
SetPlayerHealth(playerid19.0);
            }
        }
    }
    return 
1
I don't know why it doesn't work.

Or is there any setplayerhealth, that gives god mode but on the screen, player doesn't see full health, but they see no health.


Re: Help me fix injured system - Mugala - 03.02.2018

u can make it in 2 way, first is to toggleplayercontrollable, wich also gives him a god mode.
and second one, you can give a player exactly amount what he took as a damage.

OnPlayerTakeDamage
PHP код:
new Float:HP;
GetPlayerHealth(playerid,HP);
SetPlayerHealth(playerid,HP+amount); 
if u havn't make a respawn (in a death location) yet, just reply and I'll make an example.


Re: Help me fix injured system - Dirda - 03.02.2018

Quote:
Originally Posted by Mugalito
Посмотреть сообщение
u can make it in 2 way, first is to toggleplayercontrollable, wich also gives him a god mode.
and second one, you can give a player exactly amount what he took as a damage.

OnPlayerTakeDamage
PHP код:
new Float:HP;
GetPlayerHealth(playerid,HP);
SetPlayerHealth(playerid,HP+amount); 
if u havn't make a respawn (in a death location) yet, just reply and I'll make an example.
I knew it but i don't know where to put it.

WAIT, AIN'T YOU THE SAME PERSON WHO HELPED ME TO FIX THE PROBLEMS IN MY OTHER THREADS? WHOA!


Re: Help me fix injured system - Dirda - 03.02.2018

No, not command.
All i want is to prevent the injured player from taking damage.


Re: Help me fix injured system - Mugala - 03.02.2018

Quote:
Originally Posted by Dirda
Посмотреть сообщение
I knew it but i don't know where to put it.

WAIT, AIN'T YOU THE SAME PERSON WHO HELPED ME TO FIX THE PROBLEMS IN MY OTHER THREADS? WHOA!
yeah xD

place this code like this

PHP код:
public OnPlayerTakeDamage(playeridissueridFloatamountweaponidbodypart)
{
    
// we need this code at the top of the callback OnPlayerTakeDamage.
    
if(Death[playerid] == 1//u must place your death script here, for example let it be Death[playerid];
    
{
        new 
Float:HP
        
GetPlayerHealth(playerid,HP); 
        
SetPlayerHealth(playerid,HP+amount);  
        return 
1;
    } 



Re: Help me fix injured system - Abagail - 03.02.2018

If you don't need to use teams elsewhere, you can have everyone on the same team always. This prevents most player-to-player damage and iirc OnPlayerTakeDamage is still called. You'd have to set health/armor on your own though using (SetPlayerHealth/Armour) when taking damage.

FLOAT_INFINITY also could work as mentioned, is essentially unlimited health, although this means you can't use GetPlayerHealth on wounded players.