Jump to content

[Question] Downloaded File


Stranger

Recommended Posts

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

Link to comment

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

Link to comment
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 

Link to comment

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

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