Dealman Posted June 11, 2013 Share Posted June 11, 2013 Hello, I've started working on a GUI to make changing vehicles client-side easier and I have a rather big variety of models and textures as of now and the total size of the resource is starting to get rather big. I'm wondering if there's some kind of way to have the client download a specified file within the resource from the server on demand, for example: If the player selects Infernus 1, it would have to be downloaded first. As such, the client would be able to only download the ones he'd like instead of every single one. I know there's fetchRemote, but I don't think that is quite what I need. I'm new to this whole downloading stuff within MTA so any kind of help would be greatly appreciated. If this is not possible, what would be the most efficient way to go about things? Would I need to make a separate resource for every different model and then use call? Edit: I know of downloadFile, but of course it's not to be released until MTA 1.4 Link to comment
Castillo Posted June 11, 2013 Share Posted June 11, 2013 I used fetchRemote for my server and it worked just wonderful. Link to comment
DiSaMe Posted June 11, 2013 Share Posted June 11, 2013 fileOpen fileRead fileWrite triggerClientEvent Link to comment
Dealman Posted June 11, 2013 Author Share Posted June 11, 2013 I used fetchRemote for my server and it worked just wonderful. Would Mr.Castillo perhaps be so kind to provide me with some example? As I said, I'm new to downloading files like this through MTA, am not entirely sure as to how fetchRemtoe works... I have all the files in the one same resource, but with a folder structure, would it be possible to fetch a specific file/folder within that resource using fetchRemote...? fileOpen fileRead fileWrite triggerClientEvent Would that even work? Since the file(s) need to be saved on the Client? In either way, wouldn't fetchRemote be a better approach? Link to comment
Castillo Posted June 11, 2013 Share Posted June 11, 2013 addCommandHandler ( "downloadfile", function ( ) fetchRemote ( "http://localhost:8080/image.jpg", myCallback, "", false ) end ) function myCallback ( responseData, errno ) if ( errno == 0 ) then local file = fileCreate ( "image.jpg" ) if ( file ) then fileWrite ( file, responseData ) fileClose ( file ) outputChatBox ( "image.jpg successfully downloaded and created!" ) end end end NOTE: When you use fetchRemote client side, you can't use an external web server. Link to comment
Dealman Posted June 11, 2013 Author Share Posted June 11, 2013 Thank you, will fiddle around with it a bit and see if I can get it to work! 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