PDA

View Full Version : [GMOD] Lua Scripting: Any help?.. Facepunch sure hasen't any.



Bastinka
April 14th, 2009, 07:20 PM
Hey everyone,
Been trying to figure out how to make a custom HUD in Garrysmod. Posting threads and questions on facepunch, asking for tutorials or just how-to's doesn't seem to do me much well and hasn't in the past due to either the lack of people who know how to do this or something else..


If anyone here's good at it could you please take a look at it?


function jail_hud()
local client = LocalPlayer()
if !client:Alive() then return end
if(client:GetActiveWeapon() == NULL or client:GetActiveWeapon() == "Camera") then return end
draw.RoundedBox(7, 5, -5, 125, 75, Color(51, 58, 51, 175))
draw.SimpleText(client:Health() .. " HP", "ScoreboardText", 50, -25, Color(86, 104, 86, 255), 0, 0)
local mag_left = client:GetActiveWeapon():Clip1() // How much ammunition you have inside the current magazine
local mag_extra = client:GetAmmoCount(client:GetActiveWeapon():GetPr imaryAmmoType()) // How much ammunition you have outside the current magazine
local secondary_ammo = client:GetAmmoCount(client:GetActiveWeapon():GetSe condaryAmmoType())// How much ammunition you have for your secondary fire, such as the MP7's grenade launcher
end

hook.Add("HUDPaint", "jail_hud", jail_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", "hidehud", hidehud)

It's the simplest of simple, based off of a Wiki Tutorial yet I don't know how to make a Health bar or how to slap the box to the left hand bottom corner of the screen.





draw.RoundedBox(7, 5, -5, 125, 75, Color(51, 58, 51, 175))
draw.SimpleText(client:Health() .. " HP", "ScoreboardText", 50, -25, Color(86, 104, 86, 255), 0, 0)
In both these I tried negative values for Y coords but it didn't work at all..


Please, somebody point me in the right direction! :(
-SilentWindPL

( FP Thread, Most current: http://www.facepunch.com/showthread.php?p=14649900#post14649900 )

Limited
April 18th, 2009, 07:13 PM
Um, you can not have negative screen values.
0,0 = top left, then you add to the figures to eventually get at the bottom right.

n00b1n8R
April 18th, 2009, 08:22 PM
Facepunch just made a stupid newbie questions section.
Go ask there.