It's been easy making health with draw.RoundedBox/draw.SimpleText
But how do I make a ammo bar/text for my hud?
Thank You Very Much :)
This is my hud right now
[IMG]http://i.imgur.com/k97hhPW.jpg[/IMG]
You would use:
[URL="http://wiki.garrysmod.com/page/Player/GetActiveWeapon"]Player:GetActiveWeapon()[/URL]
[URL="http://wiki.garrysmod.com/page/Category:Weapon"]Category:Weapon[/URL]
I get errors
heres my code
[CODE]function hud() -- Consider functions like a cyber button, and everything INSIDE the function turns on when this cyber button is pressed.
local health = LocalPlayer():Health()
local weapon = LocalPlayer():GetActiveWeapon()
draw.RoundedBox( 0, 10, 740, 300, 50, Color( 0, 0, 0, 200 ) )
draw.RoundedBox( 0, 10, 680, 300, 50, Color( 0, 0, 0, 200 ) )
draw.RoundedBox( 0, 10, 680, math.Clamp(health ,0, 200)*3, 50, Color( 0, 0, 0, 210 ) )
draw.RoundedBox( 0, 10, 680, math.Clamp(health ,0, 200)*3, 50, Color( 0, 0, 0, 210 ) )
draw.SimpleText("Health:", "Default", 15, ScrH() - 60 - 40, Color(255,255,255,255))
draw.SimpleText("Ammo:", "Default", 15, ScrH() - 5 - 40, Color(255,255,255,255))
draw.SimpleText(health, "default", 145, ScrH() - 60 - 40, Color(255,255,255,255))
draw.SimpleText(weapon, "default", 150, ScrH() - 60 - 40, Color(255,255,255,255))
end
hook.Add("HUDPaint", "MyHudName", hud) -- I'll explain hooks and functions in a second
-- Hide Original Hud --
function hidehud(name)
for k, v in pairs({"CHudHealth", "CHudBattery", "CHudAmmo", "CHudSecondaryAmmo"}) do
if name == v then return false end
end
end
hook.Add("HUDShouldDraw", "HideOurHud:D", hidehud)
[/CODE]
[CODE]
[ERROR] lua/includes/modules/draw.lua:101: bad argument #1 to 'DrawText' (string expected, got userdata)
1. DrawText - [C]:-1
2. SimpleText - lua/includes/modules/draw.lua:101
3. v - gamemodes/beast/gamemode/cl_init.lua:12
4. unknown - lua/includes/modules/hook.lua:82
[/CODE]
[QUOTE=BeastVallejo;41991921]-snip-[/QUOTE]
That's because the first argument has to be a string.
[QUOTE](string expected, got userdata)[/QUOTE]
Use the weapon library like so, "weapon:Clip1()". This will return a number of the weapon's primary clip.
Thank You Very Much! Helped a lot!
Sorry, you need to Log In to post a reply to this thread.