Need help
#1

I have a script that decreases player health when 'Fire Power Lvl 1 Boost' is turned on but instead of boosting it resets the player health to 100 every time I shoot an enemy, it's like I have an error in my script and they cannot run it so they just set the guy's health to 100 but Pawno doesn't throw an error.

This is the extracted code from my gamemode script that is related to the Fire Power Boost(JUST FOR YOUR INFO, THE PERSON I SHOT HAVE MORE THAN 200 LIFE AND FULL AMOUR. When I shot him his amour decreases and when his amour finishes, his life decreases. When I saw that person's life it was already 100, I don't know was my shotgun too powerful or the script reset-ed his health to 100)
pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
    if(GetPVarInt(issuerid, "In Use Fire Power Boost LVL 1") == 1 && GetPlayerTeam(playerid) != 0 && GetPlayerTeam(issuerid) == 0)
    {
        new Float:PlayerHealth;
        GetPlayerHealth(playerid, PlayerHealth);
        PlayerHealth = PlayerHealth-(10/100*amount);
        SetPlayerHealth(playerid, PlayerHealth);
    }
}
I also have a defense boost thingy that uses the same way to increase/decrease player health, I have not tested it but I believe it has the same problem too since it's using the same structure but instead of subtracting, it plus-es

Apart from that I used to have a regeneration script that has the same error, I couldn't solve the problem so I commented all the codes that are related to the regeneration script but the script is still in my gamemode
pawn Код:
new BossHealTimer;
new BossHealInitiate;
new HealTimer;
new HealInitiate;



forward BossHeal(playerid);
forward Heal(playerid);



public BossHeal(playerid)
{
    BossHealInitiate = 1;
    new Float:BossZMHP;
    GetPlayerHealth(playerid, BossZMHP);
    if(BossZMHP == 0)
    {
    BossHealInitiate = 0;
    KillTimer(BossHealTimer);
    }

    if(BossZMHP < 200 && GetPlayerSkin(playerid) == 264 && GetPlayerTeam(playerid) == 1 && BossHealInitiate == 1)
    {
    BossHealInitiate = 1;
    SetPlayerHealth(playerid, BossZMHP+10);
    }

    if(BossZMHP >= 200 && GetPlayerSkin(playerid) == 264 && GetPlayerTeam(playerid) == 1)
    {
    SetPlayerHealth(playerid, 200);
    BossHealInitiate = 0;
    KillTimer(BossHealTimer);
    }
}

public Heal(playerid)
{
    HealInitiate = 1;
    new Float:HP;
    GetPlayerHealth(playerid,HP);
    if(HP == 0)
    {
    HealInitiate = 0;
    KillTimer(HealTimer);
    }
   
    new MaxHP = GetPVarInt(playerid, "MaxHP");
    if(HP < MaxHP && GetPlayerTeam(playerid) == 1 && HealInitiate == 1)
    {
    HealInitiate = 1;
    SetPlayerHealth(playerid,HP+5);
    }

    if(HP > MaxHP && GetPlayerTeam(playerid) == 1)
    {
    SetPlayerHealth(playerid, MaxHP);
    HealInitiate = 0;
    KillTimer(HealTimer);
    }
}
This regen script is triggered when someone's is attacked(OnPlayerTakeDamage), the problem I have with this regen script is the person which is regenerating just dies after enemy attacks him once. As you can see all my setplayerhealth is triggered when a person's health is changed, is it possible that my script crashes with it? Maybe because of my mathematical formula which includes equation among floats and variables?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)