Add text above VCMod Car NPC.

Edit: just found out that i accidently posted this in the wrong section. Could a mod move it to the developing/lua help section?

Hello,

I would like to add a text above the VCMod Car NPC Dealer. I’ve searched and tried multiple codes, but everything i’ve tried didn’t work out (no error codes, just no text).

The cl_init.lua has this code as the start:


include( 'shared.lua' )ENT.RenderGroup = RENDERGROUP_BOTH
 
function ENT:Draw( )
    self.Entity:DrawModel( )
end


surface.CreateFont ("NPCHUD", {
    size = 12,
    weight = 600,
    antialias = true,
    shadow = false,
    font = "DejaVu Sans"})
    

I’ve read that you should put the working code in cl_init. Is that correct?

Can you show us the actual code for the text drawing?

This was one of the many codes i’ve tried. Didn’t work though.



function ENT:Draw()
	
	cam.Start3D2D( Vector( 222, -73 , -100 ), Angle(0, 0, 0), 0.25 )
		draw.DrawText("AAAAAAAAAAA", "DermaLarge", 2, 2, Color(255, 255, 255, 255), TEXT_ALIGN_CENTER )
	cam.End3D2D()
end


You gotta do self:LocalToWorld(Vector( 222, -73 , -100 ))

So that would be:


function ENT:Draw()
    
    cam.Start3D2D(self:LocalToWorld(Vector( 222, -73 , -100 )), Angle(0, 0, 0), 0.25 )
        draw.DrawText("AAAAAAAAAAA", "DermaLarge", 2, 2, Color(255, 255, 255, 255), TEXT_ALIGN_CENTER )
    cam.End3D2D()
end

?

And do i put the code somewhere random in the cl_init.lua? Or on a specific palce?

If that doesnt work then I dont know…

Only other option I can think of for you is https://www.thecodingbeast.com/products and go to his car dealer addon. Its free and its quite nice for a free addon.

Put it somewhere in the entity’s cl_init

Unfortunately it stil isn’t working. NPC is there, but no text (and no errors whatsoever)

That’s probably because you have 2 draw functions and one is overwriting the other. You gotta have everything in 1 draw function

I changed it to


function ENT:Draw( )
    cam.Start3D2D(self:LocalToWorld(Vector( 222, -73 , -100 )), Angle(0, 0, 0), 0.25 )
        draw.DrawText("AAAAAAAAAAA", "DermaLarge", 2, 2, Color(255, 255, 255, 255), TEXT_ALIGN_CENTER )
    cam.End3D2D()
    self.Entity:DrawModel( )
end


No changes…

change the vector to 0,0,72

Same outcome :frowning:

I can post the files of the NPC Car Dealer if you want?

I apologize, but I don’t think freemmaann would like that.
I personally can’t help much since I’m a pretty busy person… I’m not sure why you wouldn’t be seeing the text if you put everything in the right place.

I’m going to switch to the TBC Car Dealer then. Where should i put the code in that module?
I’ve got cl_cardealer, but where ever i put the code i get the error:


[ERROR] addons/darkrpmodification-master/lua/darkrp_modules/tcb_car/cl_cardealer.lua:61: attempt to index global 'ENT' (a nil value)
  1. unknown - addons/darkrpmodification-master/lua/darkrp_modules/tcb_car/cl_cardealer.lua:61
   2. doInclude - [C]:-1
    3. loadModules - gamemodes/darkrp/gamemode/libraries/modificationloader.lua:102
     4. Call - gamemodes/darkrp/gamemode/libraries/modificationloader.lua:147
      5. unknown - gamemodes/darkrp/gamemode/cl_init.lua:48