Jump to content

[SOLVED] fetchRemote doesn't work


ozulus

Recommended Posts

try this:

server:

function onWin (winner) 
    outputChatBox ( "event called, fetching image..." ) 
     
    fetchRemote ( "http://i.hizliresim.com/Po0XD7.jpg",  
        function ( response, error ) 
            if error == 0 then 
                if winner then 
                    triggerClientEvent ( winner, "onClientGotImage", winner, response ) 
                    outputChatBox ( "data sucessfully send to the winner" ) 
                else 
                    outputChatBox ( "bad argument (winner) ("..tostring(winner)..")" ) 
                end 
            else     
                outputChatBox ( "error "..error.." when fetching image." ) 
            end 
        end 
    ) 
end 
addEvent("onPlayerDestructionDerbyWin",true) 
addEventHandler("onPlayerDestructionDerbyWin",root,onWin) 

client:

local myTexture 
  
addEvent( "onClientGotImage", true ) 
addEventHandler( "onClientGotImage", root, 
    function( pixels ) 
        outputChatBox ( "client: ok." ) 
         
        if myTexture and isElement ( 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 
) 

basically i only changed resourceRoot to root in the client script (line 4) also i've added some debug texts, if that doesn't work make sure onPlayerDestructionDerbyWin is called somewhere.

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