Custom Health System bug[Rep+]
#1

Hello, well I've got a pretty weird bug here. Or 2 actually... My script:
pawn Code:
new Float:pHP[MAX_PLAYERS], bool:test, KillerID[MAX_PLAYERS], WeapID[MAX_PLAYERS];

public OnPlayerSpawn(playerid)
{
    pHP[playerid] = 100;
    test = true;
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    SendDeathMessage(KillerID[playerid], playerid, WeapID[playerid]);
    return 1;
}

public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid)
{
    if (test == true)
    {
        pHP[damagedid]-=amount;
        if (pHP[damagedid] < 1)
        {
            KillerID[damagedid] = playerid;
            WeapID[damagedid] = weaponid;
            SetPlayerHealth(damagedid, 0);
        }
        else
        {
            SetPlayerHealth(damagedid, pHP[damagedid]);
        }
        test = false;
    }
    else
    {
        test = true;
    }
    return 1;
}
Here are the two issues: 1st - With some weapons, like the desert eagle, OnPlayerGiveDamage gets called 2 times (That's what the variable "test" is used for, but it looks like it doesn't fix it). And 2nd - Some low-damage weapons (like fists, dual UZIs, flowers etc.) are actually GIVING the attacked player HP, not taking it from him... Please help if you've got any ideas on how to fix this script.
Reply


Messages In This Thread
Custom Health System bug[Rep+] - by KingHual - 10.02.2012, 10:03
Re: Custom Health System bug[Rep+] - by IceCube! - 10.02.2012, 10:22
Re: Custom Health System bug[Rep+] - by MP2 - 10.02.2012, 10:24
Re: Custom Health System bug[Rep+] - by KingHual - 10.02.2012, 10:28
Re: Custom Health System bug[Rep+] - by MP2 - 10.02.2012, 10:31
Re: Custom Health System bug[Rep+] - by KingHual - 10.02.2012, 10:32
Re: Custom Health System bug[Rep+] - by MP2 - 10.02.2012, 10:35
Re: Custom Health System bug[Rep+] - by KingHual - 10.02.2012, 10:37
Re: Custom Health System bug[Rep+] - by IceCube! - 10.02.2012, 10:38

Forum Jump:


Users browsing this thread: 1 Guest(s)