Jump to content

Server freezed! mod downloader.


NeverGiveup

Recommended Posts

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
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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...