--[[ Displays the inventory, for more information see /gamemode/shared/inventory.lua ]] print("Hello from cl_inventory.lua") --debug.Trace() local prayerequiped = { false,false,false,false,false } net.Receive("equiphelpprayer",function() print("equiphelp received client side!") prayerequiped[4] = "Noob Help" end) local lastpanel = lastpanel or 1 local inventorysheets = {} --[[ ART.RegisterInventorySheet = function(func) inventorysheets[#inventorysheets + 1] = func end ]] local plyisininventory = false --Displays a dropdown of options under the players mouse, if the option is clicked, does the function --Requires a table of strings to functions, or strings to tables of strings to functions. --Be careful not to make this a recursive table. local function createMenuFor(menu, tbl) for k,v in pairs(tbl) do if isfunction(v) then --This is a dead-end, add the menu local thisoption = menu:AddOption(k,v) else --Otherwise it should be a table, recursively call to create local submenu = menu:AddSubMenu(k) createMenuFor(submenu,v) end end end --[[ function ART.RefreshDisplays() local discopy = LocalPlayer().invdisplays LocalPlayer().invdisplays = {} for k,ptbl in pairs(discopy) do if not ptbl.panel:IsValid() then continue end if ptbl.panel.Close ~= nil then ptbl.panel:Close() else print(ptbl.panel) error("panel has no close method") ptbl.panel:Remove() end ptbl.redraw() end end ]] local sheet function ShowInventory(ply,cmd,args) if plyisininventory then return end LocalPlayer().invdisplays = LocalPlayer().invdisplays or {} plyisininventory = true local width = ScrW() local height = ScrH() local dat = {} dat.panel = vgui.Create( "DFrame" ) dat.redraw = ShowInventory table.insert(LocalPlayer().invdisplays,dat) local invpanel = dat.panel invpanel:SetPos( 0, 0 ) invpanel:SetSize( width / 4, height ) invpanel:SetTitle( "Inventory" ) invpanel:SetDraggable( true ) invpanel:MakePopup() invpanel.OnClose = function(self) plyisininventory = false end sheet = vgui.Create( "DPropertySheet", invpanel ) sheet:Dock( FILL ) for k,v in pairs(inventorysheets) do local name,tsheet,image = v() sheet:AddSheet(name,tsheet,image) tsheet.sheetnum = name end sheet:SwitchToName(lastpanel) end hook.Add("OnSpawnMenuOpen","ArteryOpenInventory",ShowInventory) hook.Add("OnSpawnMenuClose","ArteryCloseInventory",function() lastpanel = sheet:GetActiveTab():GetPanel().sheetnum for k,v in pairs(LocalPlayer().invdisplays) do if not v.panel:IsValid() then continue end --PrintTable(v) v.panel:Close() LocalPlayer().invdisplays[k] = nil end plyisininventory = false end) concommand.Add("showinventory",ShowInventory) local viewdistance = 100 local rotatespeed = 65 local bone = nil local previousheadscale = Vector(1,1,1) hook.Add("CalcView","ArteryInventoryView",function(ply,pos,ang,fov,nearz,farz) if bone == nil then bone = LocalPlayer():LookupBone("ValveBiped.Bip01_Head1") end local view = {} --view.origin = LocalPlayer():GetBonePosition(bone) + LocalPlayer():GetUp() * 2 view.origin = pos if plyisininventory then local trot = math.rad(CurTime() * rotatespeed) local xoff = viewdistance * math.sin(trot) local yoff = viewdistance * math.cos(trot) view.origin = view.origin + Vector(xoff,yoff,10) ang.pitch = 20 ang.yaw = (-CurTime() * rotatespeed) - 90 end view.angles = ang view.fov = fov if not plyisininventory then LocalPlayer():ManipulateBoneScale(bone,Vector(0,0,0)) else LocalPlayer():ManipulateBoneScale(bone,previousheadscale) end view.drawviewer = plyisininventory return view end)