kkevihg009 Posted August 21, 2024 Posted August 21, 2024 Ola, eu queria fazer um script do qual , quando eu da /capturar [Nome do jogador] ele tira a screeshot da tela do jogador e manda para uma pasta, mais o problema não é esse, eu conseguir fazer isso mas ele não pega nenhum elemento da tela do jogador como Hud, painel F8, porque o intuito dele era fazer ele pegar alguns tipos de hacks visuais como Wall, fov etc... --- client-side local screenSource = nil local capturing = false function capturePlayerScreen(playerName) if capturing then return end capturing = true local screenWidth, screenHeight = guiGetScreenSize() screenSource = dxCreateScreenSource(screenWidth, screenHeight) addEventHandler("onClientRender", root, function() if screenSource then dxUpdateScreenSource(screenSource) local pixels = dxGetTexturePixels(screenSource) verifyPixels(pixels) local converted = dxConvertPixels(pixels, "jpeg", 100) -- envia os dados da imagem ao servidor triggerServerEvent("Screenshots", resourceRoot, converted, playerName, getTickCount()) removeEventHandler("onClientRender", root, function() end) destroyElement(screenSource) screenSource = nil capturing = false end end) end addCommandHandler("capturar", function(command, targetPlayerName) if targetPlayerName then capturePlayerScreen(targetPlayerName) else outputChatBox("Uso: /capturar [nome do jogador]") end end) function verifyPixels(pixels) local width, height = dxGetPixelsSize(pixels) local suspiciousPixels = 0 for x = 0, width - 1 do for y = 0, height - 1 do local r, g, b, a = dxGetPixelColor(pixels, x, y) if r == 0 and g == 255 and b == 0 and a > 0 then suspiciousPixels = suspiciousPixels + 1 end end end if suspiciousPixels > 0 then outputChatBox("!") end end --- server side addEvent("Screenshots", true) addEventHandler("Screenshots", root, function(imageData, playerName, number) local folderPath = "screenshots" local filePath = string.format("%s/%s_%d.jpg", folderPath, playerName, number) if not fileExists(folderPath) then fileCreate(folderPath) end local file = fileCreate(filePath) if file then fileWrite(file, imageData) fileClose(file) outputChatBox("Screenshot salva como " .. filePath) else outputChatBox("Erro ao salvar a screenshot.") end end)
Moderators Lord Henry Posted August 23, 2024 Moderators Posted August 23, 2024 (edited) Painel admin já tem essa função nativa. Selecione o jogador no painel admin, depois clique em screenshots lá no canto superior direito, e depois clique em Take New. A print pode ser vista in-game no mesmo menu ao clicar no botão View e também pode ser encontrada na pasta screenshots do resource admin. A print também pega a HUD do jogador (se estiver sendo mostrada via dxDraw), mas não pega o chatbox e nem janelas CEGUI (F1, F8, etc). Edited August 23, 2024 by Lord Henry Eu te ajudei ou achou meu comentário útil? Não esqueça de deixar um Thanks! Minhas contribuições para a comunidade: LordHenry - MTA Wiki Profile Inscreva-se no meu canal do YouTube: Lord Henry - Entertainment Discord Oficial do MTA: https://mtasa.com/discord Blacklist e Whitelist de Scripters: Planilha Por favor, não me envie mensagens privadas solicitando suporte. Crie um tópico no fórum em vez disso.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now