So I have the HP drawing and everything perfectly using a health ratio. But the snag I am running into is the server the hud is designed for has different user groups with varying health levels. So I tried something like this
[CODE]
local ply = LocalPlayer()
local maxhealth = 100
local maxarmor = 255
local healthratio = math.Round(health*10/maxhealth)/10
local armorratio = math.Round(armor*10/maxarmor)/10
if (ply:IsUserGroup("superadmin")) then
local healthratio = math.Round(health*10/100000)/10
end
if (ply:IsUserGroup("user")) then
local healthratio = math.Round(health*10/100)/10
end
[/CODE]
Obviously this doesn't work. Its as if the ply is never checked for their group.
When my health is at 100 (as defined in the healthratio) - [url]http://www.mythicservers.com/custom/images/mythic/f10hV.png[/url]
When my health is over 100 - [url]http://www.mythicservers.com/custom/images/mythic/tNyON.png[/url]
So what I am trying to figure out, is there a way I can vary the healthratio based on the players usergroup or the players health on spawn?
Thanks for any help in advanced.
You could do something such as
[lua]
local maxhealth = 100
if LocalPlayer():Health() > maxhealth then
maxhealth = LocalPlayer():Health()
end
[/lua]
This is one way to do it.
Ideally you would use ply:GetMaxHealth() but that is serverside only (afaik).
If the usergroup information is available clientside you could lookup their user group and get the max health from that.
Something like:
[lua]local groups = adminMod.usergroups
local mygroup = ply:GetNWString("usergroup")
local groupInfo = groups[mygroup]
local maxhealth = groupInfo.maxHealth[/lua]
Hmm Ice Tea's method worked perfectly for what I need. See there is about 15 usergroups on this server. I feel like an idiot for not thinking about that lol. Thanks for the quick responses everyone.
Sorry, you need to Log In to post a reply to this thread.