OnPlayerScreenShot: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Remove obsolete Requirements section)
 
(5 intermediate revisions by 4 users not shown)
Line 8: Line 8:
</syntaxhighlight>  
</syntaxhighlight>  


*'''theResource''': The resource which called [[takePlayerScreenShot]]
*'''theResource''': the [[resource]] which called [[takePlayerScreenShot]].
*'''status''': The status of the event which can be one of three values:
*'''status''': a [[string]] containing the status of the event which can be one of these values:
**''"ok"'' - The image capture was successful and imageData will contain a JPEG image.
**''"ok"'' - the image capture was successful and imageData will contain a JPEG image.
**''"disabled"'' - The image capture failed because the player has disabled screen uploads.
**''"disabled"'' - the image capture failed because the player has disabled screen uploads.
**''"minimized"'' - The image capture failed because the player has minimized the screen. (i.e. alt-tabbed)
**''"minimized"'' - the image capture failed because the player has minimized the screen (i.e. alt-tabbed).
*'''imageData''': A string which contains the JPEG image data. This can be saved with the file functions, or sent to players with triggerClientEvent or even uploaded to a web site.
**''"error"'' - the image capture failed because of an unspecified error.
*'''timestamp''': The server tick count when the capture was taken.
*'''imageData''': a [[string]] which contains the JPEG image data. This can be saved with the [[Server_Scripting_Functions#File_functions|file functions]], or sent to players with [[triggerClientEvent]] or even uploaded to a web site.
*'''tag''': The tag string passed to [[takePlayerScreenShot]].
*'''timestamp''': an [[int]] representing the server tick count when the capture was taken.
*'''tag''': a [[string]] passed to [[takePlayerScreenShot]].


==Source==
==Source==
Line 62: Line 63:
         if image then
         if image then
             dxDrawImage( 100, 250, 320, 200, image )
             dxDrawImage( 100, 250, 320, 200, image )
            outputChatBox ( "You Just Took A Screenshot", pixels )
        end
        end
     end
     end
)
)
</syntaxhighlight>
</syntaxhighlight>
</section>
</section>
==Requirements==
{{Requirements|1.3|n/a|}}


{{See also/Server event|Player events}}
{{See also/Server event|Player events}}

Latest revision as of 15:41, 7 November 2024

This event is triggered when the screen capture requested by takePlayerScreenShot has completed.

Parameters

resource theResource, string status, string imageData, int timestamp, string tag
  • theResource: the resource which called takePlayerScreenShot.
  • status: a string containing the status of the event which can be one of these values:
    • "ok" - the image capture was successful and imageData will contain a JPEG image.
    • "disabled" - the image capture failed because the player has disabled screen uploads.
    • "minimized" - the image capture failed because the player has minimized the screen (i.e. alt-tabbed).
    • "error" - the image capture failed because of an unspecified error.
  • imageData: a string which contains the JPEG image data. This can be saved with the file functions, or sent to players with triggerClientEvent or even uploaded to a web site.
  • timestamp: an int representing the server tick count when the capture was taken.
  • tag: a string passed to takePlayerScreenShot.

Source

The source of this event is the player

Example

This example captures the screen of a random player every 2 seconds and shows it to everyone:

Click to collapse [-]
Server
--------------------------------------------------
-- Take screen shot every 2 seconds
function doTakeScreenShot()
    takePlayerScreenShot( getRandomPlayer(), 320, 200 )
end
setTimer(doTakeScreenShot, 2000, 0)

--------------------------------------------------
-- Receive screen shot result
addEventHandler( "onPlayerScreenShot", root,
    function ( theResource, status, pixels, timestamp, tag )
        triggerClientEvent( root, "onMyClientScreenShot", resourceRoot, pixels )  -- Relay to all players
    end
)
Click to collapse [-]
Client
--------------------------------------------------
-- Turn image data into a texture at the client
addEvent("onMyClientScreenShot",true)
addEventHandler( "onMyClientScreenShot", resourceRoot,
    function( pixels )
        if image then
            destroyElement(image)
        end
        image = dxCreateTexture( pixels )
    end
)

--------------------------------------------------
-- Show image
addEventHandler( "onClientRender", root,
    function()
        if image then
            dxDrawImage( 100, 250, 320, 200, image )
        end
    end
)

See Also

Player events


Event functions