Anti-lag shoot KILL
#1

I have this code, that really works it's awesome, but I have a problem with it. It uses SetPlayerHealth, so sometimes when a player kills a player, in the death message it's saying that he commited a suicide (because when you set a players health to 0 with SetPlayerHealth, that message comes up).

Code:
pawn Код:
public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid)
{
    if(damagedid != INVALID_PLAYER_ID)
    {
        if(gTeam[playerid] != gTeam[damagedid])
        {
            new Float:HEALTH;
            new Float:ARMOR;
            new Float:DAMAGE;
           
            GetPlayerArmour(damagedid, ARMOR);
            GetPlayerHealth(damagedid, HEALTH);
           
            if(ARMOR > 0)
            {
                if(amount > ARMOR)
                {
                    ARMOR = 0;
                    SetPlayerArmour(damagedid, 0.0);
                    SetPlayerHealth(damagedid, HEALTH);
                    return 1;
                }
                else
                {
                    DAMAGE = ARMOR-amount;
                    SetPlayerArmour(damagedid, DAMAGE);
                    SetPlayerHealth(damagedid, HEALTH);
                }
            }
           
            if(ARMOR < 1)
            {
                HEALTH = HEALTH - amount;
                SetPlayerHealth(damagedid, HEALTH);
            }
        }
    }
    return 1;
}
So how to edit that code, when a player kills a player, it will send a death message that the player killed him, not the SetPlayerHealth (suicide) message.
Reply
#2

I would probably write it like that
pawn Код:
public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid) {
    if(damagedid != INVALID_PLAYER_ID) {
        if(gTeam[playerid] != gTeam[damagedid]) {
            new
                Float: health,
                Float: armour
            ;
            GetPlayerArmour(damagedid, armour);
            GetPlayerHealth(damagedid, health);

            if((armour -= amount) < 0.0) {
                health += armour;
            }
            if(0.0 < health) {
                SetPlayerArmour(damagedid, armour);
                SetPlayerHealth(damagedid, health);
            }
        }
    }
    return 1;
}
Reply
#3

I cant understand your code very well, I mean, what do these "-=", "+=" signs mean? If someone could give me a link to a wiki of these or something I'd be grateful.
Reply
#4

a += b is the same as a = a + b. Same for -=, *=, /=, etc.
Reply
#5

Actually what is the purpose of that script?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)