mirror of
https://github.com/gmod-integration/lua.git
synced 2025-03-15 22:07:34 +00:00
add: try 3 time for the screenshot before cancel
This commit is contained in:
parent
f6f47e2525
commit
ce4d1be667
|
@ -3,6 +3,7 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
local ScreenshotRequested = false
|
local ScreenshotRequested = false
|
||||||
|
local FailAttempts = 0
|
||||||
hook.Add("PostRender", "gmInteScreenshot", function()
|
hook.Add("PostRender", "gmInteScreenshot", function()
|
||||||
if (!ScreenshotRequested) then return end
|
if (!ScreenshotRequested) then return end
|
||||||
ScreenshotRequested = false
|
ScreenshotRequested = false
|
||||||
|
@ -18,19 +19,29 @@ hook.Add("PostRender", "gmInteScreenshot", function()
|
||||||
|
|
||||||
local screenCapture = render.Capture(captureData)
|
local screenCapture = render.Capture(captureData)
|
||||||
if (!screenCapture) then
|
if (!screenCapture) then
|
||||||
chat.AddText(Color(255, 130, 92), "[Gmod Integration] ", Color(102, 63, 63), "Failed to take screenshot, your system may not support this feature.")
|
if (FailAttempts < 3) then
|
||||||
return
|
timer.Simple(0.5, function()
|
||||||
|
ScreenshotRequested = true
|
||||||
|
FailAttempts = FailAttempts + 1
|
||||||
|
gmInte.log("Failed to take screenshot, retrying... (" .. FailAttempts .. "/3)", true)
|
||||||
|
end)
|
||||||
|
return
|
||||||
|
else
|
||||||
|
FailAttempts = 0
|
||||||
|
chat.AddText(Color(255, 130, 92), "[Gmod Integration] ", Color(102, 63, 63), "Failed to take screenshot, your system may not support this feature.")
|
||||||
|
return
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
screenCapture = util.Base64Encode(screenCapture)
|
local base64Capture = util.Base64Encode(screenCapture)
|
||||||
|
|
||||||
local size = math.Round(string.len(screenCapture) / 1024)
|
local size = math.Round(string.len(base64Capture) / 1024)
|
||||||
gmInte.log("Screenshot Taken - " .. size .. "KB", true)
|
gmInte.log("Screenshot Taken - " .. size .. "KB", true)
|
||||||
|
|
||||||
gmInte.http.post("/screenshots",
|
gmInte.http.post("/screenshots",
|
||||||
{
|
{
|
||||||
["player"] = gmInte.getPlayerFormat(LocalPlayer()),
|
["player"] = gmInte.getPlayerFormat(LocalPlayer()),
|
||||||
["screenshot"] = screenCapture,
|
["screenshot"] = base64Capture,
|
||||||
["captureData"] = captureData,
|
["captureData"] = captureData,
|
||||||
["size"] = size .. "KB"
|
["size"] = size .. "KB"
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue
Block a user