local cMenuOpen = false local pnl local ply = nil function GM:OnContextMenuOpen() cMenuOpen = !cMenuOpen gui.EnableScreenClicker(true) -- Derma Menu self.Think = function() if !cMenuOpen then return end //print(LocalPlayer():GetEyeTrace().Entity:GetClass()) if (input.IsMouseDown(MOUSE_RIGHT)) then local tr = LocalPlayer():GetEyeTrace().Entity local menu = DermaMenu() if tr:IsPlayer() and LocalPlayer():IsSuperAdmin() and pnl == nil then menu:AddOption( "Player Information", function() pnl = vgui.Create("AdminCMenu") end ) end if tr and tr:IsValid() and !tr:IsPlayer() and !tr:IsWorld() and LocalPlayer():IsAdmin() then menu:AddOption( "Remove", function() net.Start('removeEntity') net.WriteEntity(tr) net.SendToServer() end ) end menu:AddOption( "Cancel", function() end ) menu:Open() return end end end function GM:OnContextMenuClose() if cMenuOpen then return end if pnl != nil then pnl:Close() end cMenuOpen = false if pnl == nil then gui.EnableScreenClicker(false) end end // ADMIN MENU PANEL = {} PANEL.CMDS = { { txt = "Give Resource", tooltip = "Gives player the specified resource", func = function() local fr = vgui.Create("DFrame") fr:SetTitle("Give Resource") fr:SetSize(400, 120) fr:Center() fr:SetBackgroundBlur( true ) fr:MakePopup() local TextEntry = vgui.Create( "DTextEntry", fr ) TextEntry:SetSize( fr:GetWide()-100, 20 ) TextEntry:SetPos( (fr:GetWide()/2) - (TextEntry:GetWide()/2), (fr:GetTall()/2) - (TextEntry:GetTall()/2) - 5 ) TextEntry:SetText( "" ) TextEntry:RequestFocus() local lbl = vgui.Create( "DLabel", fr ) lbl:SetPos( TextEntry:GetPos(),TextEntry:GetPos()-TextEntry:GetTall() - 5 ) lbl:SetText("Resource") local NumSlider = vgui.Create( "DNumSlider", fr ) NumSlider:SetPos( TextEntry:GetPos(),TextEntry:GetPos()+10 ) NumSlider:SetSize( fr:GetWide()-100, 50 ) NumSlider:SetText( "Amount" ) NumSlider:GetTextArea():SetEditable(false) NumSlider:SetMin( 1 ) NumSlider:SetMax( 200 ) NumSlider:SetDecimals( 0 ) NumSlider:SetValue( 0 ) NumSlider.DoClick = function() print(NumSlider:GetValue()) end local dbtn = vgui.Create("DButton", fr) dbtn:SetSize( 50, 25 ) dbtn:SetPos( fr:GetWide()-dbtn:GetWide()-10, fr:GetTall()-dbtn:GetTall()-5 ) dbtn:SetText("Give") dbtn.DoClick = function() txtval = string.Trim(TextEntry:GetValue()) txtval = string.gsub(" "..txtval, "%W%l", string.upper):sub(2) if(GMS.Resources[txtval] == nil) then --This resource is not registered! LocalPlayer():PrintMessage(HUD_PRINTTALK, TextEntry:GetValue().." is not a valid resource!") else net.Start('giveres') net.WriteEntity(ply) net.WriteString(txtval) net.WriteInt(NumSlider:GetTextArea():GetValue(),32) net.SendToServer() LocalPlayer():PrintMessage(HUD_PRINTTALK, txtval.." x"..NumSlider:GetTextArea():GetValue().." has been given to "..ply:Nick()) end end end, }, /* { txt = "Test", tooltip = "Gives player the specified resource", func = function() print("TEST") end, }, */ } local targetRes local targetSkills function PANEL:Init() ply = LocalPlayer():GetEyeTrace().Entity self:SetSize(250,350) self:Center() self:SetTitle("Player Information") local sheet = vgui.Create( "DPropertySheet", self ) sheet:Dock( FILL ) // Commands local cmdpnl = vgui.Create( "DPanel", sheet ) for k,v in pairs(self.CMDS) do dpnl = vgui.Create("DButton", cmdpnl) dpnl:SetSize(224, 20) dpnl:SetPos(0,(k-1)*(dpnl:GetTall()+1)) dpnl:SetText("") dpnl:SetToolTip( v['tooltip'] ) dpnl.Paint = function() draw.RoundedBox( 4, 0, 0, self:GetWide(), self:GetTall(), Color( 78, 2, 78, 125 ) ) surface.SetFont("Default") surface.SetTextColor( 0,0,0 ) surface.SetTextPos( ( dpnl:GetWide()/2 ) - (surface.GetTextSize( v['txt'] )/2), 2) surface.DrawText(v['txt']) end dpnl.DoClick = v['func'] end cmdpnl.Paint = function( self, w, h ) draw.RoundedBox( 4, 0, 0, w, h, Color( 78, 78, 78, 125 ) ) end sheet:AddSheet( "Commands", cmdpnl, "icon16/user.png" ) // Skills local levelpnl = vgui.Create( "DPanel", sheet ) local layout = vgui.Create( "DListLayout", levelpnl ) layout:SetSize(224, 20) //Draw a background so we can see what it's doing layout:SetPaintBackground( true ) layout:SetBackgroundColor( Color( 0, 100, 100 ) ) -- Skills Update lastThinkSkills = CurTime() updateSkills(layout) layout.Think = function() if ( CurTime() >= lastThinkSkills + 3 )then layout:Clear() updateSkills(layout) lastThinkSkills = CurTime() end end levelpnl.Paint = function( self, w, h ) draw.RoundedBox( 4, 0, 0, w, h, Color( 78, 78, 78, 125 ) ) end sheet:AddSheet( "Skills", levelpnl, "icon16/wand.png" ) // Resources local respnl = vgui.Create( "DPanel", sheet ) local layout = vgui.Create( "DListLayout", respnl ) layout:SetSize(224, 20) //Draw a background so we can see what it's doing layout:SetPaintBackground( true ) layout:SetBackgroundColor( Color( 0, 100, 100 ) ) -- Resource Update lastThinkRes = CurTime() updateResources(layout) layout.Think = function() if ( CurTime() >= lastThinkRes + 3 )then layout:Clear() updateResources(layout) lastThinkRes = CurTime() end end respnl.Paint = function( self, w, h ) draw.RoundedBox( 4, 0, 0, w, h, Color( 78, 78, 78, 125 ) ) end sheet:AddSheet( "Resources", respnl, "icon16/rainbow.png" ) end function updateResources(layout) net.Start('adminCMenuResRequest') net.WriteEntity(ply) net.Receive( 'adminCMenuResSend', function() targetRes = net.ReadTable() for k,v in pairs (targetRes) do layout:Add( Label( " "..k.." x"..v ) ) end end) net.SendToServer() end function updateSkills(layout) net.Start('adminCMenuSkillRequest') net.WriteEntity(ply) net.Receive( 'adminCMenuSkillSend', function() targetSkills = net.ReadTable() for k,v in pairs (targetSkills) do layout:Add( Label( " "..k.." : "..v ) ) end end) net.SendToServer() end function PANEL:OnClose() pnl = nil gui.EnableScreenClicker(false) cMenuOpen = false self:Remove() end function PANEL:Paint() draw.RoundedBox(4, 0, 0, self:GetWide(), self:GetTall(), Color(28, 28, 28, 125)) end vgui.Register("AdminCMenu", PANEL, "DFrame")