Jump to content

[help] fetchRemote table


#RooTs

Recommended Posts

is that a good guy can make a table for me to add multiple images?

example

table,{ 
 image01 = "http://www.example.com/image.jpg", 
 image02 = "http://www.example.com/image2.jpg", 
 image03 = "http://www.example.com/image3.jpg", 
} 

all my code

server.lua

function startImageDownload( playerToReceive ) 
    fetchRemote ( "http://www.example.com/image.jpg", myCallback, "", false, playerToReceive ) 
end 
  
function myCallback( responseData, errno, playerToReceive ) 
    if errno == 0 then 
        triggerClientEvent( playerToReceive, "onClientGotImage", resourceRoot, responseData ) 
    end 
end 

client.lua

addEvent( "onClientGotImage", true ) 
addEventHandler( "onClientGotImage", resourceRoot, 
    function( pixels ) 
        if myTexture then 
            destroyElement( myTexture ) 
        end 
        myTexture = dxCreateTexture( pixels ) 
    end 
) 
  
addEventHandler("onClientRender", root, 
    function() 
        if myTexture then 
            local w,h = dxGetMaterialSize( myTexture ) 
            dxDrawImage( 200, 100, w, h, myTexture ) 
        end 
    end 
) 

Link to comment
local images ={ 
   {"", 1} 
} 
  
function startDownloadImage(playerToReceive) 
   for i = 1 , #images do 
       fetchRemote(images, myCallback, "", false, playerdToReceive) 
   end 
end 
  
function myCallback(responseData, errno, playerToReceive) 
   if errno == 0 then 
      triggerClientEvent(playerToReceive, "onClientGotImage", resourceRoot, responseData) 
   end 
end    

Link to comment
local images ={ 
   {"", 1} 
} 
  
function startDownloadImage(playerToReceive) 
   for i = 1 , #images do 
       fetchRemote(images, myCallback, "", false, playerdToReceive) 
   end 
end 
  
function myCallback(responseData, errno, playerToReceive) 
   if errno == 0 then 
      triggerClientEvent(playerToReceive, "onClientGotImage", resourceRoot, responseData) 
   end 
end    

fetchRemote(images[i], myCallback, "", false, playerdToReceive) 

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