Jump to content

IIYAMA

Moderators
  • Posts

    6,089
  • Joined

  • Last visited

  • Days Won

    216

Everything posted by IIYAMA

  1. Don't use "onPlayerJoin", for downloading. Client checks for files. client > server Tells the server which files there are already. The server compares the files. The server downloads the files from the external server. (Caching files for a 1 minute?) server > client The server sends the files back. Client loads the mods either from already downloaded files or directly from the RAW data. Best to load the mods that are already downloaded at this moment. As you might want to update mods in the future. There is no onPlayerJoin in that cycle.
  2. You need to write the txd data to the file but not the loaded txd.
  3. Why are you trying to write a loaded txd? > fileWrite(file, txd)
  4. You do not have to use filepaths serverside, as there are URL's. But you do need something to compare the downloaded files with the (serverside) URL's. That is when you need an identifier. You could use the URL for that, as it is always unique. Your approach sounds correctly.
  5. Compare filesizes, best way to validate if the file is incorrect. There is only 1 way to figure that out and that is to debug every step. And every variable that plays an important role. The update function is used to update the file, when you have replaced the old one with with a new one. This is something for the future. Line 70 is using the filepaths that are the old ones. Line 72 is delivering the new ones. Meta doesn't make use of include tag. <include resource="xmlData" /> Line 65 it's value should be set after onClientResourceStart.
  6. Loop in line 26 is not required. Keep in mind that you might want to update 1 of the files instead of both. When you update/create the filepaths you also need to save the files. As well as saving the filepaths in the xml saving resource.
  7. Yes, but in parts, as every part has to be build with precision. First try to get an understanding of the resource. https://wiki.multitheftauto.com/wiki/XmlData#Simplifying_the_export Then create a table format that could be used for the file management. For example: { [470] = { txd = "files/470/mod.txd", dff = "files/470/mod.dff" }, [...] = { ... } } You must create some functions that can create and update your format. I will give you more steps when this part is finished. Note, you shouldn't save your mods inside of XML. The file will get too big too quickly.
  8. Yes that is happening. If you do not want that to happen, you have to do a lot more work. The first part is file management. "Which files does the client have downloaded?" You can use this resource for keeping track of the file locations and statuses. https://community.multitheftauto.com/index.php?p=resources&s=details&id=16187 And for writing the files: https://wiki.multitheftauto.com/wiki/FileCreate 1. Client [resource:xmldata] These are the files I have on my computer! > triggerServerEvent 2. Server These files are available to download. Filter out the files that have already been downloaded. > triggerClientEvent 3.Client Create new files fileCreate() and update the file management [resource:xmldata]. Yes, that is very much possible. triggerLatentClientEvent(player, ...) local handles = getLatentEventHandles (player) local handle = handles[#handles] local status = getLatentEventStatus(player, handle) iprint((status.percentComplete or 100) .. "%")
  9. getting better local col = modelDataList.col if col then local col_loaded = engineLoadCOL (col) if col_loaded then engineReplaceCOL (col_loaded, model ) end end local txd = modelDataList.txd if txd then local txd_loaded = engineLoadTXD(txd) if txd_loaded then engineImportTXD(txd_loaded, model) end end local dff = modelDataList.dff if dff then local dff_loaded = engineLoadDFF(dff) if dff_loaded then engineReplaceModel(dff_loaded, model) end end
  10. Model and data? Where is that defined? The modelDataList from line 10 is what you have to send, when the server is finished with getting the data.
  11. You are sending nothing. Maybe it is a good idea to send what you want to send. And is 10 seconds delay enough?
  12. You can check the status of latent events. Also you might have bugged it (happend to me once), so restarting the client and the server. downloadFile doesn't work, as the files have to be initiated before the resource start. Without you can't even start the resource. Show serverside. Also keep in mind that you can't send files if they are not downloaded by the server yet. onPlayerJoin can't be used for players that are already in the server.
  13. It probably it takes too long to transfer the data without changing the bandwidth settings. The triggerClientEvent is very aggressive and will be high prioritised as well as blocking everything else untill it is finished.
  14. Just some inspiration, normally I do not write so much code on the forum, untested. -- INPUT local links = { { model = 560, txd = "https://cdn-20.anonfile.com/n9r7yfG3nd/e52c4b4d-1576530500/sultan.txd", dff = "https://cdn-07.anonfile.com/99u8y2G1n9/35d1852b-1576531060/sultan.dff" } } -- OUTPUT local modelDataList = {} -- local fileTypeLoadOrder = { "col", "txd", "dff" } do -- This is a temporary function. Only used for the initial state. local fileRequest = function (err, data, linkIndex, fileType) if (err) then print(err) end outputChatBox("Download started", root) local link = links[linkIndex] local model = link.model -- make a new container if not exist local modelData = modelDataList[model] if not modelData then modelData = { fileCountRemaining = link.fileCount } modelDataList[model] = modelData end -- save the data modelData.model = model modelData[fileType] = data modelData.fileCountRemaining = modelData.fileCountRemaining - 1 -- clean up if modelData.fileCountRemaining == 0 then modelData.fileCountRemaining = nil modelData.ready = true end end -- Loop through all the links for i=1, #links do local link = links[i] -- Keep track of the amount of files that need to be downloaded local fileCount = 0 -- Loop through all the file types in order. for j=1, #fileTypeLoadOrder do local fileType = fileTypeLoadOrder[j] local url = link[fileType] if url then -- If file type has an URL, then try to download it. fetchRemote(url, fileRequest, "", false, i, fileType) fileCount = fileCount + 1 -- + file end end link.fileCount = fileCount end end
  15. Did you check the link with a (000webhost not logged in) browser? Yes, you can do that. But don't make the queue too long.
  16. It is a limit. Timer are an async method. It requires a lot more work to keep temporary variables alive. So timers will make copies of the values rather managing the original values. - You can't pass functions in to a timer as argument. (They can't be copied) - You can pass tables in to a timer as argument, but they will become a (deep) copy.
  17. Hmmm, maybe: currentEXP = totalEXP - requiredEXP
  18. Debug line 50 and check if the value goes below 0.
  19. I think the problem lies somewhere else. Try to debug your code with debug functions. Also check this: Clientside: addEvent("s_callback", true) addEventHandler("s_callback", root, function() triggerServerEvent("serverCallback", localPlayer, s_tarek) -- ???? end)
  20. You are using the variable in onClientRender, before it even has a value assigned to it.
  21. You made a typo. bodypart ( line 8 ) > bodyPart ( line 10 )
  22. There are many. But if there is no issue, why changing the approach? If you want a different approach, it doesn't start with code, but with a concept and questions. How should the data be saved? And how should the data be accessed? Must it be dynamic? Must it be player specific? What are the conditions? What are the possible outcomes?
  23. Locked, reason: scripting request. You can make requests here: (read the section rules before posting) https://forum.multitheftauto.com/forum/149-looking-for-staff/
×
×
  • Create New...