PostDrawOpaqueRenderables problem.

I’m trying to draw 3D2D text on a door in DarkRP, and for some reason it’s not working. Entity:IsDoor() is defined in DarkRP and works when used in HUDPaint, but, no matter what, it always returns false in PostDrawOpaqueRenderables. Any idea why this is happening?

hook.Add( “PostDrawOpaqueRenderables”, “DoorTitles”, function()
for _, v in ipairs( ents.GetAll() ) do
if v:IsDoor() then
if !v.DoorData then return end
v.DoorData.title = v.DoorData.title or “”

		print( v.DoorData.title )
		if v.DoorData.title != "" then
			cam.Start3D2D( v:GetPos() + Vector( 0, 0, 50 ), v:GetAngles(), .11 )
				local t = ent.DoorData.title
				local w, h = surface.GetTextSize( t )
				surface.SetDrawColor( 0, 0, 0, 255 )
				surface.DrawRect( 0, 0, w + 10, h + 10 )
				surface.SetDrawColor( 255, 255, 255, 255 )
				draw.SimpleText( t, "ChatFont", 5, 5, Color( 255, 255, 255, 255 ) )

end )


I would just use HUDPaint, but it doesn’t update position or angles.

Now two people has used that idea :suicide: [sp]I should have copyrighted it[/sp]


you should add some debugs to the DarkRP function, it might be some networking problem

I’m on SinglePlayer if that helps, and I didn’t know anyone else had done this :v:




I was pissed that it wasn’t working and committed suicide and got the error:

Hook ‘DoorTitles’ Failed: gamemodes\darkrp\gamemode\cl_init.lua:379: attempt to index field ‘DoorData’ (a nil value)


Added a check for when the DoorData table exists. It never gets passed it. I tried creating a LAN server, still no dice.

And why does it return false on IsOwnable() until I kill myself? :v:?

Do some debugs like checking if the table really exists, also datastream might not be entirly fixed or something

AzuiSleets fix:
_outgoing[] = nil

My Fix:
_outgoing[id] = nil

Ugh… I wish stuff would just work. :saddowns:


It couldn’t be datastream, because the information is read fine in HUDPaint… which is why I thought it had to be something with PostDrawOpaqueRenderables.

i should copyright ‘end’ so noone can use it

Ok, I just used lua_run_cl to PrintTable( Entity.DoorData ) and it worked and showed the title and everything.

Conclusion met: It’s PostDrawOpaqueRenderables.

What could be causing the table to exist client-side but not exist in this client-side hook?


Tune in to find out more, when someone replies!

What does the Entity:IsOwnable() function look like?

I got rid of that, I have new code now. Updated OP.


function meta:IsDoor()
local class = self:GetClass()

if class == "func_door" or
	class == "func_door_rotating" or
	class == "prop_door_rotating" or
	class == "prop_dynamic" then
	return true
return false