I am trying to create my own damage system by disabling the current one with the hook playershouldtakedamage, but it doesn’t want to work…
function PlayerShouldTakeDamage( victim, pl ) if pl:IsPlayer() == 1 then -- check the attacker is player Victim = FindPlayer(victim:Name()) Attacker = FindPlayer(attacker:Name()) print("Success") Hit() return false -- do not damage the player end print("Fail") return true -- damage the player end hook.Add( "PlayerShouldTakeDamage", "PlayerShouldTakeDamage", playershouldtakedamage) function Hit(attacker, victim) local Att = Attacker local Vic = Victim DMG = Att:GetNWInt("Damage") + Att:GetNWInt("Damage+") ArmorDmg = Vic:GetNWInt("Armor") - Att:GetNWInt("ArmorDmg") if ArmorDmg <= 0 then Vic:SetNWInt("Armor", 0) print("Armor Blocked Damage") else ArmorLeft = Vic:GetNWInt("Armor") - ArmorDmg Vic:SetNWInt("Armor", ArmorLeft) end DamageDealt = DMG - Vic:GetNWInt("Armor") if DamageDealt <= 0 then DamageDealt = 0 ArmorLeft2 = Vic:GetNWInt("Armor") - DMG Vic:SetNWInt("Armor", ArmorLeft2) else Vic:SetNWInt("Armor", 0) print("Taking Damage") HP = ply:Health() - DamageDealt ply:SetHealth(HP) end end
I set the 4 variables on the initial spawn (just for testing) dmg is 1 and armor is 5 the other 2 are 0.
What it does is:
Doesn’t print anything
Damages player (it should hit him 5 times then bring his hp down by 1 each time)
I might be taking a noob approach to this, but it was the only way that seemed logical to me.
The Networked integers will be set somehow by the weapon the person has and the armor will be set by the armor the person has…