Rotti Posted March 23, 2013 Share Posted March 23, 2013 Hello, I have a lot of carmods on my server. But if a new Player connects he has to wait very long until the carmods are downloaded. So is it possible that the carmods will download after he has logged in? So that the new player connects, everything will download, the login gui comes, he logs in and then the carmods begin to download so that he can play while the carmods are loading. Link to comment
Rotti Posted March 23, 2013 Author Share Posted March 23, 2013 Not even with a short script? Link to comment
EstrategiaGTA Posted March 23, 2013 Share Posted March 23, 2013 No man, that's impossible. The players must download the files... Link to comment
Rotti Posted March 23, 2013 Author Share Posted March 23, 2013 ok thank you for the quick answer Link to comment
Scripting Moderators Sarrum Posted March 23, 2013 Scripting Moderators Share Posted March 23, 2013 downloadFile In 1.4 Link to comment
ixjf Posted March 23, 2013 Share Posted March 23, 2013 No, isn't possible. It is possible. As for the downloadFile function, for now there are ways to do the same job. Link to comment
EstrategiaGTA Posted March 23, 2013 Share Posted March 23, 2013 No, isn't possible. It is possible. As for the downloadFile function, for now there are ways to do the same job. But with the version 1.4, so isn't possible for the moment. Link to comment
ixjf Posted March 23, 2013 Share Posted March 23, 2013 No, it is possible at the moment. Link to comment
EstrategiaGTA Posted March 23, 2013 Share Posted March 23, 2013 No, it is possible at the moment. No, it is possible only for Multi Theft Auto 1.4. And that version isn't yet. Link to comment
ixjf Posted March 23, 2013 Share Posted March 23, 2013 https://community.multitheftauto.com/index.php?p= ... ls&id=3379 Now tell me it isn't possible. Link to comment
Rotti Posted March 23, 2013 Author Share Posted March 23, 2013 ok, ok i'll test it. So is it like that: function download () downloadFile("carmods") --carmods is the name of the foulder end addEventHandler("onPlayerLogin", getRootElement(), download) Link to comment
ixjf Posted March 23, 2013 Share Posted March 23, 2013 (edited) No, it isn't. There is a list of functions and events in the description of the resource. The syntax of the function downloadFile is the following: boolean downloadFile ( string filePath, string savePath, int interval ) I added a symbol before 'boolean' because the function only returns a boolean value (false) when something doesn't go right, like the arguments are invalid. filePath - This is the path (including file name and extension) to the file you want to download. savePath - This is the path where the file will be saved (client's computer - root path is %MTA_FOLDER%/mods/deathmatch/resources) interval - This is the interval, in milliseconds, between each client event trigger (basically this is the interval between each data sending). Setting a very low interval is not recommended. Edited March 23, 2013 by Guest Link to comment
Rotti Posted March 23, 2013 Author Share Posted March 23, 2013 but he has to download the whole resource... does it works like the download when he connects to the server? Link to comment
ixjf Posted March 23, 2013 Share Posted March 23, 2013 Well, call the function for all files in the resource. The function copies the file content to the client's computer (I don't recommend using this for client scripts, instead use the cache attribute in the 'meta.xml' file) - the good thing here is that it's faster and there's no download bar on the screen. Link to comment
Rotti Posted March 24, 2013 Author Share Posted March 24, 2013 But then then Resource isn't started I think Link to comment
ixjf Posted March 24, 2013 Share Posted March 24, 2013 As I said, that is only for files like models, pictures, sounds, not for script files.. For script files, use the cache attribute in the 'meta.xml' file. So yes, the resource is started. Link to comment
Rotti Posted March 24, 2013 Author Share Posted March 24, 2013 ok ok its a bit difficult to understand for me. will it work if i have a folder on my server where the script and the meta of the carmods are. And i have a folder where only the model files of the carmods are. Then i tell a resource that it should download the files on the computer off the client, in a folder named like the folder on my server. Link to comment
ixjf Posted March 24, 2013 Share Posted March 24, 2013 Can you please try to explain better? I didn't understand what are you trying to ask. Link to comment
Rotti Posted March 24, 2013 Author Share Posted March 24, 2013 ok i just want to ask: How does it works? How can i do that? in my foulder is the script.lua the meta.xml infernus.txd and infernus.dff so i think the infernus.txd and the infernus.dff must be downloaded can you give me an example that will work? and should i change something in the meta? Link to comment
ixjf Posted March 24, 2013 Share Posted March 24, 2013 (edited) How does it work? It opens the file and sends the bytes of the file (content of the file, in an "easier" English) to the client by parts (sending big files in one time would lag and probably give the very known "Network trouble" error infinitely). Then the client saves the bytes into a new file with the same name and extension in the cache. How can I do that? Use the function downloadFile from that resource. I showed you the syntax in a reply above. Create a new script file (client side) and (optionally)add the cache attribute in the 'meta.xml' file for it (search the wiki about that attribute if you don't know where to put it or what it does). Inside the file, write for example: downloadFile ( "infernus.dff", "infernus.dff", 1000 ) --first argument passed is the path to the file in the server, second argument is the path to where the file is going to be saved in the client's cache, the third argument is the interval between each event triggering (where it passes the data to the client). Here is an example: addEventHandler ( "onClientResourceStart", resourceRoot, function() downloadFile ( "infernus.dff", "infernus.dff", 500 ) downloadFile ( "infernus.txd", "infernus.txd", 500 ) end ) addEventHandler ( "onClientDownloadComplete", root, function( strFile ) if( ( strFile == "infernus.dff" ) or ( strFile == "infernus.txd" ) )then --load model end end ) I guess this was clear now, tell me if you're getting any problems. Edited March 24, 2013 by Guest Link to comment
Rotti Posted March 24, 2013 Author Share Posted March 24, 2013 ok ive understood it. BUT only one more question then its clear. When the player joins he will download the files too because they are in the meta.xml. So he will download them twice Link to comment
ixjf Posted March 24, 2013 Share Posted March 24, 2013 You can remove them from the 'meta.xml' (not totally sure, but I guess only client-side file functions need them added to the 'meta.xml' file to be able to load them). In case it doesn't work removing them, add them again and use the download attribute with value false in each script. By the way, I added an example in my last reply. Link to comment
Rotti Posted March 24, 2013 Author Share Posted March 24, 2013 ok thank you very much fpr your help, ill try it :DDDD 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