Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- concommand.Add("dshop_open", function(ply, cmd, args)
- ply:ChatPrint( "Hold right click to rotate view" )
- net.Start( "thirdperson" )
- net.SendToServer()
- local angs = ply:EyeAngles()
- ply:SetEyeAngles( Angle(0, angs.y, angs.z) )
- local w, h = 750, 500
- local frame = vgui.Create( "DFrame" )
- frame:SetSize( w, h )
- frame:SetPos((ScrW()/2)+(w/4), (ScrH()/2)-(h/2))
- frame:SetTitle("DoomServers Store")
- frame:MakePopup()
- frame.OnClose = function()
- net.Start( "thirdperson" )
- net.SendToServer()
- end
- local sheet = vgui.Create( "DPropertySheet", frame )
- sheet:Dock( FILL )
- local namey = 5
- local tabs = {}
- local lists = {}
- for catid, catname in SortedPairsByValue(ShopCategories, true) do
- table.insert(tabs, catname)
- table.insert(lists, catname)
- tabs[catid] = vgui.Create( "DPanel", sheet )
- tabs[catid].Paint = function( self, w, h ) draw.RoundedBox( 4, 0, 0, w, h, Color( 65, 65, 65, self:GetAlpha() ) ) end
- lists[catid] = vgui.Create("DPanelList", tabs[catid])
- lists[catid]:Dock( FILL )
- lists[catid]:SetSpacing(2)
- lists[catid]:EnableVerticalScrollbar()
- for i, v in pairs(Items) do
- if i != 0 then --dont put base item in store
- local p = vgui.Create("Panel")
- p:SetTall(60)
- local model = vgui.Create("DModelPanel", p)
- model:SetPos(0, -(p:GetTall()+35))
- model:SetSize( 150, 150 )
- model:SetModel(Items[i].MODEL)
- local txt = txt
- if table.HasValue( hats, i ) then txt = "Equip / Use" else txt = "Buy" end
- local equip = vgui.Create( "DButton", p )
- equip:SetPos( frame:GetWide()-150, namey )
- equip:SetSize( 80, 20 )
- equip.Think = function()
- equip:SetText( txt )
- end
- equip.DoClick = function()
- if tonumber(LocalPlayer():GetNWInt("myhat")) == i then --If you're already wearing this hat, unequip it if you click the button
- RunConsoleCommand( "dshop_unequip" )
- surface.PlaySound( "buttons/button15.wav" )
- else
- RunConsoleCommand( "dshop_equip", i )
- surface.PlaySound( "buttons/button15.wav" )
- end
- end
- p.Paint = function()
- local col = Color(80, 80, 80, 255)
- local namecol = namecol
- if table.HasValue( hats, i ) then namecol = Color(0, 255, 0, 255) else namecol = Color(255, 255, 255, 255) end
- draw.RoundedBox(2, 0, 0, p:GetWide(), p:GetTall(), col)
- local name = draw.SimpleText(v.NAME, "DermaDefaultBold", 120, namey, namecol, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP)
- local desc = draw.SimpleText(v.DESCRIPTION or "", "DermaDefault", 120, namey+15, Color(255, 255, 255, 255), TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP)
- local cost = draw.SimpleText("Costs "..ToMoney(v.COST).." coins", "DermaDefault", 120, namey+30, Color(255, 255, 0, 255), TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP)
- end
- if Items[i].CAT == catid then
- lists[catid]:AddItem(p)
- end
- end
- end
- sheet:AddSheet( catname, tabs[catid], "icon16/emoticon_smile.png" )
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement