/* net.Receive( "Weapons", function ( len ) Weapons = net.ReadTable(); Entities = net.ReadTable(); PrintTable( Weapons ); PrintTable( Entities ); if ( Weapons && type( Weapons ) == "table" && table.Count( Weapons ) > 0 && type( Entities ) == "table" ) then WeaponsCount = table.Count ( Weapons ) + table.Count( Entities ); else WeaponsCount = 0; end end ); */ local flat = Color(52, 152, 219) local flat_1 = Color(149, 165, 166) local flat_2 = Color(189, 195, 199) local flat_3 = Color(127, 140, 141) local Weapons = {}; local Entities = {}; for i = 1, 15 do Weapons[ i ] = "m9k_m98b"; end for i = 1, 15 do Entities[ i ] = "grenade_helicopter"; end if ( Weapons && type( Weapons ) == "table" && table.Count( Weapons ) > 0 && type( Entities ) == "table" ) then WeaponsCount = table.Count ( Weapons ) + table.Count( Entities ); else WeaponsCount = 0; end local function ShowInventory() local ply = LocalPlayer(); local inventorySize = 10; if ( ply:IsUserGroup("vipadmin") or ply:IsUserGroup("vipmod") or ply:IsUserGroup("trusted") or ply:IsUserGroup("donator") or ply:IsUserGroup("superadmin") or ply:IsUserGroup("trusted") ) then inventorySize = 30; end /* not going to be used for designing net.Start( "GetInventorySize" ); net.WriteFloat( ply:EntIndex() ); net.SendToServer(); */ -- main Derma panel local _invis = vgui.Create( "DPanel" ) _invis:SetSize( ScrW() / 2, ScrH() / 2 ) _invis.Paint = function() draw.RoundedBox( 0, 0, 0, _invis:GetWide(), _invis:GetTall(), Color( 0, 0, 0, 0) ) end local _window = vgui.Create( "DFrame", _invis ); -- Creates the frame itself _window:SetSize( 361, 500 ); -- Size of the frame _window:Center(); -- Position on the players screen _window:SetTitle( "" ); -- Title of the frame net.Receive( "GetInventorySize", function( len ) inventorySize = inventorySize + net.ReadFloat(); _window:SetTitle( "Inventory - " .. ( WeaponsCount or "Loading!" ) .. " of ".. ( inventorySize or "Loading!" ) .." weapons" ); -- Title of the frame end ); _window:SetVisible( true ); _window:SetDraggable( false ); -- Draggable by mouse? _window:ShowCloseButton( false ); -- Show the close button _window.Paint = function() draw.RoundedBox( 0, 0, 0, _window:GetWide(), _window:GetTall(), color_white ) draw.RoundedBox( 0, 0, 0, _window:GetWide(), 25, flat ) end _window:MakePopup(); local closeButton = vgui.Create('DButton', _window) closeButton:SetFont('marlett') closeButton:SetText('r') closeButton:SetColor(Color(255, 255, 255)) closeButton:SetSize(15, 15) closeButton:SetDrawBackground(false) closeButton:SetPos(_window:GetWide() - 20, 5) closeButton.DoClick = function() _invis:Remove() end if ( WeaponsCount == 0 ) then -- User has no weapons local _itemlabel = vgui.Create( "DLabel", _window ); _itemlabel:SetPos( 82, 50 ); _itemlabel:SetColor( Color( 255, 255, 255, 255) ); _itemlabel:SetFont( "ChatFont" ); _itemlabel:SetText( "You don't have any weapons!" ); _itemlabel:SizeToContents(); else -- PropertySheet contains all the ItemPanels local _sheet = vgui.Create( "DColumnSheet", _window ); _sheet:SetPos( 5, 30 ); _sheet:SetSize( 351, 465 ); _sheet.Paint = function() draw.RoundedBox( 0, 0, 0, _sheet:GetWide(), _sheet:GetTall(), color_white ) end local _dpl = vgui.Create( "DScrollPanel", _sheet ); _dpl:SetSize( _window:GetWide( ) - 15, _window:GetTall( ) - 30 - 5 ); _dpl:SetPos( 0, 0 ); _dpl:GetVBar().Paint = function() draw.RoundedBox( 0, 5, 0, _dpl:GetVBar():GetWide(), _dpl:GetVBar():GetTall(), color_white ) end _dpl:GetVBar().btnUp.Paint = function() draw.RoundedBox( 0, 5, 0, _dpl:GetVBar():GetWide(), _dpl:GetVBar():GetTall() - 5, flat_3 ) end _dpl:GetVBar().btnDown.Paint = function() draw.RoundedBox( 0, 5, 0, _dpl:GetVBar():GetWide(), _dpl:GetVBar():GetTall() - 5, flat_3 ) end _dpl:GetVBar().btnGrip.Paint = function() draw.RoundedBox( 0, 5, 0, _dpl:GetVBar():GetWide(), _dpl:GetVBar():GetTall(), flat_1 ) end _dpl:SetVisible(true) local _dll = vgui.Create( "DListLayout", _dpl ); _dll:SetSize( _dpl:GetWide( ), _dpl:GetTall( ) ); _dll:SetPos( 0, 0 ); local _x = ( ScrW( ) / 2 ) - _window:GetWide( ) / 2; local _y = ( ScrH( ) / 2 ) - _window:GetTall( ) / 2 + 30; local _w = 300; local _h = 500 - 30 - 5; for i,v in ipairs( Weapons ) do local _weapon = weapons.GetStored( v ); if ( !_weapon ) then continue; end -- One ItemPanel for each weapon local _itemPanel = vgui.Create( "DPanel" ) _itemPanel:SetSize( 290, 100 ); _itemPanel.Paint = function() -- Alternating row colors, simple yet nice effect if ( i % 2 == 0 ) then surface.SetDrawColor( flat_1 ); else surface.SetDrawColor( flat_2 ); end surface.DrawRect( 0, 0, 565, 90 ); end -- The button that is for Use -- The icon of the weapon local _icon = vgui.Create( "DModelPanel", _itemPanel ); _icon:SetModel( _weapon.WorldModel ); _icon:SetSize( 90, 90 ); _icon:SetPos( 15, 0 ); _icon:SetCamPos( Vector( 20, 10, 20 ) ); _icon:SetLookAt( Vector( 0, 0, 0 ) ); local _iconOldPaint = _icon.Paint; _icon.Paint = function() render.SetScissorRect( _x, _y, _x + _w, _y + ( 500 - 30 - 5 ), true ); _iconOldPaint( _icon ); render.SetScissorRect( 0, 0, 0, 0, false ); end -- The name of the weapon local _itemlabel = vgui.Create( "DLabel", _itemPanel ); _itemlabel:SetPos( 110, 5 ); _itemlabel:SetColor( Color( 255, 255, 255, 255) ); _itemlabel:SetFont( "ChatFont" ); _itemlabel:SetText( _weapon.PrintName ); _itemlabel:SizeToContents(); local _itemdesc = vgui.Create( "DLabel", _itemPanel ); _itemdesc:SetPos( 111, 31 ); _itemdesc:SetColor( color_black ); _itemdesc:SetFont( "Default" ); _itemdesc:SetText( "Put anything you wish here." ); _itemdesc:SizeToContents(); local _itemdesc = vgui.Create( "DLabel", _itemPanel ); _itemdesc:SetPos( 110, 30 ); _itemdesc:SetColor( color_white ); _itemdesc:SetFont( "Default" ); _itemdesc:SetText( "Put anything you wish here." ); _itemdesc:SizeToContents(); _dll:Add( _itemPanel ); local _useButton = vgui.Create( "DButton", _itemPanel ); _useButton:SetText( "" ); _useButton:SetPos( 15, 0 ); _useButton:SetColor( color_white ) _useButton:SetSize( 90, 90 ); _useButton.Paint = function() draw.RoundedBox( 0, 0, 0, _useButton:GetWide(), _useButton:GetTall(), Color( 0, 0, 0, 0 ) ) end _useButton.DoClick = function () net.Start("UseWeapon"); -- send to server to give the player the weapon net.WriteString( v ); -- send weapon entity name net.WriteFloat( i ); -- send weapon entity id net.WriteFloat( ply:EntIndex() ); -- send player net.SendToServer(); _window:Remove(); end end colorover1 = vgui.Create( "DPanel", _invis ) colorover1:SetPos( 360, 80 + 25 + 10 + 20 - 20 ) colorover1:SetSize( 150, 400 ) colorover1.Paint = function() draw.RoundedBox(10, 0, 0, 150, colorover1:GetTall() - 50, color_white) end colorover = vgui.Create( "DPanel", _invis ) colorover:SetPos( 360, 110.5 ) colorover:SetSize( 100, 25 ) colorover.Paint = function() draw.RoundedBox(0, 0, 0, 100, colorover:GetTall(), flat) end --[[ tabs start here, it's pretty simple. Tabs are buttons, which when clicked set visible te ]] local b = vgui.Create( "DButton", _invis ) b:SetSize( 100, 20) b:SetPos( 360, 100 + 25 + 10 + 6 ) b:SetColor( Color(231, 76, 60) ) b:SetText( "Weapons" ) b.Paint = function() draw.RoundedBox( 0, 0, 0, b:GetWide(), b:GetTall(), flat ) end local b1 = vgui.Create( "DButton", _invis ) b1:SetSize( 100, 20) b1:SetPos( 360, 100 + 25 + 10 + 20 + 10 + 6 ) b1:SetColor( color_white ) b1:SetText( "Entities" ) b1.Paint = function() draw.RoundedBox( 0, 0, 0, b1:GetWide(), b1:GetTall(), flat ) end local b2 = vgui.Create( "DButton", _invis ) b2:SetSize( 100, 20) b2:SetPos( 360, 100 + 25 + 10 + 30 + 30 + 6) b2:SetColor( color_white ) b2:SetText( "Snipers" ) b2.Paint = function() draw.RoundedBox( 0, 0, 0, b2:GetWide(), b2:GetTall(), flat ) end local b3 = vgui.Create( "DButton", _invis ) b3:SetSize( 100, 20) b3:SetPos( 360, 100 + 25 + 10 + 30 + 30 + 30 + 6) b3:SetColor( color_white ) b3:SetText( "Shotguns" ) b3.Paint = function() draw.RoundedBox( 0, 0, 0, b3:GetWide(), b3:GetTall(), flat ) end -- local b4 = vgui.Create( "DButton", _invis ) b4:SetSize( 100, 20) b4:SetPos( 360, 100 + 25 + 10 + 120 + 6) b4:SetColor( color_white ) b4:SetText( "Rifle" ) b4.Paint = function() draw.RoundedBox( 0, 0, 0, b4:GetWide(), b4:GetTall(), flat ) end textover = vgui.Create( "DLabel", _window ) textover:SetText("Inventory - " .. ( WeaponsCount or "Loading!" ) .. "/".. ( inventorySize or "Loading!" )) textover:SetColor( color_white ) textover:SetPos( _window:GetWide() /2 - 80, 4.5 ) textover:SetSize( 700, 15 ) local c = color_white local c1 = color_white local c2 = color_white local c3 = color_white local c4 = color_white b.OnMousePressed = function() _dpl:SetVisible(true) entity1:SetVisible( false ) entity2:SetVisible(false) entity3:SetVisible(false) entity4:SetVisible(false) end b1.OnMousePressed = function() _dpl:SetVisible(false) entity1:SetVisible( true ) entity2:SetVisible(false) entity3:SetVisible(false) entity4:SetVisible(false) end b2.OnMousePressed = function() _dpl:SetVisible(false) entity1:SetVisible( false ) entity2:SetVisible(true) entity3:SetVisible(false) entity4:SetVisible(false) end b3.OnMousePressed = function() _dpl:SetVisible(false) entity1:SetVisible( false ) entity2:SetVisible(false) entity3:SetVisible(true) entity4:SetVisible(false) end b4.OnMousePressed = function() _dpl:SetVisible(false) entity1:SetVisible( false ) entity2:SetVisible(false) entity3:SetVisible(false) entity4:SetVisible(true) end end end -- Called on holster local _nextHolster = CurTime(); local function PutItemInInventory( _p, _key ) if ( input.IsKeyDown( KEY_I ) && _nextHolster <= CurTime() ) then _nextHolster = CurTime() + 2; local _trdata = {}; _trdata.start = _p:GetShootPos(); _trdata.endpos = _p:GetShootPos() + ( _p:GetAimVector() * 80 ); _trdata.filter = _p; local _tr = util.TraceLine( _trdata ); if ( _tr.HitNonWorld && _tr.Entity:IsValid() ) then net.Start( "HolsterEntity" ); net.WriteFloat( _tr.Entity:EntIndex() ); net.WriteFloat( _p:EntIndex() ); net.SendToServer(); Msg( "\n\nAttempting to put " .. _tr.Entity:GetClass() .. " in your inventory.\n\n " ); end end end hook.Add( "KeyPress", "PutItemInInventory", PutItemInInventory ); concommand.Add( "inv", ShowInventory );