Vector Posted July 11, 2013 Share Posted July 11, 2013 Hi,I want to know if there is another way to transfer files from server to client and from client to server rather than adding a "file" node in meta.xml file. () for example. I have a lot of model/texture files and I don´t want users download all files at once. Only download the files that client need in that moment. I guess, I can use triggerClientEvent and triggerServerEvent, and send all the data of a file through this functions as a big string, and then, create the file in client-side like this: server-side local file = fileOpen (file_that_request_the_client); triggerClientEvent (client_that_request_the_file, "onFileDownload", getRootElement (), file_name, fileRead (file, fileSize (file))); fileClose (file); client-side addEvent ("onFileDownload", true); addEventHandler ("onFileDownload", getRootElement (), function (fileName, fileData) local file = fileCreate (fileName); fileWrite (file, fileData); fileClose (file); end); Is this the best way to achieve what I want, or there is another way? Link to comment
Jesseunit Posted July 11, 2013 Share Posted July 11, 2013 Hi,I want to know if there is another way to transfer files from server to client and from client to server rather than adding a "file" node in meta.xml file. () for example. I have a lot of model/texture files and I don´t want users download all files at once. Only download the files that client need in that moment. I guess, I can use triggerClientEvent and triggerServerEvent, and send all the data of a file through this functions as a big string, and then, create the file in client-side like this: server-side local file = fileOpen (file_that_request_the_client); triggerClientEvent (client_that_request_the_file, "onFileDownload", getRootElement (), file_name, fileRead (file, fileSize (file))); fileClose (file); client-side addEvent ("onFileDownload", true); addEventHandler ("onFileDownload", getRootElement (), function (fileName, fileData) local file = fileCreate (fileName); fileWrite (file, fileData); fileClose (file); end); Is this the best way to achieve what I want, or there is another way? Use either fetchRemote Or wait until MTA 1.4 is out and use downloadFile 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