Jump to content

Custom File Size


.:HyPeX:.

Recommended Posts

Posted

Hello, how can i retrive the size of a file client-sided?

fileOpen wont work - its for text files

Greetz

HyPeX

My ingame nick is ~HyPeX~

BF3 Gamemode Progress: ~30% - Currently working on AI & MapManager

gKhdyRJ.png

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)

My ingame nick is ~HyPeX~

BF3 Gamemode Progress: ~30% - Currently working on AI & MapManager

gKhdyRJ.png

Posted
fileGetSize 

you need to open the file with fileOpen -- This works with text files only i belive.

My ingame nick is ~HyPeX~

BF3 Gamemode Progress: ~30% - Currently working on AI & MapManager

gKhdyRJ.png

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

My ingame nick is ~HyPeX~

BF3 Gamemode Progress: ~30% - Currently working on AI & MapManager

gKhdyRJ.png

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)

If you find my post useful or if it helped you, please like my post :)
Ingame name: ZoeN

560x95_FFFFFF_FF9900_000000_000000.png

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