Advertisement
Guest User

ZARP Gaming "Anti-Cheat" Screenshot Client Code

a guest
Jan 21st, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.07 KB | None | 0 0
  1.  
  2. local videoRecord = video.Record
  3. local httpPost = http.Post
  4. local ostime = os.time
  5. local _tostring = tostring
  6. local _ScrW = ScrW
  7. local _ScrH = ScrH
  8. local mathClamp = math.Clamp
  9. local netReceive = net.Receive
  10. local hookAdd = hook.Add
  11. local hookRemove = hook.Remove
  12. local renderCapture = render.Capture
  13. local strformat = string.format
  14. local fileOpen = file.Open
  15. local timerSimple = timer.Simple
  16. local netReadUInt = net.ReadUInt
  17. local renderGetTexture = render.GetScreenEffectTexture
  18. local renderCopy = render.CopyTexture
  19. local renderPush = render.PushRenderTarget
  20. local renderPop = render.PopRenderTarget
  21. local renderUpdate = render.UpdateScreenEffectTexture
  22. local enc = util.Base64Encode
  23. local drawTexture = render.DrawTextureToScreen
  24.  
  25. FAdmin.StartHooks["AntiCheat"] = function()
  26.     FAdmin.Access.AddPrivilege("AntiCheat", 3)
  27.     FAdmin.Access.AddPrivilege("ExtraAntiCheat", 3)
  28.     FAdmin.Commands.AddCommand("anticheatrequest", nil, "<Player>")
  29.  
  30.     FAdmin.ScoreBoard.Player:AddActionButton("Anti Cheat Request", "fadmin/ico-zarpadmin.png", Color(255, 130, 0, 255),
  31.     function(ply) return FAdmin.Access.PlayerHasPrivilege(LocalPlayer(), "AntiCheat", ply) end, function(ply, button)
  32.         local menu = DermaMenu()
  33.         local Title = vgui.Create("DLabel")
  34.         Title:SetText("  Which method?\n")
  35.         Title:SetFont("UiBold")
  36.         Title:SizeToContents()
  37.         Title:SetTextColor(color_black)
  38.  
  39.         menu:AddPanel(Title)
  40.         menu:AddOption("Standard", function() RunConsoleCommand("_FAdmin", "anticheatrequest", ply:UserID(), 1) end)
  41.         menu:AddOption("Video Frame", function() RunConsoleCommand("_FAdmin", "anticheatrequest", ply:UserID(), 2)  end)
  42.         menu:AddOption("Internal", function() RunConsoleCommand("_FAdmin", "anticheatrequest", ply:UserID(), 3)  end)
  43.            
  44.         if FAdmin.Access.PlayerHasPrivilege(LocalPlayer(), "ExtraAntiCheat", ply) then/
  45.             menu:AddOption("FB", function() RunConsoleCommand("_FAdmin", "anticheatrequest", ply:UserID(), 4)  end)
  46.         end
  47.         menu:Open()
  48.     end)
  49. end
  50.  
  51. local newRT = GetRenderTarget("_rt_zarp_1", _ScrW(), _ScrH(), false)
  52. hookAdd("PostRender", "CopyRT", function()
  53.     renderCopy(renderGetTexture(0), newRT)
  54. end)
  55.  
  56. local function CaptureSingleVideoFrame()
  57.     local id64 = LocalPlayer():SteamID64()
  58.     local id = _tostring(netReadUInt(32))
  59.    
  60.     local CaptureFunction = function()
  61.         renderPush(newRT)
  62.         local writer = videoRecord({
  63.             container = "webm",
  64.             video = "vp8",
  65.             quality = 100,
  66.             audio = "vorbis",
  67.             bitrate = 2000,
  68.             fps = 1,
  69.             lockfps = 1,
  70.             name = id,
  71.             width = mathClamp(_ScrW(), 0, 1920),
  72.             height = mathClamp(_ScrH(), 0, 1080),
  73.         })
  74.         writer:SetRecordSound( false )
  75.         writer:AddFrame(1, true)
  76.         writer:Finish()
  77.         renderPop()
  78.     end
  79.     CaptureFunction()
  80.  
  81.     timerSimple(.5, function()
  82.         local f = fileOpen(strformat("videos/%s.webm",id), "rb", "GAME")
  83.         if not f then return end
  84.         local data = f:Read(f:Size())
  85.         f:Close()
  86.        
  87.         if (data) then
  88.             data = enc(data)
  89.             httpPost("http://api2.friendlyplayers.com/webcheck.php", {name = id64, unq = id, data = data, webm = "1"})
  90.         end
  91.     end)
  92. end
  93. netReceive("CaptureSingleVideoFrame", CaptureSingleVideoFrame)
  94.  
  95. local function CaptureRenderImage()
  96.     local id64 = LocalPlayer():SteamID64()
  97.     local id = _tostring(netReadUInt(32))
  98.     local image = nil
  99.  
  100.     local CaptureFunction = function()
  101.             renderPush(newRT)
  102.             image = renderCapture({
  103.             format = "jpeg",
  104.             quality = "80",
  105.             w = _ScrW(),
  106.             h = _ScrH(),
  107.             x = 0,
  108.             y = 0
  109.         })
  110.         renderPop()
  111.     end
  112.     CaptureFunction()
  113.  
  114.     timerSimple(.5 , function()
  115.         if (image ~= nil) then
  116.             local data = enc(image)
  117.             httpPost("http://api2.friendlyplayers.com/webcheck.php", {name = id64, unq = id, data = data, webm = "0"})
  118.         end
  119.     end)
  120. end
  121. netReceive("CaptureRenderImage", CaptureRenderImage)
  122.  
  123. local function CaptureInternalImage()
  124.     local id64 = LocalPlayer():SteamID64()
  125.     local id = _tostring(netReadUInt(32))
  126.     LocalPlayer():ConCommand(strformat("con_filter_enable 1; con_filter_text_out %s.jpg; __SCREENSHOT_INTERNAL %s", id, id))
  127.  
  128.     timerSimple(.5, function()
  129.         LocalPlayer():ConCommand("con_filter_enable 0; con_filter_text_out ''")
  130.         local f = fileOpen(strformat("screenshots/%s.jpg", id), "rb", "GAME")
  131.         if not f then return end
  132.         local data = f:Read(f:Size())
  133.         f:Close()
  134.        
  135.         if (data) then
  136.             data = enc(data)
  137.             httpPost("http://api2.friendlyplayers.com/webcheck.php", {name = id64, unq = id, data = data, webm = "0"})
  138.         end
  139.     end)
  140. end
  141. netReceive("CaptureInternalImage", CaptureInternalImage)
  142.  
  143. local function CaptureFB()
  144.     local id64 = LocalPlayer():SteamID64()
  145.     local id = _tostring(netReadUInt(32))
  146.    
  147.     drawTexture(renderGetTexture())
  148.     local image = renderCapture({
  149.         format = "jpeg",
  150.         quality = "80",
  151.         w = _ScrW(),
  152.         h = _ScrH(),
  153.         x = 0,
  154.         y = 0
  155.     })
  156.     if (image ~= nil) then
  157.         local data = enc(image)
  158.         httpPost("http://api2.friendlyplayers.com/webcheck.php", {name = id64, unq = id, data = data, webm = "0"})
  159.     end
  160. end
  161. netReceive("CaptureFB", CaptureFB)
  162.  
  163. hookAdd("DrawOverlay", "CaptureFB", function()
  164.     renderUpdate()
  165. end)
  166.  
  167. local function OpenURL()
  168.     local link = net.ReadString()
  169.     gui.OpenURL(link)
  170. end
  171. net.Receive("OpenURL", OpenURL)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement