So, basically what i’m trying to do is to make a Derma button, that if pushed an entity spawn somewhere on the map.
the problem is that derma is only client side, and ents library shared, and when i push the button i get “Tried TO USE A NULL ENTITY.”, as if i’m trying to run it client side.
here’s the code
client_init.lua:
include(“shared.lua”)
function spawnFrame()
local MyFrame = vgui.Create("DFrame")
MyFrame:SetPos(ScrW()/2, ScrH()/2)
MyFrame:SetSize(500, 400)
MyFrame:SetTitle("Testing derma")
MyFrame:SetVisible(true)
MyFrame:SetDraggable(true)
MyFrame:ShowCloseButton(true)
MyFrame:MakePopup()
MyButton = vgui.Create("DButton")
MyButton:SetParent(MyFrame)
MyButton:SetPos(0,0)
MyButton:SetSize(250,200)
MyButton:SetText("spawn")
MyButton.DoClick = function()
spawnEntity()
end
end
concommand.Add(“spawnFrame”, spawnFrame)
shared.lua
–include(“cl_init.lua”)
function spawnEntity(Model_File)
local MyEnt = ents.Create("npc_alyx")
MyEnt:SetPos(Vector(0,0,100))
MyEnt:Spawn()
MyEnt:Activate()
end