Spawning a entity through a derma menu?

So, I’m trying to make a derma menu that spawns a entity and takes away 200$ for that entity. I was going to use ent_create but that’s a blocked command.

Here’s my Derma Menu

[LUA]
function Store()

local DermaPanel = vgui.Create( “DFrame” )
DermaPanel:SetPos( 50,50 )
DermaPanel:SetSize( 200, 195 )
DermaPanel:SetTitle( “Mini-Mart” )
DermaPanel:SetVisible( true )
DermaPanel:SetDraggable( true )
DermaPanel:ShowCloseButton( false)
DermaPanel:MakePopup()
DermaPanel:Center( true )
gui.EnableScreenClicker(true)

local Icon = vgui.Create( “SpawnIcon”, Frame);
Icon:SetPos( 10, 25 );
Icon:SetParent( DermaPanel )
Icon:SetModel( “models/props_junk/glassbottle01a.mdl” );
Icon.DoClick = function()
DermaPanel:Close(gui.EnableScreenClicker(false))
end

local Icon = vgui.Create( “SpawnIcon”, Frame);
Icon:SetPos( 10, 90 );
Icon:SetParent( DermaPanel )
Icon:SetModel( “models/props_junk/glass_jug01.mdl” );
Icon.DoClick = function()
DermaPanel:Close(gui.EnableScreenClicker(false))
end

local DermaButton = vgui.Create( “DButton” )
DermaButton:SetParent( DermaPanel )
DermaButton:SetText( “I don’t want anything. Thanks Anyways” )
DermaButton:SetPos( 10, 155 )
DermaButton:SetSize( 180, 30 )
DermaButton.DoClick = function ()
DermaPanel:Close(gui.EnableScreenClicker(false))

end

end
concommand.Add(“store”, Store)
[/LUA]

**[Entity.Spawn

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=Entity.Spawn)**

[editline]08:49PM[/editline]

and use ply:TakeMoney( amount ) to take money away

Ah, Thanks for the help Flawless.

Just remember that spawning entities clientside means only you can see them – other people can’t see these entities.

How do i spawn them serverside then?

I mean console commands :x

By the way i edited that

What do you mean?

I mean make a serverside console command that does what you want and make the derma menu run it, i’d show an example but im literally about to log off

[lua] //clientside

DermaButton.DoClick = function ()
RunConsoleCommand(“buySome”, 1)
end

// serverside

concommand.Add (“buySome”, function (sender, command, arguments)

if not sender:IsValid() then return end

local i = tonumber(arguments[1])

if i == 1 then
local ent = ents.Create(“prop_physics”)
ent:SetModel(“models/props_junk/glass_jug01.mdl”)
ent:SetOwner(sender)
ent:Spawn()
ent:Activate()
end

end)
[/lua]

I wrote this in 2 mintues in the quickreply box; this is just to give you an idea how to do this.