takePlayerScreenShot | Multi Theft Auto: Wiki Skip to content

takePlayerScreenShot

Client-side
Server-side
Shared

This page is incomplete! Help wanted!

Please finish this page using the corresponding Old Wiki article.
Go to Contribution guidelines for more information.


This function forces a client to capture the current screen output and send it back to the server. The image will contain the GTA HUD and the output of any dxDraw functions that are not flagged as 'post GUI'. The image specifically excludes the chat box and all GUI (including the client console). The result is received with the event onPlayerScreenShot.

Syntax

takePlayerScreenShot ( )

Code Examples

server
local screenSizeX,screenSizeY = guiGetScreenSize() -- save the current screen dimensions
local imgtexture
local takenBy
function wepFire(weapon)
if weapon == 43 then -- if the weapon the player just fired is the camera
triggerServerEvent("onPlayerTakesPhoto",localPlayer)
end
end
addEventHandler("onClientPlayerWeaponFire",localPlayer,wepFire)
function updateLatestPhoto(img)
if imgtexture then -- clean up the old dxTextrue if there is one
destroyElement(imgtexture)
end
imgtexture = dxCreateTexture(img) -- create a new dxTexture from the image data so that we can render it using dxDrawImage
takenBy = "taken by "..getPlayerName(source) -- let's also credit the photographer
end
addEvent("updatePhoto",true)
addEventHandler("updatePhoto",root,updateLatestPhoto)
function renderPhoto()
if imgtexture then
local sizeX, sizeY = 320, 240
dxDrawImage(screenSizeX-sizeX,screenSizeY-sizeY,sizeX,sizeY,imgtexture) -- render the picture as well as the name of the photographer in the bottom right corner of the screen
dxDrawText(takenBy,screenSizeX-sizeX,screenSizeY-sizeY,screenSizeX,screenSizeY,tocolor(0,0,0))
end
end
addEventHandler("onClientRender",root,renderPhoto)

See Also