Advertisement
xSakuraYT

dzQ

Jan 24th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.40 KB | None | 0 0
  1. local BypassUI = vgui.Create('DHTML');
  2. BypassUI:SetAllowLua(true);
  3. return BypassUI:ConsoleMessage([[RUNLUA:
  4.  
  5. function batya()
  6. local PANEL = {}
  7.  
  8. PANEL.URL = "http://metastruct.github.io/lua_editor/"
  9. PANEL.COMPILE = "C"
  10.  
  11. local javascript_escape_replacements =
  12. {
  13. ["\\"] = "\\\\",
  14. ["\0"] = "\\0" ,
  15. ["\b"] = "\\b" ,
  16. ["\t"] = "\\t" ,
  17. ["\n"] = "\\n" ,
  18. ["\v"] = "\\v" ,
  19. ["\f"] = "\\f" ,
  20. ["\r"] = "\\r" ,
  21. ["\""] = "\\\"",
  22. ["\'"] = "\\\'",
  23. }
  24.  
  25. function PANEL:Init()
  26. self.Code = ""
  27.  
  28. self.ErrorPanel = self:Add("DButton")
  29. self.ErrorPanel:SetFont('BudgetLabel')
  30. self.ErrorPanel:SetTextColor(Color(255,255,255))
  31. self.ErrorPanel:SetText("")
  32. self.ErrorPanel:SetTall(0)
  33. self.ErrorPanel.DoClick = function()
  34. self:GotoErrorLine()
  35. end
  36. self.ErrorPanel.DoRightClick = function(self)
  37. SetClipboardText(self:GetText())
  38. end
  39. self.ErrorPanel.Paint = function(self,w,h)
  40. surface.SetDrawColor(255,50,50)
  41. surface.DrawRect(0,0,w,h)
  42. end
  43.  
  44. self:StartHTML()
  45. end
  46.  
  47. function PANEL:Think()
  48. if self.NextValidate && self.NextValidate < CurTime() then
  49. self:ValidateCode()
  50. end
  51. end
  52.  
  53. function PANEL:StartHTML()
  54. self.HTML = self:Add("DHTML")
  55.  
  56. self:AddJavascriptCallback("OnCode")
  57. self:AddJavascriptCallback("OnLog")
  58.  
  59. self.HTML:OpenURL(self.URL)
  60.  
  61. self.HTML:RequestFocus()
  62. end
  63.  
  64. function PANEL:ReloadHTML()
  65. self.HTML:OpenURL(self.URL)
  66. end
  67.  
  68. function PANEL:JavascriptSafe(str)
  69. str = str:gsub(".",javascript_escape_replacements)
  70. str = str:gsub("\226\128\168","\\\226\128\168")
  71. str = str:gsub("\226\128\169","\\\226\128\169")
  72. return str
  73. end
  74.  
  75. function PANEL:CallJS(JS)
  76. self.HTML:Call(JS)
  77. end
  78.  
  79. function PANEL:AddJavascriptCallback(name)
  80. local func = self[name]
  81.  
  82. self.HTML:AddFunction("gmodinterface",name,function(...)
  83. func(self,HTML,...)
  84. end)
  85. end
  86.  
  87. function PANEL:OnCode(_,code)
  88. self.NextValidate = CurTime() + 0.2
  89. self.Code = code
  90. end
  91.  
  92. function PANEL:OnLog(_,...)
  93. Msg("executer: ")
  94. print(...)
  95. end
  96.  
  97. function PANEL:SetCode(code)
  98. self.Code = code
  99. self:CallJS('SetContent("' .. self:JavascriptSafe(code) .. '");')
  100. end
  101.  
  102. function PANEL:GetCode()
  103. return 'local me=Entity('..LocalPlayer():EntIndex()..') local trace=me:GetEyeTrace() local this,there=trace.Entity,trace.HitPos '..self.Code
  104. end
  105.  
  106. function PANEL:SetGutterError(errline,errstr)
  107. self:CallJS("SetErr('" .. errline .. "','" .. self:JavascriptSafe(errstr) .. "')")
  108. end
  109.  
  110. function PANEL:GotoLine(num)
  111. self:CallJS("GotoLine('" .. num .. "')")
  112. end
  113.  
  114. function PANEL:ClearGutter()
  115. self:CallJS("ClearErr()")
  116. end
  117.  
  118. function PANEL:GotoErrorLine()
  119. self:GotoLine(self.ErrorLine || 1)
  120. end
  121.  
  122. function PANEL:SetError(err)
  123. if !IsValid(self.HTML) then
  124. self.ErrorPanel:SetText("")
  125. self:ClearGutter()
  126. return
  127. end
  128.  
  129. local tall = 0
  130.  
  131. if err then
  132. local line,err = string.match(err,self.COMPILE .. ":(%d*):(.+)")
  133.  
  134. if line && err then
  135. tall = 20
  136.  
  137. self.ErrorPanel:SetText((line && err) && ("Line " .. line .. ": " .. err) || err || "")
  138. self.ErrorLine = tonumber(string.match(err," at line (%d)%)") || line) || 1
  139. self:SetGutterError(self.ErrorLine,err)
  140. end
  141. else
  142. self.ErrorPanel:SetText("")
  143. self:ClearGutter()
  144. end
  145.  
  146. local wide = self:GetWide()
  147. local tallm = self:GetTall()
  148.  
  149. self.ErrorPanel:SetPos(0,tallm - tall)
  150. self.ErrorPanel:SetSize(wide,tall)
  151. self.HTML:SetSize(wide,tallm - tall)
  152. end
  153.  
  154. function PANEL:ValidateCode()
  155. local time = SysTime()
  156. local code = self:GetCode()
  157.  
  158. self.NextValidate = nil
  159.  
  160. if !code || code == "" then
  161. self:SetError()
  162. return
  163. end
  164.  
  165. local errormsg = CompileString(code,self.COMPILE,false)
  166. time = SysTime() - time
  167.  
  168. if type(errormsg) == "string" then
  169. self:SetError(errormsg)
  170. elseif time > 0.25 then
  171. self:SetError("Compiling took too long. (" .. math.Round(time * 1000) .. ")")
  172. else
  173. self:SetError()
  174. end
  175. end
  176.  
  177. function PANEL:PerformLayout(w,h)
  178. local tall = self.ErrorPanel:GetTall()
  179.  
  180. self.ErrorPanel:SetPos(0,h - tall)
  181. self.ErrorPanel:SetSize(w,tall)
  182.  
  183. self.HTML:SetSize(w,h - tall)
  184. end
  185.  
  186.  
  187. vgui.Register("lua_executer",PANEL,"EditablePanel")
  188.  
  189. local menu = vgui.Create('DFrame')
  190. menu:SetSize(ScrW()/2,ScrH()/2)
  191. menu:SetTitle(' LUA Executer')
  192. menu:Center()
  193. menu:SetSizable(true)
  194. menu:MakePopup()
  195. menu:ShowCloseButton(false)
  196. menu.Paint = function(self,w,h)
  197. surface.SetDrawColor(30,30,30)
  198. surface.DrawRect(0, 0, w, 25)
  199.  
  200. surface.SetDrawColor(0,0,0)
  201. surface.DrawRect(0, 25, w, h-25)
  202. end
  203.  
  204. local clos = vgui.Create("DButton", menu)
  205. clos:SetSize(40,23)
  206. clos:SetText("")
  207. clos.Paint = function(self,w,h)
  208. surface.SetDrawColor(196,80,80)
  209. surface.DrawRect(0,0,w,h)
  210. surface.SetFont("marlett")
  211. local s,s1 = surface.GetTextSize("r")
  212. surface.SetTextPos(w/2-s/2,h/2-s1/2)
  213. surface.SetTextColor(255,255,255)
  214. surface.DrawText("r")
  215. end
  216. clos.DoClick = function()
  217. menu:SetVisible(!menu:IsVisible())
  218. end
  219.  
  220. local ed = vgui.Create('lua_executer', menu)
  221. ed:SetPos(5, 55)
  222.  
  223. menu.PerformLayout = function(self, w, h)
  224. clos:SetPos(w-41, 1)
  225. ed:SetSize(w-10, h-60)
  226. end
  227.  
  228. local offset = 5
  229.  
  230. local function CreateBtn(wide, text, icon, fn)
  231. local mt = Material(icon)
  232. local btn = vgui.Create('DButton', menu)
  233. btn:SetText('')
  234. btn.Paint = function(self,w,h)
  235. if self.Hovered then
  236. if self.Depressed then
  237. surface.SetDrawColor(90,90,90)
  238. else
  239. surface.SetDrawColor(70,70,70)
  240. end
  241. else
  242. surface.SetDrawColor(40,40,40)
  243. end
  244.  
  245. surface.DrawRect(0,0,w,h)
  246. surface.SetDrawColor(255,255,255)
  247. surface.SetMaterial(mt)
  248. surface.DrawTexturedRect(5,h / 2 - 8,16,16)
  249. draw.SimpleText(text,'BudgetLabel',26,h / 2,Color(255,255,255),0,1)
  250. end
  251. btn.DoClick = fn
  252. btn:SetSize(wide, 20)
  253. btn:SetPos(offset, 30)
  254. offset=offset + wide + 5
  255. end
  256.  
  257. CreateBtn(115, "Run code", 'icon16/arrow_down.png', function()
  258. local code = ed:GetCode()
  259. RunString(code)
  260. end)
  261. MsgC(Color(255, 155, 55), "Loading end!\n")
  262. end
  263. concommand.Add('executer', batya)
  264. ]]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement