Two questions, about lua and ENT:RenderOverride()

Hi all,

Ok so, i would like to ask you just 2 questions still about my gamemode developpement :

  • How can i replace the patern char " and ’ with " and '. Yes i changed the whole chat management, but when you type " or ’ you got Something is creating script errors, because the char is not escaped. So how i can replace it, so it is escaped ?
  • Is there any way to make ENT:RenderOverride() working, without changing the lua files when you see a NPC.
    Indead, i’m making Text rendering above NPC heads (with cam.Start3D2D), but i can’t figure out why RenderOverride is not called when the player don’t see the NPC. You need to force redownload lua files when a player is front of an NPC to have the RenderOverride method called. Any way to fix this ?

In the hope of quicks answers to my questions,
Thanks by advance,

Thanks for no answers

You are welcome.
Use ENT:Draw()

function ENT:Draw()
        //Drawing the model
	// Other draw stuff

ENT:RenderOverride is not a thing for SENTs unless you add support for it. Do what Nak said.

Thank you, but if i use RenderOverride, it’s because it’snot a sent… It’s a SNPC…

And for the first question ? How can i escape invalid chars in chat ?

string.gsub(text, "\"", "")

That won’t work since " will be formatted into "

Use the \ escape character

text:gsub( '\\"', '"' ) \\ since you're replacing " with \" here, use ' to open and close the string

text:gsub( "\\'", "'" ) \\ since you're replacing ' with \' here, use " to open and close the string

\\ all string.* functions can be used as metafunctions
\* Alternatively:

text:gsub( [[\"]], '"' )
text:gsub( [[\']], "'" )


Sorry for the code being a slight clusterfuck.

SNPCs are SENTs with NPC behaviors.

Thank you all ! First problem solved !

If i put ENT:Draw instead of ENT:RenderOverride, nothing, simply nothing is called. The function is no longer called. You can edit lua files, as much times as you want the function is no longer called.

It’s changing with the ENT.Base = on my shared.
Example :
“base_entity”, will call the ENT:Draw each frames.
“base_ai”, will never call ENT:Draw.
“base_gmodentity”, not existing on my gamemode’s base.

SNPCs don’t have client side hooks, unfortunately.

So am i condamned to be not able to show texts on the head ? If that’s the case, how RealLife Roleplay has made to show texts on NPC head ?

Noone ever said you cant do it, you are just doing it the wrong way. Just draw the text like 20 units up from the eyes.