Stranger Posted June 15, 2016 Posted June 15, 2016 hello guys .. is there any possible way to know if the file has been already downloaded or not ? cause i want to check so that the file not to be downloaded any more .. so if this possible can someone tell me how ? .. thanks
KariiiM Posted June 16, 2016 Posted June 16, 2016 Use this event to check the downloaded files. onClientFileDownloadComplete
Stranger Posted June 16, 2016 Author Posted June 16, 2016 i know that ... but you didn't understand me .. here is the code: addEventHandler ("onClientResourceStart", resourceRoot, function () setTimer (function () for _,v in ipairs (modelTable) do downloadFile (v[1]) Downloading [v[1]] = true if not isEventAdded then addEventHandler ("onClientRender", root, download) end end end, 1000, 1) end ) you got what i mean now ? i mean like when the resource start the dx .. shows up everytime even if the files are already downloaded .. i want it to be like if the file downloaded ... the dx will not show .. but here is the problem ... when i start the resource it load up the models .. successfully but there is this problem .. that the dx shows up .. so i hope you got me now ..
KariiiM Posted June 16, 2016 Posted June 16, 2016 I wrote a code for you, untested but it should work: client side: addEventHandler ( "onClientResourceStart", resourceRoot, function ( ) triggerServerEvent ( "onClientReady", localPlayer ) end ) addEvent ( "showDX", true ) addEventHandler ( "showDX", root, function ( ) -- your code end ) server side: local players = { } addEvent ( "onClientReady", true ) addEventHandler ( "onClientReady", root, function ( ) if ( not players[client] ) then players[client] = true else triggerClientEvent ( client, "showDX", client ) end end ) addEventHandler ( "onPlayerQuit", root, function( ) if ( players[source] ) then players[source] = nil end end ) Wish that can help you
Stranger Posted June 16, 2016 Author Posted June 16, 2016 that's good .. but the problem is .. when he quits and join again .. that dx will show to him again .. so this is the problem .. i don't want it to show up any more .. after the file has been already downloaded ..
KariiiM Posted June 16, 2016 Posted June 16, 2016 that's good .. but the problem is .. when he quits and join again ..that dx will show to him again .. so this is the problem .. i don't want it to show up any more .. after the file has been already downloaded .. Now I got what you mean: Use the function fileExists to check if the file is already exists or not then do your code, Tomas already posted the function for you, Try something like that: if ( fileExists ( "filePath" ) then -- the file exists else -- doesn't exist end
Stranger Posted June 16, 2016 Author Posted June 16, 2016 thanks karim ... i figured out another way ... that i added removeEventHandler in the event 'onClientFileDownloadComplete' cause as i can see that event will not stop even if the file has been already downloaded so .. the only one who stops if the file has downloaded is .. downloadFile .. so i put it in that event so if the file has been completed ... the dx should be removed .. so yea .. thank you all ..
KariiiM Posted June 16, 2016 Posted June 16, 2016 You're welcome, just to tell you that, the client files will be restarted each time the local player joined the server
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