Jump to content

Custom File Size


.:HyPeX:.

Recommended Posts

Posted
i think client file its same on server but without file server side, you can check thiem with out clientside script :P

Nono, i'm downloading files with downloadFile and i want to check progress, is there a way i can do this? (Of the file individually)

Posted

Okay, nevermind, its working, but the randomly (normaly at 2nd or 3rd file), the download gets fucked up and fileOpen starts giving up errors.

Why is this?

  
  
local fileDownload = 0 
local endingFile = 17 
local fileName = "" 
addEventHandler('onClientResourceStart',resourceRoot, function() 
local file = fileOpen("wheelDownload.txt") 
if file then 
    local size = fileGetSize(file) 
    local txt = fileRead(file,size) 
    if txt == "true" then 
    else 
    downloadFile("wheels/"..wheels[1].name..".dff") 
    fileName = wheels[1].name 
    fileDownload = 1 
    addEventHandler('onClientRender',root,drawLoad) 
    end 
else 
    downloadFile("wheels/"..wheels[1].name..".dff") 
    fileName = wheels[1].name 
    fileDownload = 1 
    addEventHandler('onClientRender',root,drawLoad) 
end 
end) 
  
local x,y = guiGetScreenSize() 
function drawLoad() 
dxDrawText("Downloading File: "..fileName..".dff", x*0.4,y*0.5,x*0.5,y*0.6,tocolor(255,255,255,255), 1.5, "default") 
local p = fileDownload/endingFile * (x*0.2) 
local file = fileOpen("wheels/"..fileName..".dff",true) 
if file then 
local size =fileGetSize(file) 
local size = math.floor(size/1000) 
outputConsole(size .. " / "..wheels[fileDownload].size) 
local psize = (size / wheels[fileDownload].size) * (x*0.2) 
dxDrawRectangle( x*0.4,y*0.55,psize,y*0.025,tocolor(0,0,0,255)) 
end 
dxDrawRectangle( x*0.4,y*0.6,p,y*0.025,tocolor(0,0,0,255)) 
end 
  
addEventHandler('onClientFileDownloadComplete',root,function(file,result) 
    if result then 
        fileDownload = fileDownload + 1 
            if fileDownload > 17 then 
            removeEventHandler('onClientRender',root, drawLoad) 
            local file = fileCreate("wheelDownload.txt") 
            fileWrite(file, "true") 
            fileClose(file) 
            return 
            end 
        downloadFile("wheels/"..wheels[fileDownload].name..".dff") 
        outputConsole(fileDownload) 
        fileName = wheels[fileDownload].name 
    else 
    downloadFile("wheels/"..wheels[fileDownload].name..".dff") 
    end 
end) 

greetz

HyPeX

Posted
not sure but multiple times using fileOpen on same file without closing can also cause issues with fileOpen(but i don't know if this is issue with your script)

Of course it would probably cause problems, because you're not supposed to open the same file without closing it.

Happy new year btw

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