Is there any ply:GetMaxHealth() equivalent for armor?
3 replies, posted
Hi everybody, I was making a HUD and I took with a problem that I can't solve, is there any equivalent to GetMaxHealth() but with armor?
I did this with the HP, is there any way to make it with the Armor?
[code]
local ply = LocalPlayer()
local hp = ply:Health()
local bh = 35
local modhp = math.Clamp( hp / ply:GetMaxHealth(), 0, 1)
surface.SetDrawColor( 255, 70, 70 )
surface.DrawRect( w / 2, h / 2, 300 * modhp, bh )
[/code]
There's no SetMaxArmor function so you can just go on the assumption that the max armor will be no higher than 100.
[code]local PLAYER = {}
PLAYER.DisplayName = "Default Class"
PLAYER.WalkSpeed = 400 -- How fast to move when not running
PLAYER.RunSpeed = 600 -- How fast to move when running
PLAYER.CrouchedWalkSpeed = 0.3 -- Multiply move speed by this when crouching
PLAYER.DuckSpeed = 0.3 -- How fast to go from not ducking, to ducking
PLAYER.UnDuckSpeed = 0.3 -- How fast to go from ducking, to not ducking
PLAYER.JumpPower = 200 -- How powerful our jump should be
PLAYER.CanUseFlashlight = true -- Can we use the flashlight
PLAYER.MaxHealth = 100 -- Max health we can have
PLAYER.StartHealth = 100 -- How much health we start with
PLAYER.StartArmor = 0 -- How much armour we start with
PLAYER.DropWeaponOnDie = false -- Do we drop our weapon when we die
PLAYER.TeammateNoCollide = true -- Do we collide with teammates or run straight through them
PLAYER.AvoidPlayers = true -- Automatically swerves around other players
PLAYER.UseVMHands = true -- Uses viewmodel hands[/code]
The MaxArmor property does not exist. You can always just clamp the player's armor to be safe:
[CODE]Player:SetArmor( math.Clamp( Player:Armor(), 0, (max armor value here) ) )[/CODE]
[QUOTE=Joeyl10;50449887]
- Snip -
[/QUOTE]
[QUOTE=Remixful;50450087]
- Snip -
[/QUOTE]
Now it works, thank you so much for your help :D
Sorry, you need to Log In to post a reply to this thread.