ServersYour serverFor creatorsForumFAQDocumentationSecurity
Download the launcher
  1. Documentation
  2. Server functions
  3. takePlayerScreenShot

Function

takePlayerScreenShot

Takes a screenshot of the player's game (JPEG, without the overlay). The result arrives in the onPlayerScreenShot event.

Syntax

bool takePlayerScreenShot(player thePlayer, int width, int height [, string tag = "", int quality = 30, int maxBandwidth, int maxPacketSize, bool includeUI = false])

Arguments

thePlayerplayer
The player.
widthint
Width 1-4096.
heightint
Height 1-4096.
tagstring, optional = ""
Any text passed to the event.
qualityint, optional = 30
JPEG quality 0-100.
maxBandwidthint, optional
Accepted for compatibility; the image is sent at once.
maxPacketSizeint, optional
Accepted for compatibility.
includeUIbool, optional = false
true = a shot with the interface: CEF panels, dxDraw, GUI and HUD (as the player sees it).Not in MTA:SA

Differences from MTA:SA

  • Arguments in a different colour differ from MTA:SA.

In MTA:SA

takePlayerScreenShot(player thePlayer, int width, int height, string tag = "", int quality = 30, int maxBandwidth = 5000, int maxPacketSize = 500)

Returns

true if the request was sent.

Example

addCommandHandler("zrzut", function(admin, cmd, name)
    local target = name and getPlayerFromName(name)
    if target then
        takePlayerScreenShot(target, 960, 540, getPlayerName(admin), 60)
    end
end)

addEventHandler("onPlayerScreenShot", root, function(res, status, imageData, timestamp, tag)
    if status == "ok" then
        local f = fileCreate("zrzuty/" .. getPlayerName(source) .. "_" .. timestamp .. ".jpg")
        fileWrite(f, imageData)
        fileClose(f)
    end
end)

See also