I made a HUD for my DarkRP server with hunger bar on it, now, whenever i enable the hunger mod in the config, it puts the default blue hunger bar aswell as my custom one.
Does anyone know how to remove the blue DarkRP one?
Screen shot, (Its under the health bar)
REMOVED IMAGE
Thanks!
Follow it to a folder darkrp\gamemode\modules\hungermod
Open Lua scripts cl_init.lua
Remove of the code.
[CODE]function HM.HUDPaint()
LocalPlayer().DarkRPVars = LocalPlayer().DarkRPVars or {}
LocalPlayer().DarkRPVars.Energy = LocalPlayer().DarkRPVars.Energy or 0
if GAMEMODE.Config.hungermod or LocalPlayer().DarkRPVars.LocalHungerMod == 1 then
local x = 5
local y = ScrH() - 9
draw.RoundedBox(4, x - 1, y - 1, GetConVarNumber("HudW") - 8, 9, Color(0, 0, 0, 255))
if LocalPlayer():Team()!=TEAM_MON then
if LocalPlayer().DarkRPVars.Energy > 0 then
draw.DrawText(math.ceil(LocalPlayer().DarkRPVars.Energy) .. "%", "DefaultSmall", GetConVarNumber("HudW") / 2, y - 2, Color(255, 255, 255, 255), 1)
draw.RoundedBox(4, x, y, (GetConVarNumber("HudW") - 9) * (math.Clamp(LocalPlayer().DarkRPVars.Energy, 0, 100) / 100), 7, Color(0, 155, 0, 255))
else
draw.DrawText(LANGUAGE.starving, "CenterPrintText", GetConVarNumber("HudW") / 2, y - 4, Color(200, 0, 0, 255), 1)
end
end
if FoodAteAlpha > -1 then
local mul = 1
if FoodAteY <= ScrH() - 100 then
mul = -.5
end
draw.DrawText("++", "HungerPlus", 208, FoodAteY + 1, Color(0, 0, 0, FoodAteAlpha), 0)
draw.DrawText("++", "HungerPlus", 207, FoodAteY, Color(20, 100, 20, FoodAteAlpha), 0)
FoodAteAlpha = math.Clamp(FoodAteAlpha + 1000 * FrameTime() * mul, -1, 255)
FoodAteY = FoodAteY - 150 * FrameTime()
end
end
end
hook.Add("HUDPaint", "HM.HUDPaint", HM.HUDPaint)[/CODE]
[QUOTE=piston1996;41079101]Follow it to a folder darkrp\gamemode\modules\hungermod
Open Lua scripts cl_init.lua
Remove of the code.
[CODE]function HM.HUDPaint()
LocalPlayer().DarkRPVars = LocalPlayer().DarkRPVars or {}
LocalPlayer().DarkRPVars.Energy = LocalPlayer().DarkRPVars.Energy or 0
if GAMEMODE.Config.hungermod or LocalPlayer().DarkRPVars.LocalHungerMod == 1 then
local x = 5
local y = ScrH() - 9
draw.RoundedBox(4, x - 1, y - 1, GetConVarNumber("HudW") - 8, 9, Color(0, 0, 0, 255))
if LocalPlayer():Team()!=TEAM_MON then
if LocalPlayer().DarkRPVars.Energy > 0 then
draw.DrawText(math.ceil(LocalPlayer().DarkRPVars.Energy) .. "%", "DefaultSmall", GetConVarNumber("HudW") / 2, y - 2, Color(255, 255, 255, 255), 1)
draw.RoundedBox(4, x, y, (GetConVarNumber("HudW") - 9) * (math.Clamp(LocalPlayer().DarkRPVars.Energy, 0, 100) / 100), 7, Color(0, 155, 0, 255))
else
draw.DrawText(LANGUAGE.starving, "CenterPrintText", GetConVarNumber("HudW") / 2, y - 4, Color(200, 0, 0, 255), 1)
end
end
if FoodAteAlpha > -1 then
local mul = 1
if FoodAteY <= ScrH() - 100 then
mul = -.5
end
draw.DrawText("++", "HungerPlus", 208, FoodAteY + 1, Color(0, 0, 0, FoodAteAlpha), 0)
draw.DrawText("++", "HungerPlus", 207, FoodAteY, Color(20, 100, 20, FoodAteAlpha), 0)
FoodAteAlpha = math.Clamp(FoodAteAlpha + 1000 * FrameTime() * mul, -1, 255)
FoodAteY = FoodAteY - 150 * FrameTime()
end
end
end
hook.Add("HUDPaint", "HM.HUDPaint", HM.HUDPaint)[/CODE][/QUOTE]
Thank you it worked!!!
1 more thing though, on join, i get these errors.
[CODE]
[ERROR] gamemodes/darkrp/gamemode/client/hud.lua:187: attempt to index field 'DarkRPVars' (a nil value)
1. MyHUD - gamemodes/darkrp/gamemode/client/hud.lua:187
2. DrawHUD - gamemodes/darkrp/gamemode/client/hud.lua:246
3. unknown - gamemodes/darkrp/gamemode/client/hud.lua:358
[/CODE]
Any idea there?
[QUOTE=Smexy Pig;41079820]Thank you it worked!!!
1 more thing though, on join, i get these errors.
[CODE]
[ERROR] gamemodes/darkrp/gamemode/client/hud.lua:187: attempt to index field 'DarkRPVars' (a nil value)
1. MyHUD - gamemodes/darkrp/gamemode/client/hud.lua:187
2. DrawHUD - gamemodes/darkrp/gamemode/client/hud.lua:246
3. unknown - gamemodes/darkrp/gamemode/client/hud.lua:358
[/CODE]
Any idea there?[/QUOTE]
How are we supposed to know whats without the code you're using?
At the very least I can tell you that on like 187 of hud.lua DarkRPVars is a nil value.
I wan't to ask something. How do I ADD a Hunger hud?
Sorry, you need to Log In to post a reply to this thread.