Jump to content

Download a picture via link


WiBox

Recommended Posts

-- Server
function startImageDownload( playerToReceive )
    fetchRemote ("https://imgur.com/download/B8ta5Aa/The+Senate+upvote+this+image+of+our+glorious+ruler+so+it's+the+first+image+when+you+google+%22The%20Senate%22", myCallback, "", false, playerToReceive )
end
addCommandHandler( "d", startImageDownload)

function myCallback( responseData, errno, playerToReceive )
    if errno == 0 then
        triggerClientEvent( playerToReceive, "onClientGotImage", resourceRoot, responseData )
    end
end
-- Client
addEvent( "onClientGotImage", true )
addEventHandler( "onClientGotImage", resourceRoot,
    function( pixels )
        downloadFile( pixels )
    end
)

File doesn't exist, it is the first time I use fetchRemote, so I'm not sure what's the wrong thing in it, now I know so I can download it I should edit meta.xml, but the image has not been downloaded, so any explanations?

Edited by R.I.P Logic
Link to comment

How can I check if a link works? I've tried to write 

" https://imgur.com/download/B8ta5Aa/The+Senate+upvote+this+image+of+our+glorious+ruler+so+it's+the+first+image+when+you+google+%22The%20Senate%22 "

and it worked, :

The+Senate+upvote+this+image+of+our+glor

 

How can I know if the link will work in MTA?

Okay, thanks I tried to use, fileCreate, fileWrite, fileClose and it worked! I used outputChatBox and print, and suddenly I remembered that that encrypted language doesn't work in MTA, so I tried those 3 functions, worked. Thanks!

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