Jump to content

triggerLatentClientEvent...


denny199

Recommended Posts

Hi there fellow reader,

Today I was just just scripting arround and then I needed fetchRemote on the server-side to send images from a url to the client's pc without caching it on the hard-drive, now the example on the wiki (https://wiki.multitheftauto.com/wiki/FetchRemote) uses "triggerClientEvent", now I just added just in case "triggerLatentClientEvent", but now it didn't loaded the image, nor outputted something on the client-side, and there are no debug-script errors. Heres my code server-side:

addEvent ( "downloadImage", true ) 
addEventHandler( "downloadImage", root, function (player) 
fetchRemote ( "http://png-5.findicons.com/files/icons/1790/large_android/512/android_sh.png", sendPixels, "", false, player ) 
outputChatBox ( "derp" ) -- it outputted derp 
end) 
  
  
  
function sendPixels( responseData, errno, playerToReceive ) 
outputChatBox ( "derpfunc" ) -- this was too succesfully outputted 
    if errno == 0 then 
outputChatBox ( "derp2" ) -- this was too succesfully outputted 
        triggerLatentClientEvent ( playerToReceive, "sendPixels", 50000,false,playerToReceive,responseData ) 
    end 
end 

client side:

  
myTextures = {} 
downloadedimgs = 0 
  
addEvent( "sendPixels", true ) 
addEventHandler( "sendPixels", resourceRoot, 
function( pixels) 
outputChatBox ( "client" ) -- doesn't output 
    downloadedimgs = downloadedimgs + 1 
    if myTextures[downloadedimgs] then 
        destroyElement( myTextures[downloadedimgs] ) 
    end 
    myTextures[downloadedimgs] = dxCreateTexture( pixels ) 
end 
) 
  
-- this is my usage of sending a request to the server 
  
function startImageDownload() 
triggerServerEvent ( "downloadImage", localPlayer, localPlayer ) 
end 
  

So is there a way to make it work without caching the image to the clients pc and if possible using triggerLatenClientEvent?

Kindly regards,

Danny

Link to comment

That's because you attached the event client side to resourceRoot, which the source of the trigger is a player and player not belong to resourceRoot.

You have two ways to fix it, attach the event to root or change the source of the trigger to be resourceRoot.

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...