roaddog Posted January 6, 2015 Share Posted January 6, 2015 Ohai People! I'm having a problem regarding this mod downloader. When I tried it in my local server the script is working fine, but after I ran it in my server, my server freezed and went down. It happened when two players open the panel at the same time or when there are many files. here's part when client receive the list. Client: function downloadMod() if not guiGetVisible(gWindow["DownloadMod"]) then showCursor(true) guiSetVisible(gWindow["DownloadMod"], true) guiGridListClear(gGrid["DownloadMod"]) triggerServerEvent('onLoadDownloadList', localPlayer, localPlayer) else showCursor(false) guiSetVisible(gWindow["DownloadMod"], false) end end bindKey("f4", "down", downloadMod) function fillDownloadList(downloadList) for _, data in pairs(downloadList) do local row = guiGridListAddRow(gGrid["DownloadMod"]) local modSize = data[3] + data[5] + data[7] local txd, dff, col = data[8], data[9], data[10] local txd_id, dff_id, col_id = data[11], data[12], data[13] if not txd then txd = '-' end if not dff then dff = '-' end if not col then col = '-' end if not txd_id then txd_id = '-' end if not dff_id then dff_id = '-' end if not col_id then col_id = '-' end guiGridListSetItemText(gGrid["DownloadMod"], row, gColumn["DownloadName"], data[1], false, false) guiGridListSetItemText(gGrid["DownloadMod"], row, gColumn["DownloadSize"], sizeFormat(modSize) or 0, false, false) guiGridListSetItemText(gGrid["DownloadMod"], row, gColumn["DownloadTXD"], txd, false, false) guiGridListSetItemText(gGrid["DownloadMod"], row, gColumn["DownloadDFF"], dff, false, false) guiGridListSetItemText(gGrid["DownloadMod"], row, gColumn["DownloadCOL"], col, false, false) guiGridListSetItemText(gGrid["DownloadMod"], row, gColumn["DownloadTXD_ID"], txd_id, false, false) guiGridListSetItemText(gGrid["DownloadMod"], row, gColumn["DownloadDFF_ID"], dff_id, false, false) guiGridListSetItemText(gGrid["DownloadMod"], row, gColumn["DownloadCOL_ID"], col_id, false, false) end end addEvent('onLoadDownloadDraw', true) addEventHandler('onLoadDownloadDraw', localPlayer, fillDownloadList) Server: function onFillDownloadList(player) local downloadMods = {} for _, data in pairs(DownloadList) do local modName local txtID, dffID, colID local txdSize, dffSize, colSize local txdPath, dffPath, colPath local txdBytes, dffBytes, colBytes if (data.modName == nil) then modName = 'Unknown' else modName = data.modName end if (data.engineLoadTXD_Path == nil) then txdPath = false else txdID = data.engineImportTXD_ID txdPath = data.engineLoadTXD_Path end if (data.engineLoadDFF_Path == nil) then dffPath = false else dffID = data.engineReplaceModel_ID dffPath = data.engineLoadDFF_Path end if (data.engineLoadCOL_Path == nil) then colPath = false else colID = data.engineReplaceCOL_ID colPath = data.engineLoadCOL_Path end if(txdPath)then if fileExists(txdPath) then txdFile = fileOpen(txdPath) if(txdFile)then txdSize = fileGetSize(txdFile) txdBytes = fileRead(txdFile, fileGetSize(txdFile)) fileClose(txdFile) end end end if(dffPath)then if fileExists(dffPath) then dffFile = fileOpen(dffPath) if(dffFile)then dffSize = fileGetSize(dffFile) dffBytes = fileRead(dffFile, fileGetSize(dffFile)) fileClose(dffFile) end end end if(colPath)then if fileExists(colPath) then colFile = fileOpen(colPath) if(colFile)then colSize = fileGetSize(colFile) colBytes = fileRead(colFile, fileGetSize(colFile)) fileClose(colFile) end end end table.insert(downloadMods, {modName, txdBytes or false, txdSize or 0, dffBytes or false, dffSize or 0, colBytes or false, colSize or 0, txdPath or false, dffPath or false, colPath or false, txdID or false, dffID or false, colID or false}) end onClientSendMods(player, downloadMods) end addEvent('onLoadDownloadList', true) addEventHandler('onLoadDownloadList', root, onFillDownloadList) function onClientSendMods(player, downloadList) triggerClientEvent(player, 'onLoadDownloadDraw', player, downloadList) end Thanks in advanced for the help. Link to comment
Gallardo9944 Posted January 6, 2015 Share Posted January 6, 2015 triggerClientEvent is not recommended for huge files. Use triggerLatentClientEvent instead. Link to comment
roaddog Posted January 8, 2015 Author Share Posted January 8, 2015 function downloadMod() if not guiGetVisible(gWindow["DownloadMod"]) then showCursor(true) guiSetVisible(gWindow["DownloadMod"], true) guiGridListClear(gGrid["DownloadMod"]) triggerServerEvent('onLoadDownloadList', localPlayer, localPlayer) else showCursor(false) guiSetVisible(gWindow["DownloadMod"], false) end end bindKey("f4", "down", downloadMod) function fillDownloadList(downloadList) for _, data in pairs(downloadList) do local row = guiGridListAddRow(gGrid["DownloadMod"]) local modSize = data[3] + data[5] + data[7] local txd, dff, col = data[8], data[9], data[10] local txd_id, dff_id, col_id = data[11], data[12], data[13] if not txd then txd = '-' end if not dff then dff = '-' end if not col then col = '-' end if not txd_id then txd_id = '-' end if not dff_id then dff_id = '-' end if not col_id then col_id = '-' end guiGridListSetItemText(gGrid["DownloadMod"], row, gColumn["DownloadName"], data[1], false, false) guiGridListSetItemText(gGrid["DownloadMod"], row, gColumn["DownloadSize"], sizeFormat(modSize) or 0, false, false) guiGridListSetItemText(gGrid["DownloadMod"], row, gColumn["DownloadTXD"], txd, false, false) guiGridListSetItemText(gGrid["DownloadMod"], row, gColumn["DownloadDFF"], dff, false, false) guiGridListSetItemText(gGrid["DownloadMod"], row, gColumn["DownloadCOL"], col, false, false) guiGridListSetItemText(gGrid["DownloadMod"], row, gColumn["DownloadTXD_ID"], txd_id, false, false) guiGridListSetItemText(gGrid["DownloadMod"], row, gColumn["DownloadDFF_ID"], dff_id, false, false) guiGridListSetItemText(gGrid["DownloadMod"], row, gColumn["DownloadCOL_ID"], col_id, false, false) end end addEvent('onLoadDownloadDraw', true) addEventHandler('onLoadDownloadDraw', localPlayer, fillDownloadList) function onFillDownloadList(player) local downloadMods = {} for _, data in pairs(DownloadList) do local modName local txtID, dffID, colID local txdSize, dffSize, colSize local txdPath, dffPath, colPath local txdBytes, dffBytes, colBytes if (data.modName == nil) then modName = 'Unknown' else modName = data.modName end if (data.engineLoadTXD_Path == nil) then txdPath = false else txdID = data.engineImportTXD_ID txdPath = data.engineLoadTXD_Path end if (data.engineLoadDFF_Path == nil) then dffPath = false else dffID = data.engineReplaceModel_ID dffPath = data.engineLoadDFF_Path end if (data.engineLoadCOL_Path == nil) then colPath = false else colID = data.engineReplaceCOL_ID colPath = data.engineLoadCOL_Path end if(txdPath)then if fileExists(txdPath) then txdFile = fileOpen(txdPath) if(txdFile)then txdSize = fileGetSize(txdFile) txdBytes = fileRead(txdFile, fileGetSize(txdFile)) fileClose(txdFile) end end end if(dffPath)then if fileExists(dffPath) then dffFile = fileOpen(dffPath) if(dffFile)then dffSize = fileGetSize(dffFile) dffBytes = fileRead(dffFile, fileGetSize(dffFile)) fileClose(dffFile) end end end if(colPath)then if fileExists(colPath) then colFile = fileOpen(colPath) if(colFile)then colSize = fileGetSize(colFile) colBytes = fileRead(colFile, fileGetSize(colFile)) fileClose(colFile) end end end table.insert(downloadMods, {modName, txdBytes or false, txdSize or 0, dffBytes or false, dffSize or 0, colBytes or false, colSize or 0, txdPath or false, dffPath or false, colPath or false, txdID or false, dffID or false, colID or false}) end onClientSendMods(player, downloadMods) end addEvent('onLoadDownloadList', true) addEventHandler('onLoadDownloadList', root, onFillDownloadList) function onClientSendMods(player, downloadList) triggerLatentClientEvent(player, 'onLoadDownloadDraw', 50000, false, player, downloadList) end I tried this but it didnt work, didn't even send the list. Link to comment
Moderators IIYAMA Posted January 8, 2015 Moderators Share Posted January 8, 2015 triggerLatentClientEvent is a slow download progress. I will recommend you to increase the bandwidth and also check the status. https://wiki.multitheftauto.com/wiki/Ge ... ventStatus https://wiki.multitheftauto.com/wiki/Ge ... entHandles Link to comment
Gallardo9944 Posted January 8, 2015 Share Posted January 8, 2015 Bandwidth of 50k means download speed will be about 45kbps. This is extremely slow. Try something like 1024*1024 (1mbps) Link to comment
Castillo Posted January 8, 2015 Share Posted January 8, 2015 Why don't you use downloadFile function? Link to comment
roaddog Posted January 9, 2015 Author Share Posted January 9, 2015 I did use downloadFile function to download the mods, but not retrieving file names or file sizes and put it into gridlist. I used file function and then I sent it to client to fill the gridlist. can I use downloadFile function to do some task like that? if so how? Link to comment
Castillo Posted January 9, 2015 Share Posted January 9, 2015 Oh sorry, I thought you were using file functions to later replace the mod, my bad. 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