mirror of
https://github.com/gmod-integration/lua.git
synced 2025-03-15 22:07:34 +00:00
edit: screenshot take system
This commit is contained in:
parent
299b07a9ed
commit
b654535813
|
@ -17,6 +17,11 @@ hook.Add("PostRender", "gmInteScreenshot", function()
|
||||||
}
|
}
|
||||||
|
|
||||||
local screenCapture = render.Capture(captureData)
|
local screenCapture = render.Capture(captureData)
|
||||||
|
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.")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
screenCapture = util.Base64Encode(screenCapture)
|
screenCapture = util.Base64Encode(screenCapture)
|
||||||
|
|
||||||
local size = math.Round(string.len(screenCapture) / 1024)
|
local size = math.Round(string.len(screenCapture) / 1024)
|
||||||
|
@ -31,6 +36,7 @@ hook.Add("PostRender", "gmInteScreenshot", function()
|
||||||
},
|
},
|
||||||
function(code, body)
|
function(code, body)
|
||||||
gmInte.log("Screenshot sent to Discord", true)
|
gmInte.log("Screenshot sent to Discord", true)
|
||||||
|
chat.AddText(Color(255, 130, 92), "[Gmod Integration] ", Color(255, 255, 255), "Screenshot sent to Discord.")
|
||||||
end,
|
end,
|
||||||
function(code, body)
|
function(code, body)
|
||||||
gmInte.log("Screenshot failed to send to Discord, error code: " .. code, true)
|
gmInte.log("Screenshot failed to send to Discord, error code: " .. code, true)
|
||||||
|
@ -42,13 +48,8 @@ end)
|
||||||
// Methods
|
// Methods
|
||||||
//
|
//
|
||||||
|
|
||||||
function gmInte.takeScreenShot(serverID, authToken)
|
function gmInte.takeScreenShot()
|
||||||
gmInte.config.id = serverID
|
ScreenshotRequested = true
|
||||||
gmInte.config.token = authToken
|
|
||||||
|
|
||||||
timer.Simple(0.2, function()
|
|
||||||
ScreenshotRequested = true
|
|
||||||
end)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -56,7 +57,7 @@ end
|
||||||
//
|
//
|
||||||
|
|
||||||
concommand.Add("gmod_integration_screenshot", function()
|
concommand.Add("gmod_integration_screenshot", function()
|
||||||
gmInte.SendNet("takeScreenShot")
|
gmInte.takeScreenShot()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -69,6 +70,7 @@ hook.Add("OnPlayerChat", "gmInteChatCommands", function(ply, text, teamChat, isD
|
||||||
text = string.sub(text, 2)
|
text = string.sub(text, 2)
|
||||||
|
|
||||||
if (text == "screen") then
|
if (text == "screen") then
|
||||||
gmInte.SendNet("takeScreenShot")
|
gmInte.takeScreenShot()
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
end)
|
end)
|
|
@ -23,6 +23,7 @@ hook.Add("PostRender", "gmInte:PostRender:Stream:Frame", function()
|
||||||
}
|
}
|
||||||
|
|
||||||
local screenCapture = render.Capture(captureConfig)
|
local screenCapture = render.Capture(captureConfig)
|
||||||
|
if (!screenCapture) then return end
|
||||||
screenCapture = util.Base64Encode(screenCapture)
|
screenCapture = util.Base64Encode(screenCapture)
|
||||||
|
|
||||||
local size = math.Round(string.len(screenCapture) / 1024)
|
local size = math.Round(string.len(screenCapture) / 1024)
|
||||||
|
@ -45,33 +46,33 @@ hook.Add("PostRender", "gmInte:PostRender:Stream:Frame", function()
|
||||||
StreamsRequeted = false
|
StreamsRequeted = false
|
||||||
end)
|
end)
|
||||||
|
|
||||||
//
|
-- //
|
||||||
// Methods
|
-- // Methods
|
||||||
//
|
-- //
|
||||||
|
|
||||||
function gmInte.takeScreenShot(serverID, authToken)
|
-- function gmInte.takeScreenShot(serverID, authToken)
|
||||||
gmInte.config.id = serverID
|
-- gmInte.config.id = serverID
|
||||||
gmInte.config.token = authToken
|
-- gmInte.config.token = authToken
|
||||||
StreamsRequeted = true
|
-- StreamsRequeted = true
|
||||||
end
|
-- end
|
||||||
|
|
||||||
function gmInte.stopScreenShot()
|
-- function gmInte.stopScreenShot()
|
||||||
StreamsRequeted = false
|
-- StreamsRequeted = false
|
||||||
end
|
-- end
|
||||||
|
|
||||||
//
|
-- //
|
||||||
// Console Commands
|
-- // Console Commands
|
||||||
//
|
-- //
|
||||||
|
|
||||||
concommand.Add("gmod_integration_stream", function()
|
-- concommand.Add("gmod_integration_stream", function()
|
||||||
StreamsRequeted = !StreamsRequeted
|
-- StreamsRequeted = !StreamsRequeted
|
||||||
gmInte.log("Streaming frames to WebPanel: " .. tostring(StreamsRequeted))
|
-- gmInte.log("Streaming frames to WebPanel: " .. tostring(StreamsRequeted))
|
||||||
|
|
||||||
-- if (StreamsRequeted) then
|
-- -- if (StreamsRequeted) then
|
||||||
-- gmInte.stopScreenShot()
|
-- -- gmInte.stopScreenShot()
|
||||||
-- gmInte.log("Stopped streaming frames to WebPanel")
|
-- -- gmInte.log("Stopped streaming frames to WebPanel")
|
||||||
-- else
|
-- -- else
|
||||||
-- gmInte.SendNet("getSingleUseToken")
|
-- -- gmInte.SendNet("getSingleUseToken")
|
||||||
-- gmInte.log("Started streaming frames to WebPanel")
|
-- -- gmInte.log("Started streaming frames to WebPanel")
|
||||||
-- end
|
-- -- end
|
||||||
end)
|
-- end)
|
|
@ -12,10 +12,10 @@ local netSend = {
|
||||||
["wsRelayDiscordChat"] = 1,
|
["wsRelayDiscordChat"] = 1,
|
||||||
["adminConfig"] = 2,
|
["adminConfig"] = 2,
|
||||||
["testApiConnection"] = 3,
|
["testApiConnection"] = 3,
|
||||||
["screenshotToken"] = 4,
|
|
||||||
["publicConfig"] = 5,
|
["publicConfig"] = 5,
|
||||||
["chatColorMessage"] = 6,
|
["chatColorMessage"] = 6,
|
||||||
["openVerifPopup"] = 7
|
["openVerifPopup"] = 7,
|
||||||
|
["savePlayerToken"] = 8
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send
|
// Send
|
||||||
|
@ -59,6 +59,9 @@ local netReceive = {
|
||||||
end,
|
end,
|
||||||
[6] = function(ply)
|
[6] = function(ply)
|
||||||
gmInte.verifyPlayer(ply)
|
gmInte.verifyPlayer(ply)
|
||||||
|
end,
|
||||||
|
[7] = function(ply, data)
|
||||||
|
sendPlayerToken(ply)
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,24 +0,0 @@
|
||||||
//
|
|
||||||
// Websocket
|
|
||||||
//
|
|
||||||
|
|
||||||
function gmInte.wsPlayerScreen(data)
|
|
||||||
for _, ply in pairs(player.GetAll()) do
|
|
||||||
if (ply:SteamID64() == data.steamID64) then
|
|
||||||
gmInte.takeScreenshot(ply)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
//
|
|
||||||
// Methods
|
|
||||||
//
|
|
||||||
|
|
||||||
function gmInte.takeScreenshot(ply)
|
|
||||||
gmInte.getClientOneTimeToken(ply, function(oneTime)
|
|
||||||
gmInte.SendNet("screenshotToken", {
|
|
||||||
["serverID"] = gmInte.config.id,
|
|
||||||
["oneTimeToken"] = oneTime
|
|
||||||
}, ply)
|
|
||||||
end)
|
|
||||||
end
|
|
Loading…
Reference in New Issue
Block a user