HUD and NPC Spawning help

1)[lua]function GM:HUDPaint()
draw.SimpleText(timeleft, “ScoreboardSub”, ScrW()/2, 25, Color(255,140,0),1,1)
it never changes the text

2) How do I spawn a npc? I have the position I want them to go, I just don’t know how to spawn them
3) How do I put an image on the hud?

Probably because timeleft isn’t updating.

Use ents.Create(“npc_name”) and use ent:Activate() and ent:Spawn().

Use draw.TexturedQuad or surface.TexturedRect. I’ll explain later.

ah ok, I didn’t know if it was the texturedrec or not.
but I have timeleft updating in init.lua, maybe it’s not updating because it’s server side?
Edit: timeleft is stored in shared.lua, but is updated in init.lua (which is server side)

What are you using for the timeleft?

If you are establishing it serverside, you need usermessages or something to send it to the client.

how do I usermessage it? and how can I spawn the npc at a position


Would I use ‘Entity.SetPos’ to set it’s position?

Yeah, use entity:SetPos(). Here, try this:
[lua]local npc = ents.Create(“npc_citizen”)
Just establish who the player is (ply).

I’ll explain usermessages in a sec.

Thanks, also, har har har funny

Erm, funny, why?

Also, the usermessages:


[lua]local timeleft = 0
timeleft = um:ReadShort()

someone rated me funny >_>
where would I put the server side part? where I change timeleft’s value?
Thanks for all your help!

Wasn’t me. :stuck_out_tongue:

You put the serverside part where the “timeleft” variable is.
And no problem.

so like at the top?
or where I change the timeleft variable?

Dunno, it’s whatever you want to do for your timeleft variable.

nevermind, got it!