God mode during a certain mode
#1

So, when a players health is equal to or less than 25 and he takes damage - he will be put into Brutal M mode. Brutal M is the first stage of the death.

PHP код:
public OnPlayerDamage(&playerid, &Float:amount, &issuerid, &weapon, &bodypart)
{
       new 
DeathB;
    new 
DeathS[128];
    new 
Float:PlayerHealth;
    
GetPlayerHealth(playerid, PlayerHealth);
    if(
amount > PlayerHealth) {
    
SetPlayerHealth(playerid, 24);
    return 
0;
    }
    if (
PlayerHealth - amount <= 25)
    {
        if(
Character[playerid][BrutalM] == 0)
           {
            
GetPlayerPos(playerid, BMPos[playerid][0], BMPos[playerid][1], BMPos[playerid][2]);
            
Character[playerid][BrutalM] = 1;
            
Character[playerid][CanAccept] = 0;
            
LegHit[playerid] = 0;
            
format(DTextS, sizeof(DTextS), "(( %s is currently injured, type /damages %i for more info. ))", GetName(playerid), playerid);
            
label[playerid] = Create3DTextLabel(DTextS, COLOR_RED, BMPos[playerid][0], BMPos[playerid][1], BMPos[playerid][2], 10.0, 0);
            
Attach3DTextLabelToPlayer(label[playerid], playerid, 0, 0, 0.7); 
The second stage is dead mode, which when a player is in BrutalM mode and he takes damage again - he will go into Dead mode.
PHP код:
    if(Character[playerid][BrutalM] == 1)
            
GetPlayerPos(playerid, DPos2[playerid][0], DPos2[playerid][1], DPos2[playerid][2]);
            
Delete3DTextLabel(label[playerid]);
            
label2[playerid] = Create3DTextLabel("(( THIS PLAYER IS NOW DEAD ))", COLOR_RED, DPos2[playerid][0], DPos2[playerid][1], DPos2[playerid][2], 10.0, 0);
            
Attach3DTextLabelToPlayer(label2[playerid], playerid, 0, 0, 0.7);
            
Character[playerid][Dead] = 1;
            
Character[playerid][BrutalM] = 0;
            
SCM(playerid, COLOR_YELLOW, ">> You are now dead. You can use /respawnme after 60 seconds to respawn.");
            
Character[playerid][CanSpawn] = 0;
            
KillTimer(DeathT);
            
RespawnT = 60;
            
RespawnEx = SetTimer("RespawnTimer", 999, true);
            
RTimer = SetTimerEx("RespawnTimer2", 60000, false, "i", playerid);
    } 
The issue is, if a player is being shot at by an M4/AK (automatic weapons), when he goes into BrutalM mode he will instantly go into Dead mode due to the fact he is being sprayed at. I was wondering if it's possible to maybe add a timer, or even a way to prevent the player taking damage for about 5 seconds. Thanks in advanced.
Reply
#2

Yes, it's possible. When you set a player to brutally wounded, for example, do:
PHP код:
PlayerData[playerid][pExecuteTime] = 1;
public 
YOUR_TIMER_HERE
{
    foreach(new 
i : Player){
     if(
PlayerData[i][pExecuteTime]){
            
PlayerData[i][pExecuteTime]++;
            if(
PlayerData[i][pExecuteTime] == 5){
                
PlayerData[i][pExecuteTime] = 0;
            }
        }
    }
} 
Add to:
PHP код:
   if(Character[playerid][BrutalM] == 1 && !PlayerData[playerid][pExecuteTime]) 
Reply
#3

Can't seem to do that, anyone have any other ideas?
Reply
#4

http://forum.sa-mp.com/showpost.php?...98&postcount=2
I don't understand why are you creating 2 threads with almost exactly the same code,You don't learn huh?
Reply


Forum Jump:


Users browsing this thread: