Trying to use an entity?

Hey everyone!

I am trying to make an entity (NPC in this case) popup a panel for the player who uses the entity.
Ex: I press E looking at the NPC (being close to it) and a derma menu should pop up, etc…

Code:

Entity -> init.lua ::



function ENT:Use(activator, caller)
	
	net.Start("npc_base")
	net.Send(activator) //I have tried using caller instead. Didn't work.

end


Gamemode -> clientside ::



net.Receive("npc_base", function(len, caller)

	caller:PrintMessage(HUD_PRINTTALK, "npc_base was used!")
	print("npc_base was used!")

end)


  1. I have added the network string (util.AddNetworkString)
  2. I have tried sending the net message to both the caller and the activator (nothing worked)

Still, no message is sent…
If you need any other pieces of the code, let me know :wink:

Any help is appreciated! :smiley:

  • Fillipuster

Did you network it, So do util.AddNetworkedstring(“themssagenamehere”)

Also for npc’s I dont use ENT:Use() I do


function ENT:AcceptInput(name, activator, caller)	


end

That will be fired when a player or npc uses it, caller being the player

That did the tick. Thanks a lot man :smiley: