Scripting Moderators thisdp Posted May 21, 2016 Scripting Moderators Share Posted May 21, 2016 i can't use fetchRemote in client side. And if i use fetchRemote and triggerClientEvent, the server's bandwidth can't hold these files. Link to comment
Saml1er Posted May 21, 2016 Share Posted May 21, 2016 Use fetchRemote server side and send data to client using triggerLatentClientEvent. Link to comment
Scripting Moderators thisdp Posted May 22, 2016 Author Scripting Moderators Share Posted May 22, 2016 Use fetchRemote server side and send data to client using triggerLatentClientEvent. There's no way to let client download files from other website? Link to comment
Noki Posted May 22, 2016 Share Posted May 22, 2016 No, because if clients were able to use fetchRemote and callRemote, a server with a large amount of players could potentially set up a large botnet. Link to comment
Scripting Moderators thisdp Posted May 22, 2016 Author Scripting Moderators Share Posted May 22, 2016 No, because if clients were able to use fetchRemote and callRemote, a server with a large amount of players could potentially set up a large botnet. Just download can cause botnet? Link to comment
Wojak Posted May 23, 2016 Share Posted May 23, 2016 Not tested, but I think that you can exploit the CEF to download some files directly (website - > client): Images: local webBrowser = createBrowser(Width, Height, false, false) -- Width, Height of the image addEventHandler("onClientBrowserCreated", webBrowser, function() loadBrowserURL(webBrowser, "http://direct_hotlink_to_image.png") --note that at this point the user will likely revive a dialog to whitelist the domain, and the rest of the script will fail if he doesn't... --also there will be problems if the hosting site contains adds... end) addEventHandler ( "onClientBrowserDocumentReady" , root , function ( url ) --domain already whitelisted if source == webBrowser then encodeImage() end end) addEventHandler ( "onClientBrowserWhitelistChange" , root , function( url ) --domain whitelisted by the user if source == webBrowser then encodeImage() end end) function encodeImage() local data = dxGetTexturePixels(webBrowser) destroyElement(webBrowser) local newImg = fileCreate('img.png') fileWrite(newImg, data) fileClose(newImg) end Small text files (less then 2mb): local webBrowser = createBrowser(Width, Height, false, false) -- Width, Height do not matter addEventHandler("onClientBrowserCreated", webBrowser, function() loadBrowserURL(webBrowser, "http://direct_hotlink_to_file.txt") --note that at this point the user will likely revive a dialog to whitelist the domain, and the rest of the script will fail if he doesn't... --also there will be problems if the hosting site contains adds... end) addEventHandler ( "onClientBrowserDocumentReady" , root , function ( url ) --domain already whitelisted if source == webBrowser then getBrowserSource(webBrowser, encodeFile(code)) end end) addEventHandler ( "onClientBrowserWhitelistChange" , root , function( url ) --domain whitelisted by the user if source == webBrowser then getBrowserSource(webBrowser, encodeFile(code)) end end) function encodeFile(code) destroyElement(webBrowser) local newtxt = fileCreate('test.txt') fileWrite(newtxt, data) fileClose(newtxt) end Link to comment
Scripting Moderators thisdp Posted May 23, 2016 Author Scripting Moderators Share Posted May 23, 2016 Not tested, but I think that you can exploit the CEF to download some files directly (website - > client):Images: local webBrowser = createBrowser(Width, Height, false, false) -- Width, Height of the image addEventHandler("onClientBrowserCreated", webBrowser, function() loadBrowserURL(webBrowser, "http://direct_hotlink_to_image.png") --note that at this point the user will likely revive a dialog to whitelist the domain, and the rest of the script will fail if he doesn't... --also there will be problems if the hosting site contains adds... end) addEventHandler ( "onClientBrowserDocumentReady" , root , function ( url ) --domain already whitelisted if source == webBrowser then encodeImage() end end) addEventHandler ( "onClientBrowserWhitelistChange" , root , function( url ) --domain whitelisted by the user if source == webBrowser then encodeImage() end end) function encodeImage() local data = dxGetTexturePixels(webBrowser) destroyElement(webBrowser) local newImg = fileCreate('img.png') fileWrite(newImg, data) fileClose(newImg) end Small text files (less then 2mb): local webBrowser = createBrowser(Width, Height, false, false) -- Width, Height do not matter addEventHandler("onClientBrowserCreated", webBrowser, function() loadBrowserURL(webBrowser, "http://direct_hotlink_to_file.txt") --note that at this point the user will likely revive a dialog to whitelist the domain, and the rest of the script will fail if he doesn't... --also there will be problems if the hosting site contains adds... end) addEventHandler ( "onClientBrowserDocumentReady" , root , function ( url ) --domain already whitelisted if source == webBrowser then getBrowserSource(webBrowser, encodeFile(code)) end end) addEventHandler ( "onClientBrowserWhitelistChange" , root , function( url ) --domain whitelisted by the user if source == webBrowser then getBrowserSource(webBrowser, encodeFile(code)) end end) function encodeFile(code) destroyElement(webBrowser) local newtxt = fileCreate('test.txt') fileWrite(newtxt, data) fileClose(newtxt) end thank you all the same. Actually I found a better way, but it is complicate matters. I can use a socket system with file system as Downloading System. Like node.js or a game engine(like love2d). I can open it manually while I am in the server. Create an interface between MTA Client and Downloading System with a file, and download files with it's socket system. 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