Making a HUD, which displays a timer?

How would I go on, making a hud which is linked to a timer?

More specificly; I have a SEnt, which is a bulletproof vest and it reduces the damage by 50%
and I would like it, so that when ENT.Use is triggered, a Bar comes up, either centered or in a corner, with the text “Equipping…” and the current percentage of the… uhm… done…ness?

(I’m danish, and I cant think straight right now, lol)

It would take 5 seconds for the player to equip it and also emit a sound*.
(Forgot to add “Equipping…” so;…)

  •       - Equipping...
    

(*Ent.EmitSound (“LAWLS.wav”) right?)

If anyone could, not just point me in direction, but follow me down along the path, of such a creation, that would just be neat-o! :stuck_out_tongue:

If you’re thinking: “I will just make the whole thing for him, then he’ll be happy! :D”, then you’re kind of wrong.

As much as I want the script, I would like to learn, as my Lua coding abilities are limited.

and Please, dont just post a link “gut lock has fon” and leave, cause I’ve never done a HUD before, but THAT’s just at the wiki, right? :slight_smile: Anyways, any help - well, almost any help is appreciated!

Thanks in advance!

You want to use
**[G.CurTime

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=G.CurTime)**

example

[lua]
if not self.use then self.use = CurTime() end
if self.use > CurTime() then
return false
else
self.use = CurTime() + 5
// Code here
end
[/lua]
Untested wrote in quick reply box

More specifically, you want to do this in a think hook.

… what/which think hook?

Oh, ENT.Think() function right? or…?

[editline]02:43PM[/editline]

What code are you talking about? :o

Like… the code where he equips it?

[LUA]/---------------------------------------------------------
Name: Think
Desc: Called every frame
---------------------------------------------------------
/
function ENT:Think()

if not self.use then self.use = CurTime() end  
if self.use > CurTime() then   
    return false  
else  
    self.use = CurTime() + 5
    // Code here
end  

end [/LUA]

At least you and i spotted the bit without the if statement lol. :wink:

[lua]self.use > CurTime() then[/lua]

There is actually an if in his code, the syntax highlighter just cuts it off, press reply and you will see.

Thats strange how it cut off

[editline]06:39PM[/editline]

edited post and it fixed its self

It isn’t fixed for me, doesn’t matter though, I know it is there.

Still wondering about which code you guys are talking about…

The equipping of the vest (set %50 less dmg)
or the hud.

The code I posted

Correct.

–__–*

Im’a try again:

What code, should I put in, where it says “code here”??

The equipping of the vest (reducing dmg) or the HUD code?

Hud, or what ever you asked for the timer to do lol.

Okay, and how would I go on creating this hud?

(preferable the picture I showed you above)

Draw functions

Please :confused:

That will teach you basics