mirror of
https://github.com/gmod-integration/lua.git
synced 2025-08-03 11:02:41 +00:00
feat: add screenshot title
This commit is contained in:
parent
3534141410
commit
423ca3175a
|
@ -1,5 +1,6 @@
|
||||||
local ScreenshotRequested = false
|
local ScreenshotRequested = false
|
||||||
local FailAttempts = 0
|
local FailAttempts = 0
|
||||||
|
local ScreenshotTitle = ""
|
||||||
hook.Add("PostRender", "gmInteScreenshot", function()
|
hook.Add("PostRender", "gmInteScreenshot", function()
|
||||||
if !ScreenshotRequested then return end
|
if !ScreenshotRequested then return end
|
||||||
local captureData = {
|
local captureData = {
|
||||||
|
@ -35,6 +36,7 @@ hook.Add("PostRender", "gmInteScreenshot", function()
|
||||||
gmInte.http.post("/clients/:steamID64/servers/:serverID/screenshots", {
|
gmInte.http.post("/clients/:steamID64/servers/:serverID/screenshots", {
|
||||||
["player"] = gmInte.getPlayerFormat(LocalPlayer()),
|
["player"] = gmInte.getPlayerFormat(LocalPlayer()),
|
||||||
["screenshot"] = base64Capture,
|
["screenshot"] = base64Capture,
|
||||||
|
["title"] = ScreenshotTitle,
|
||||||
["captureData"] = captureData,
|
["captureData"] = captureData,
|
||||||
["size"] = size .. "KB"
|
["size"] = size .. "KB"
|
||||||
}, function(code, body) gmInte.chatAddText(Color(255, 130, 92), gmInte.getTranslation("chat.screenshot.sent", "Screenshot sent to Discord.")) end, function(code, body)
|
}, function(code, body) gmInte.chatAddText(Color(255, 130, 92), gmInte.getTranslation("chat.screenshot.sent", "Screenshot sent to Discord.")) end, function(code, body)
|
||||||
|
@ -54,16 +56,26 @@ function gmInte.takeScreenShot()
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
concommand.Add("gmi_screen", gmInte.takeScreenShot)
|
local function extractTitleFromCmd(ply, cmd, args)
|
||||||
concommand.Add("gmod_integration_screen", gmInte.takeScreenShot)
|
if !args[1] then
|
||||||
|
ScreenshotTitle = ""
|
||||||
|
else
|
||||||
|
ScreenshotTitle = table.concat(args, " ")
|
||||||
|
end
|
||||||
|
|
||||||
|
gmInte.takeScreenShot()
|
||||||
|
end
|
||||||
|
|
||||||
|
concommand.Add("gmi_screen", extractTitleFromCmd)
|
||||||
|
concommand.Add("gmod_integration_screen", extractTitleFromCmd)
|
||||||
hook.Add("OnPlayerChat", "gmInteChatCommands", function(ply, text, teamChat, isDead)
|
hook.Add("OnPlayerChat", "gmInteChatCommands", function(ply, text, teamChat, isDead)
|
||||||
if ply != LocalPlayer() then return end
|
if ply != LocalPlayer() then return end
|
||||||
text = string.lower(text)
|
if string.len(text) < 7 then return end
|
||||||
text = string.sub(text, 2)
|
local cmdPrefix = string.sub(text, 1, 1)
|
||||||
if text == "screen" then
|
local args = string.Explode(" ", string.sub(text, 2))
|
||||||
|
if args[1] != "screen" && args[1] != "screenshot" then return end
|
||||||
|
ScreenshotTitle = table.concat(args, " ", 2)
|
||||||
gmInte.takeScreenShot()
|
gmInte.takeScreenShot()
|
||||||
return true
|
|
||||||
end
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
local contextMenuOpen = false
|
local contextMenuOpen = false
|
||||||
|
|
Loading…
Reference in New Issue
Block a user