Leaderboard
Popular Content
Showing content with the highest reputation on 17/12/19 in Posts
-
Yes, of course. I forgot to mention that. It's needed to have the files in the resource's folder so you can tell to the meta.xml where it is. Okay. We are conflicting ideas here lol. The last approach I sent it's not complementary of IIYAMA's approach - you can't put them together.2 points
-
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.2 points
-
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) .. "%")1 point
-
1 point
-
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 end1 point
-
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.1 point
-
You are sending nothing. Maybe it is a good idea to send what you want to send. And is 10 seconds delay enough?1 point
-
I changed the fetchRemote at line 66 fetchRemote(url, {}, fileRequest, {i, fileType}) And the fileRequest parameters to match the fetchRemote local fileRequest = function (data, err, linkIndex, fileType) if not err.success then print(err.statusCode) end ... Have you tried downloadFile()? It seems to do exactly what you need. I made an alternative code using this function. It's not good, it's a concept... but let me explain how it works. To use downloadFile() it's needed to store your file paths in the meta.xml with download attribute set to false. In order to let you create only one file, I made a trick using the meta.xml as a config file as well. I don't know the implications of it - IIYAMA can tell us - but this way you're going to be able to loop through the meta.xml and get the <file> tags. The meta.xml will look like this: <file src="sultan.txd" download="false" modelid="560"/> <file src="sultan.dff" download="false" modelid="560"/> <!-- In this case the files are in the resource root folder --> I added a extra attribute to store the modelid, so you can know for what model the file is related. It's needed to put the <file> tags in the proper load oder (col, txd, dff). So the code wil loop this meta file and store the informations to the fileModelList table then it will iterate this table and download all entries. The table will look like this: local fileModelList = { ["sultan.txd"] = { model = "560", fileType = "txd" }, ["sultan.dff"] = { model = "560", fileType = "dff" } } Client: local fileModelList = {} local downloadFiles = function() local metaNode = getResourceConfig("meta.xml") for _, v in pairs(xmlNodeGetChildren(metaNode)) do if xmlNodeGetName(v) == "file" then local fileName = xmlNodeGetAttribute(v, "src") local modelId = xmlNodeGetAttribute(v, "modelid") local fileType = gettok(fileName, 2, "\.") setTimer(downloadFile, 500, 1, fileName) -- In the localhost the download is so fast that one event isn't triggered -- downloadFile(fileName) fileModelList[fileName] = { model = modelId, fileType = fileType } end end end addEventHandler("onClientFileDownloadComplete", resourceRoot, function(fileName, success) if not success then return end -- Later you should do something to handle failed downloads local model = fileModelList[fileName].model local type = fileModelList[fileName].fileType if type == "txd" then engineImportTXD(engineLoadTXD(fileName), model) end if type == "dff" then engineReplaceModel(engineLoadDFF(fileName), model) end fileModelList[fileName] = nil end) addEvent("downloadFiles", true) addEventHandler("downloadFiles", resourceRoot, downloadFiles) Server: addEventHandler("onPlayerJoin", root, function() -- triggerLatentClientEvent(source, "downloadFiles", 10^7, true, resourceRoot) -- Even 10 MBytes didn't work triggerClientEvent(source, "downloadFiles", resourceRoot) end) You will need to mess with the triggerLatentClientEvent() downloadFile() is good if you need to postpone the file downloads, but if you're going to download everything onPlayerJoin wouldn't it be better to let the server handle it? He's downloading 5 MB files (or even more). For his case, what's the correct value to put in the bandwidth parameter? I set it to 10^7 and didn't works lol1 point
-
1 point
-
1 point
-
Você só copiou a função no seu código e como espera que vá funcionar? Seu próximo passo é chamá-la no getPlayerName.1 point
-
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 end1 point
-
Usando o código acima ainda tem como burlar com os códigos hex, então para remover de uma forma definitiva use isto: function removeHex( s ) if type(s) == "string" then while(s:find("#%x%x%x%x%x%x")) do s = s:gsub("#%x%x%x%x%x%x","") end end return s or false end1 point
-
Já foi respondido no discord pelo iDannz [Breno]#2456 Vou postar o que ele enviou: function removeHex(s) return string.gsub(s,"#%x%x%x%x%x%x", "") end1 point
-
Utilize o botão <> do fórum para postar códigos. Não cole direto no texto.1 point
-
1 point
-
Cuidado ae cara. Ele não é o Danilin. A não ser que vc conheça ele na RL e tenha dado esse apelido pra ele.1 point
-
Faça alguns testes com o performancebrowser, você pode ir guardando informações de cada resource com relação ao uso de memória e cpu a cada dia que passar. É provavelmente um problema relacionado a scripts mal feitos. Você pode parar alguns resources que julgar 'pesados' para o servidor.1 point
-
Serials: CF0BF665ECDDDE5FF7AB2C445D7C1394 and (mod note) 874278BB22EE8480B62E2FDE9129C0E2 Banned for ddosing mrgreengaming.com I admit my guilt. I don't have any desires to be anyhow connected with anything about "ddos" now and in the near future either. https://mrgreengaming.com/forums/topic/20836-alekscore/1 point
-
Não gostei do seu argumento, Mais valeu vou estudar mais sobre isso aí0 points
