Guest User

weapons.lua

a guest
Jul 25th, 2015
213
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ply = LocalPlayer()
  2. local PANEL = { }
  3. function PANEL:Init( )
  4.     self.Label = vgui.Create( "DLabel", self )
  5.     self.Label:SetText( "Weapons" )
  6.     self.Label:SetTextColor( Color( 255, 255, 255, 255 ) )
  7.     self.Label:SizeToContents( )
  8.    
  9.     self.ListList = vgui.Create( "DPanelList", self )
  10.    
  11.     self.IconList = {}
  12.     self.IconListCollapse = {}
  13.     for k,v in pairs (MODELGROUPS) do
  14.     self.IconList[k] = vgui.Create( "DPanelList", self )
  15.     self.IconList[k]:EnableVerticalScrollbar( true )
  16.     self.IconList[k]:EnableHorizontal( true )
  17.     self.IconList[k]:SetPadding( 4 )
  18.     self.IconList[k]:SetVisible( true )
  19.    
  20.     self.IconListCollapse[k] = vgui.Create( "DCollapsibleCategory", self )
  21.     self.IconListCollapse[k]:SetSize( 610,20 )
  22.     self.IconListCollapse[k]:SetLabel( v )
  23.     self.IconListCollapse[k]:SetVisible( true )
  24.     self.IconListCollapse[k]:SetContents(self.IconList[k])
  25.     self.ListList:AddItem( self.IconListCollapse[k] )
  26.     end
  27.            
  28.     for k,v in pairs( MODELS ) do
  29.         ents.CreateClientProp("prop_physics") -- lol ailias filthy hack
  30.         local ico = vgui.Create( "DModelPanel", self )
  31.         ico:SetModel(k)
  32.         ico.Skin = math.random(0,util.GetModelInfo(k).SkinCount-1)
  33.         ico.Entity:SetSkin(ico.Skin)
  34.         ico.DoClick = function( ico )
  35.         LocalPlayer():ConCommand("giveplayeritem "..v.NAME.." "..v.PRICE.."\n")
  36.         surface.PlaySound( "ui/buttonclick.wav" )      
  37.         end
  38.     end
  39. end
  40.  
  41. function PANEL:PerformLayout( )
  42.     self:StretchToParent( 2, 24, 2, 2 )
  43.     self.Label:SetPos( 2, 2 )
  44.     self.ListList:StretchToParent( 4, 26, 4, 4 )
  45.     self.ListList:InvalidateLayout()
  46.     for k,v in pairs (self.IconList) do
  47.     --v:StretchToParent( 4, 26, 4, 4 )
  48.     v:SizeToContents( )
  49.     v:InvalidateLayout()
  50.     end
  51. end
  52.  
  53.  
  54. function PANEL:OnVScroll( iOffset )
  55.     self.pnlCanvas:SetPos( 25, 25 + iOffset )
  56. end
  57.  
  58. function PANEL:OnMouseWheeled( dlta )
  59.     if ( self.VBar ) then
  60.         return self.VBar:OnMouseWheeled( dlta )
  61.     end
  62. end
  63.  
  64. vgui.Register( "gofish_weapons_menu", PANEL, "DPanel" )
RAW Paste Data