Advertisement
Guest User

cl_screengrab

a guest
Sep 17th, 2013
23
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. SCRG.UPTO = 1
  3. SCRG.DATA = {}
  4.  
  5. function SCRG.ShowSC( data, ply )
  6. local isDecentRes = (ScrW()>=1600 and ScrH()>=900)
  7. local frmSG = vgui.Create("DFrame")
  8. frmSG:SetTitle("[GetCaught]: "..ply:Name() .." - "..ply:SteamID() )
  9. if isDecentRes then
  10. frmSG:SetSize( 1600, 900 ) -- Sorry if you have a resolution smaller than this lmao
  11. else
  12. frmSG:SetSize( 1024, 576)
  13. end
  14. frmSG:MakePopup()
  15. frmSG:Center()
  16. frmSG.Paint = function()
  17. surface.SetDrawColor( Color(30,30,30,255) )
  18. surface.DrawRect( 0, 0, 1600, 900 )
  19. end
  20.  
  21. local image = vgui.Create("HTML", frmSG )
  22. if isDecentRes then
  23. image:SetSize( 1488, 837 )
  24. image:SetPos( 56, 35 )
  25. image:SetHTML( [[ <img width="1440" height="810" src="data:image/jpeg;base64, ]]..data..[["/> ]] )
  26. else
  27. image:SetSize( 960, 540 )
  28. image:SetPos( 32, 30 )
  29. image:SetHTML( [[ <img width="1440" height="810" src="data:image/jpeg;base64, ]]..data..[["/> ]] )
  30. end
  31. end
  32.  
  33. net.Receive("screengrab_fwd_init", function()
  34. local ply = net.ReadEntity()
  35. ply.SG = {}
  36. ply.SG.LEN = net.ReadUInt( 32 )
  37. ply.SG.PARTS = {}
  38. chat.AddText(Color(0, 200, 0), " [GC] Taking a screenshot of "..ply:Name().." ["..ply.SG.LEN.." parts]")
  39. end)
  40.  
  41. net.Receive("screengrab_fwd", function()
  42. local ply = net.ReadEntity()
  43. local len = net.ReadUInt( 32 )
  44. local data = net.ReadData( len )
  45.  
  46. if !ply:IsValid() then print("ply not val"); return end
  47. if ply.SG == nil then print("sg nil"); return end
  48.  
  49. ply.SG.PARTS[ #ply.SG.PARTS + 1 ] = util.Decompress( data )
  50. if #ply.SG.PARTS == ply.SG.LEN then
  51. chat.AddText( Color(0,200,0), " [GC] Done "..ply:Name() )
  52. local finaldata = table.concat( ply.SG.PARTS )
  53. SCRG.ShowSC( finaldata, ply )
  54. ply.SG = nil
  55. SCRG.UPTO = 1
  56. SCRG.DATA = {}
  57. end
  58.  
  59. end)
  60.  
  61. net.Receive("screengrab_start", function()
  62. local qual = net.ReadInt( 32 )
  63. local info = {
  64. format = "jpeg",
  65. h = ScrH(),
  66. w = ScrW(),
  67. quality = qual,
  68. x = 0,
  69. y = 0
  70. }
  71. local splitamt = 20000
  72. local capdat = util.Base64Encode( render.Capture( info ) )
  73. local len = string.len( capdat )
  74. local frags = math.ceil( len / splitamt )
  75.  
  76. for i = 1, frags do
  77. local start = (i * splitamt) - splitamt + 1
  78. local stop = (i * splitamt)
  79. if stop > len then
  80. stop = len
  81. end
  82. SCRG.DATA[i] = string.sub( capdat, start, stop )
  83. end
  84.  
  85. net.Start("screengrab_start")
  86. net.WriteUInt( frags, 32 )
  87. net.SendToServer()
  88.  
  89. end)
  90.  
  91. net.Receive( "screengrab_part", function()
  92.  
  93. local nextsend = SCRG.DATA[ SCRG.UPTO ]
  94.  
  95. local len = string.len( nextsend )
  96. nextsend = util.Compress( nextsend )
  97.  
  98. net.Start( "screengrab_part")
  99. net.WriteUInt( len, 32 )
  100. net.WriteData( nextsend, len )
  101. net.SendToServer()
  102. if SCRG.UPTO == #SCRG.DATA then
  103. SCRG.UPTO = 1
  104. SCRG.DATA = {}
  105. return
  106. end
  107. SCRG.UPTO = SCRG.UPTO + 1
  108.  
  109. end)
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement