From 809672d61a9ca98fbf1b7c30264c8ecfdebc5053 Mon Sep 17 00:00:00 2001 From: Fierelier Date: Tue, 17 Apr 2018 22:59:02 +0200 Subject: [PATCH] Revert "Broke af" This reverts commit 87cab524ee09733175295fbb013483d44e641785. --- paydayHealth.cs | 42 ++++++++++++++++-------------------------- 1 file changed, 16 insertions(+), 26 deletions(-) diff --git a/paydayHealth.cs b/paydayHealth.cs index e546d34..45033d6 100644 --- a/paydayHealth.cs +++ b/paydayHealth.cs @@ -6,9 +6,9 @@ namespace pdHealth { public class pdHealth : Script { + public pdHealth() { - if (allDamageArmor == true) { this.Tick += new EventHandler(this.doAllDamageArmorTick); } this.Tick += new EventHandler(this.doHealthTick); //this.KeyDown += new GTA.KeyEventHandler(this.keyDownHandler); } @@ -40,13 +40,23 @@ namespace pdHealth if (pl.Armor < armorVal) { timeUntilRegen = armorRegenDelay; } if (pl.Health < healthVal) { timeUntilRegen = armorRegenDelay; } + if (allDamageArmor == true) { + if (pl.Health < healthVal) { + int damageTaken = healthVal - pl.Health; + if (damageTaken < pl.Armor) { + pl.Health = pl.Health + damageTaken; + pl.Armor = pl.Armor - damageTaken; + } else { + pl.Health = pl.Health + (damageTaken - pl.Armor); + pl.Armor = 0; + } + } + } + if (timeUntilRegen > 0) { timeUntilRegen = timeUntilRegen - tickTime; if (timeUntilRegen < 0) { timeUntilRegen = 0; } - } - - - if (timeUntilRegen == 0) { + } else { if (pl.Armor < armorRegen) { pl.Armor = pl.Armor + armorRegenSpeed; if (pl.Armor > armorRegen) { pl.Armor = armorRegen; } @@ -55,30 +65,10 @@ namespace pdHealth armorVal = pl.Armor; healthVal = pl.Health; - Game.DisplayText("Health: " +pl.Health.ToString()+ "\nArmor: " +pl.Armor.ToString(), 1000); + Game.DisplayText("Health:\n " +pl.Health.ToString(), 1000); Wait(tickTime); } - private void doAllDamageArmorTick(object sender, EventArgs e) - { - Ped pl = Player.Character; - if (pl.isAlive == false) { return; } - - if (pl.Health < healthVal) { - int damageTaken = healthVal - pl.Health; - if (damageTaken < pl.Armor) { - pl.Health = pl.Health + damageTaken; - pl.Armor = pl.Armor - damageTaken; - } else { - pl.Health = pl.Health + (damageTaken - pl.Armor); - pl.Armor = 0; - } - } - - armorVal = pl.Armor; - healthVal = pl.Health; - } - //Testing private void keyDownHandler(object sender, GTA.KeyEventArgs e) {