Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local ScreenMat = CreateMaterial("ScreenMat", "Fillrate", {})
- local function screengrab(open_menu)
- file.CreateDir("screengrabs")
- hook.Add("PostRender", "Screengrab", function()
- local frame_count = FrameNumber()
- render.UpdateScreenEffectTexture(1)
- ScreenMat:SetTexture("$basetexture", render.GetScreenEffectTexture(1):GetName())
- cam.Start2D()
- surface.SetMaterial(ScreenMat)
- surface.SetDrawColor(255, 255, 255, 255)
- surface.DrawTexturedRect(0, 0, ScrW(), ScrH())
- surface.SetDrawColor(0, 255, 0, 255)
- surface.DrawRect(0, 0, 10, 10)
- file.Write(string.format("screengrabs/%i.jpg", os.time()), render.Capture{
- format = "jpg",
- quality = 100,
- x = 0, y = 0,
- w = ScrW(), h = ScrH(),
- })
- cam.End2D()
- if frame_count ~= FrameNumber() then
- while true do end
- end
- if open_menu then
- gui.ActivateGameUI()
- end
- hook.Remove("PostRender", "Screengrab")
- end)
- end
- concommand.Add("screengrab", function()
- local escape_menu = gui.IsGameUIVisible()
- if escape_menu then
- gui.HideGameUI()
- end
- screengrab(escape_menu)
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement