Hello.
Currently I am trying to make a HUD with moving bars, and 2 of them work, the armor and hp one, but the ammo bar doesn't(at least correctly)
The bar doesn't fill up the entirely with a full mag:
[url]https://gyazo.com/f4d53631aca8113a0b7ea36a93f7eafb[/url]
[url]https://gyazo.com/4ab1ca7a573f8b7bd5f89b73490922f1[/url]
Any idea why?
Here is the code:
[CODE] draw.RoundedBox(3, 16, ScrH() - 15 - 36, 100 * 2.6, 23, Color(25,25,25,255))
draw.RoundedBox(3, 16, ScrH() - 15 - 35, LocalPlayer():GetActiveWeapon():Clip1() * 2.6, 21, Color(255,145,0,255))
draw.SimpleText( "Ammo: "..ply:GetActiveWeapon():Clip1().." / "..ply:GetAmmoCount( wep:GetPrimaryAmmoType() ), "Trebuchet24", ScrW() - 1875, ScrH()-52, Color(255, 255, 255,255) )[/CODE]
Thanks
LocalPlayer():GetActiveWeapon():Clip1() * 2.6 This is why.
What you want to do with dynamic widths is this:
[code]
local number = LocalPlayer():GetActiveWeapon():Clip1() -- Current ammo
local MaxNumber = 45 -- Max ammo
local maxWidth = 500 // Max box width
local realWidth = maxWidth * ( number / MaxNumber ) -- The actual box width you use in the draw.RoundedBox[/code]
[QUOTE=Robotboy655;48396320]LocalPlayer():GetActiveWeapon():Clip1() * 2.6 This is why.
What you want to do with dynamic widths is this:
[code]
local number = LocalPlayer():GetActiveWeapon():Clip1() -- Current ammo
local MaxNumber = 45 -- Max ammo
local maxWidth = 500 // Max box width
local realWidth = maxWidth * ( number / MaxNumber ) -- The actual box width you use in the draw.RoundedBox[/code][/QUOTE]
is there a way to make it get the default amount of bullets in the clip of your current weapon, and then have the bar width change depending on the clip size?
[QUOTE=Tobiasx;48396385]is there a way to make it get the default amount of bullets in the clip of your current weapon, and then have the bar width change depending on the clip size?[/QUOTE]
Yes, by accessing the SWEP table and looking for ClipSize variable.
You'd need to add exceptions for HL2 sweps though.
Sorry, you need to Log In to post a reply to this thread.