.:HyPeX:. Posted December 30, 2014 Posted December 30, 2014 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
WASSIm. Posted December 30, 2014 Posted December 30, 2014 i think client file its same on server but without file server side, you can check thiem with out clientside script
.:HyPeX:. Posted December 30, 2014 Author Posted December 30, 2014 i think client file its same on server but without file server side, you can check thiem with out clientside script 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
manve1 Posted December 30, 2014 Posted December 30, 2014 fileGetSize Looking for tutorials or information? check out: www.simpleask.co.uk
.:HyPeX:. Posted December 30, 2014 Author Posted December 30, 2014 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
.:HyPeX:. Posted December 30, 2014 Author Posted December 30, 2014 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
manve1 Posted December 31, 2014 Posted December 31, 2014 It's because you're getting the file size and handling maths inside of the handler. Looking for tutorials or information? check out: www.simpleask.co.uk
John Smith Posted December 31, 2014 Posted December 31, 2014 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
Gallardo9944 Posted December 31, 2014 Posted December 31, 2014 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 Code Debugger - Minimalistic MTA debug line replacement
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