Entity drawing

Excuse me, if I have an entity I am making for example a health charger, how can I add a vgui button onto it? Do I just use the DButton or do I use some other code to check if the crosshair is facing that element? If so could you please help me out?

Shameless plug (assuming you mean a 3d2d ui).

If you want it to be VGUI, there’s https://github.com/HandsomeMatt/3d2d-vgui/ too.

Holy 3d2d vgui exists? I ment like the ui

[editline]18th March 2015[/editline]

I have a quick question. When I use it do I just paste the lua file into my addon and add AddCSLuaFile(“3d2dimgui.lua”) to the cl_init.lua of the entity.

[editline]18th March 2015[/editline]

How would I add it to an entity? Cause I tried but failed.

So Vortex, I can’t help you much using 3D2D, the only thing I know is that 3D2D is extremely complicated when you need to calculate angles. Positions aren’t as much hard to get (you can do it easly using a locfinder in Singleplayer), but angles are so complicated to get.

If you want a simple Scripted Entity/NPC with VGui open on use key pressed, then simply do the following :



//Server side
util.AddNetworkString("PacketName")
function ENT:AcceptInput(in, act, ply)
     if (in == "Use" && IsValid(ply) && ply:IsPlayer()) then
          net.Start("PacketName")
          net.Send(ply)
     end
end

//Client side
net.Receive("PacketName", function(len, ply)
      //VGui stuff here, example (forget about RRP_DFrame if you're not using the mod_advrendering of RRP, so anyway forget because the GM is private ; use DFrame instead) :
      local mainFrame = vgui.Create("RRP_DFrame")
      mainFrame:SetSize(512, 512)
      mainFrame:Center()      
end)


Thanks man. I didn’t want that but yesterday I changed my mind and started working on this meth cooking type of thing. That material will be useful :slight_smile: