Advertisement
Guest User

Untitled

a guest
May 24th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.93 KB | None | 0 0
  1. concommand.Add("dshop_open", function(ply, cmd, args)
  2.  
  3. ply:ChatPrint( "Hold right click to rotate view" )
  4.  
  5. net.Start( "thirdperson" )
  6. net.SendToServer()
  7.  
  8. local angs = ply:EyeAngles()
  9. ply:SetEyeAngles( Angle(0, angs.y, angs.z) )
  10.  
  11. local w, h = 750, 500
  12.  
  13. local frame = vgui.Create( "DFrame" )
  14. frame:SetSize( w, h )
  15. frame:SetPos((ScrW()/2)+(w/4), (ScrH()/2)-(h/2))
  16. frame:SetTitle("DoomServers Store")
  17. frame:MakePopup()
  18. frame.OnClose = function()
  19. net.Start( "thirdperson" )
  20. net.SendToServer()
  21. end
  22.  
  23. local sheet = vgui.Create( "DPropertySheet", frame )
  24. sheet:Dock( FILL )
  25.  
  26. local namey = 5
  27.  
  28.  
  29. local tabs = {}
  30. local lists = {}
  31.  
  32.  
  33. for catid, catname in SortedPairsByValue(ShopCategories, true) do
  34.  
  35. table.insert(tabs, catname)
  36. table.insert(lists, catname)
  37.  
  38. tabs[catid] = vgui.Create( "DPanel", sheet )
  39. tabs[catid].Paint = function( self, w, h ) draw.RoundedBox( 4, 0, 0, w, h, Color( 65, 65, 65, self:GetAlpha() ) ) end
  40.  
  41. lists[catid] = vgui.Create("DPanelList", tabs[catid])
  42. lists[catid]:Dock( FILL )
  43. lists[catid]:SetSpacing(2)
  44. lists[catid]:EnableVerticalScrollbar()
  45.  
  46. for i, v in pairs(Items) do
  47.  
  48. if i != 0 then --dont put base item in store
  49.  
  50. local p = vgui.Create("Panel")
  51. p:SetTall(60)
  52.  
  53. local model = vgui.Create("DModelPanel", p)
  54. model:SetPos(0, -(p:GetTall()+35))
  55. model:SetSize( 150, 150 )
  56. model:SetModel(Items[i].MODEL)
  57.  
  58. local txt = txt
  59.  
  60. if table.HasValue( hats, i ) then txt = "Equip / Use" else txt = "Buy" end
  61.  
  62. local equip = vgui.Create( "DButton", p )
  63.  
  64. equip:SetPos( frame:GetWide()-150, namey )
  65. equip:SetSize( 80, 20 )
  66. equip.Think = function()
  67. equip:SetText( txt )
  68. end
  69. equip.DoClick = function()
  70.  
  71. if tonumber(LocalPlayer():GetNWInt("myhat")) == i then --If you're already wearing this hat, unequip it if you click the button
  72. RunConsoleCommand( "dshop_unequip" )
  73. surface.PlaySound( "buttons/button15.wav" )
  74. else
  75. RunConsoleCommand( "dshop_equip", i )
  76. surface.PlaySound( "buttons/button15.wav" )
  77. end
  78. end
  79.  
  80. p.Paint = function()
  81. local col = Color(80, 80, 80, 255)
  82. local namecol = namecol
  83. if table.HasValue( hats, i ) then namecol = Color(0, 255, 0, 255) else namecol = Color(255, 255, 255, 255) end
  84.  
  85. draw.RoundedBox(2, 0, 0, p:GetWide(), p:GetTall(), col)
  86. local name = draw.SimpleText(v.NAME, "DermaDefaultBold", 120, namey, namecol, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP)
  87. local desc = draw.SimpleText(v.DESCRIPTION or "", "DermaDefault", 120, namey+15, Color(255, 255, 255, 255), TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP)
  88. local cost = draw.SimpleText("Costs "..ToMoney(v.COST).." coins", "DermaDefault", 120, namey+30, Color(255, 255, 0, 255), TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP)
  89. end
  90.  
  91. if Items[i].CAT == catid then
  92. lists[catid]:AddItem(p)
  93. end
  94.  
  95. end
  96.  
  97. end
  98.  
  99. sheet:AddSheet( catname, tabs[catid], "icon16/emoticon_smile.png" )
  100.  
  101. end
  102. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement