Hi facepunch.
I have this code and im not sure how to make it spawn a entiyy with the models in the table, as you can see i want it so when the player presses one of the buttons it spawns that entity in front of them and deducts a certain amount of money from them (If you can help me just default all costs to 800).
function shop() -- shop by Infinity1995 local drugs = {} drugs[1] = "models/katharsmodels/contraband/zak_wiet/zak_wiet.mdl" drugs[2] = "models/katharsmodels/syringe_out/syringe_out.mdl" drugs[3] = "models/cocn.mdl" drugs[4] = "models/drug_od/the_bottle_of_water.mdl" drugs[5] = "models/ipha/mushroom_small.mdl" drugs[6] = "models/boxopencigshib.mdl" drugs[7] = "models/smile/smile.mdl" drugs[8] = "models/jaanus/aspbtl.mdl" local frame = vgui.Create("DFrame") local IconList = vgui.Create( "DPanelList", frame ) frame:Center() frame:SetSize(220,200) frame:SetTitle("Npc Shop") frame:MakePopup() IconList:EnableVerticalScrollbar( true ) IconList:EnableHorizontal( true ) IconList:SetPadding( 4 ) IconList:SetPos(10,30) IconList:SetSize(200, 160) for k,v in pairs(drugs) do local icon = vgui.Create( "SpawnIcon", IconList ) icon:SetModel( v ) IconList:AddItem( icon ) icon.DoClick = function( icon ) surface.PlaySound( "ui/buttonclickrelease.wav" ) RunConsoleCommand("gm_spawn", v) end end concommand.Add( "npcshop1", shop ) end
Also, please dont steal this code
Thank you in advance.
Edited:
From what i see i must edit:
To make it spawn a entity instead of a model.Code:RunConsoleCommand("gm_spawn", v)

Register
Events
Popular
More
Post #1








