Okay, so I'm creating this NPC that opens a derma menu when the player presses their use key on it, one problem though: When the player presses their use key on it, absolutely nothing happens, not even an error.
To me everything seems fine, and it should work, but nothing happens. Here's the code:
init.lua:
include("shared.lua")
AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
util.AddNetworkString("smug")
function ENT:Use(ply)
print("Test")
net.Start("smug")
net.Send(ply)
end
function ENT:Initialize()
self:SetModel('models/humans/group01/female_01.mdl')
self:SetHullType(HULL_HUMAN)
self:SetHullSizeNormal()
self:SetNPCState(NPC_STATE_SCRIPT)
self:SetSolid(SOLID_BBOX)
--self:SetUseType(SIMPLE_USE)
self:DropToFloor()
end
cl_init.lua:
include("shared.lua")
function ENT:Draw()
self.Entity:DrawModel()
end
net.Receive("smug", function()
if( !frame ) then
local frame = vgui.Create("DFrame")
frame:SetSize(900,600)
frame:SetPos(ScrW()/2-450,ScrH()/2-300)
frame:SetVisible(true)
frame:MakePopup()
frame:SetDeleteOnClose(true)
end
end )
shared.lua just has your normal entity code in it, so there is no need to show that.
If you can find the flaw, please tell me what happened and how to fix it. Thanks for looking at this post!
Uncomment SetUseType and test
You should localise frame as a local outside of your net.Receive, or else it will continuously make panels.
Uncommenting did nothing, and it won't even make 1 panel...
It isn't off-topic, because the local and panel will be garbage collected, making it so no panel appears.
yes, but I made it local by, correct me if i'm wrong, putting
local frame = {}
above the .net in cl_init, and it still does not open, or print anything for that matter, even though I put a test print function in the client side and server side.
I had the same issue with ENT:Use()
Not a clue why is happened but here is my work-around
function ENT:AcceptInput( name, activator, caller )
if name == "Use" and caller:IsPlayer() then
net.Start("mavshop")
net.Send(caller)
end
end
Okay! That worked! if anybody is here looking for a solution to the same problem, Luke has all of the answers
Sorry, you need to Log In to post a reply to this thread.