denny199 Posted December 14, 2013 Share Posted December 14, 2013 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
Gallardo9944 Posted December 15, 2013 Share Posted December 15, 2013 Well, try increasing the speed of transfering in the latent event, maybe it's not loading just cause it didn't manage to. Also, try getting the latent event state and get the percentage. Link to comment
TAPL Posted December 15, 2013 Share Posted December 15, 2013 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
denny199 Posted December 15, 2013 Author Share Posted December 15, 2013 Hahahaha, fail.... Thanks for helping me, I guess that I didn't payed attention yesterday, I was tired ;P Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now