Shop GUI

Ok so I’m wondering how I could make a shop, which sells entities. I can make one that spawns props, that’s easy. But that’s not what I want.

Why don’t you attempt it yourself, and once you’ve given up give us what you have and we will correct it.

Ok.

[editline]30th January 2013[/editline]

Ok I give up. Heres my code, the first line of “items”, is my fail at using one of the SWeps from CSS Realistic SWEPS pack.



function ShopMenu()
    local items = {}
 
        items[1] = "weapon_real_cs_deagle"
	items[2] = "models/weapons/w_smg_mac10.mdl"
	items[3] = "models/props_junk/garbage_takeoutcarton001a.mdl"
	items[4] = "models/props_junk/watermelon01.mdl"
	items[5] = "models/props_junk/garbage_metalcan001a.mdl"
	items[6] = "models/props_lab/box01a.mdl"
	items[7] = "models/props_lab/box01b.mdl"
	
    local frame = vgui.Create("DFrame")
	local IconList = vgui.Create("DPanelList", frame) 
 
	frame:Center()
	frame:SetSize(400,380)
	frame:SetTitle("Shop Menu")
	frame:MakePopup()
 
 	IconList:EnableVerticalScrollbar(true) 
 	IconList:EnableHorizontal(true) 
 	IconList:SetPadding(4) 
	IconList:SetPos(10, 30)
	IconList:SetSize(400, 380)
 
	for k,v in pairs(items) 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 	
end
usermessage.Hook("ShopMenu", ShopMenu)


[editline]30th January 2013[/editline]

Bump-

BUMP

[editline]31st January 2013[/editline]

New code by the way, the little text box was to test if the menu was working correctly:



function ShopMenu()
    local ply = LocalPlayer()
	local Window = vgui.Create("DFrame")
	Window:SetTitle("Shop Menu")
	Window:SetSize(500, 200)
	Window:SetPos(100, 200)
	Window:SetDraggable(true)
	Window:SetVisible(true)
	Window:MakePopup()
	Window.Paint = function()
		draw.RoundedBox(4, 0, 0, Window:GetWide(), Window:GetTall(), Color(30, 0, 150, 220))
		draw.RoundedBox(2, 2, 2, Window:GetWide()-4, 21, Color(30, 30, 30, 220))
	end
	local Text = vgui.Create("DTextEntry", Window)
	Text:SetPos(20, 30)
	Text:SetTall(50)
	Text:SetWide(160)
	Text:SetEnterAllowed(true)
	Text.OnEnter = function()
		ply:ConCommand("say "..Text:GetValue())
		Window:SetVisible(false)
	end
end
usermessage.Hook("ShopMenu", ShopMenu)


It doesn’t have any sort of spawning in it. I could use the older code as posted above if needed.

[editline]31st January 2013[/editline]

Bump- Come on can someone help? Or if there is a tutorial out there(which I have not found) someone please link it!

http://www.facepunch.com/showthread.php?t=1228438

Not a point shop… A money shop that sells guns and other weapons.

Here’s a suggestion…
[lua]
local items = {}
table.insert(items,{“Desert Eagle”,“models/weapons/w_pist_deagle.mdl”})
[/lua]
This system makes it so that items[1][1] would be the name of the item, and that the next arguments would be the image, and the weapon to give to the player, it’s better then making a huge function checking if it’s the model to return the name… etc.

Well you could atleast try and study it, I’m sure it’s code can be used for other purposes.

Thanks for help guys.

Rename it from points to money?

Is this going to be for a custom gamemode?

Probably not, Pointshop does have a weapon section, but mainly it’s items that are applied to playermodels, so the code could be pretty useless for op’s needs.

[editline]1st February 2013[/editline]

But this could help:

Yes Brandon and Georgeface. You guys are on the right track. No one else seems to get it. Thanks for the link bro.