Jump to content

Usage of dxCreateScreenSource


Recommended Posts

Hello MTA, I have another small issue on my hand, but not so much an issue.

Using dxCreateScreenSource is there a way to transmit the taken image from one clients screen and send the same image to other players? I am working on a speedcam that takes a photo of the player who sped and want to transit the image to every police on duty, the image displays to all police and to the violator only the police receive an image of themselves.

Link to comment

OK. So I am not exactly sure the issue here, but it fails to show the photo to anyone.

Client:

addEvent("onMyClientScreenShot",true) 
addEventHandler( "onMyClientScreenShot", resourceRoot, 
    function( pixels ) 
        if image then 
            destroyElement(image) 
        end 
        image = dxCreateTexture( pixels ) 
        daPic() 
    end 
) 
  
--local screen = dxCreateScreenSource ( 340, 380 ); 
local sWidth,sHeight = guiGetScreenSize() 
  
function daPic() 
    dxUpdateScreenSource(image); 
    addEventHandler("onClientRender", root, showSpeedPic) 
    setTimer(removeDaAnnoyingThingy, 5000, 1); 
end 
addEvent("showPicture", true) 
addEventHandler("showPicture", getLocalPlayer(), daPic) 
  
function showSpeedPic() 
    rect =  dxDrawRectangle(20.0,209.0,295.0,255.0,tocolor(0,0,0,140),false) 
    dxDrawImage( 28.0,217.0,279.0,238.0, image) 
end 
  
function removeDaAnnoyingThingy() 
    removeEventHandler("onClientRender", root, showSpeedPic) 
end 
-------------------------------------------------- 
--[[ Show image 
addEventHandler( "onClientRender", root, 
    function() 
        if image then 
            rect =  dxDrawRectangle(20.0,209.0,295.0,255.0,tocolor(0,0,0,140),false) 
            dxDrawImage( 28.0,217.0,279.0,238.0, image) 
            setTimer(removeDaAnnoyingThingy, 5000, 1); 
        end 
    end 
)]] 
  
function getScreenSize(value,thePlayer) 
    local x,y = guiGetScreenSize() 
    triggerServerEvent("takePicture",getLocalPlayer(),value,thePlayer,x,y) 
end 
addEvent("getScreenSize",true) 
addEventHandler("getScreenSize",getRootElement(),getScreenSize) 

Server:

function takePicture(value,thePlayer,x,y) 
    takePlayerScreenShot(thePlayer,x,y,"speedcam",100) 
end 
addEventHandler( "onPlayerScreenShot", root, 
    function ( theResource, status, pixels, timestamp, tag ) 
        triggerClientEvent( root, "onMyClientScreenShot", resourceRoot, pixels )  -- Relay to all players 
    end 
) 

And I have added

triggerClientEvent("getScreenSize",getRootElement(),value,thePlayer) 

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...