Jump to content

Help fileIsEOF


boro

Recommended Posts

Posted

Hi all i have created this load script but debug say warning

WARNING: solider/replace.lua:10: Bad argument @ 'fileIsEOF' [Expected scriptfile at argument 1, got string 'solider.txd' ] 
  
  

 

This script work but why is showed this warning ??? please help

fileIsEOF i use for check if is file completely downloaded.

addEventHandler("onClientResourceStart",resourceRoot, 
    function () 
    downloadFile ( "solider.txd" ) 
    downloadFile ( "solider.dff" ) 
    soliderload = setTimer(solider, 60000, 0, source) 
    end 
) 
  
function solider () 
if fileExists("solider.txd") and fileExists("solider.dff") and fileIsEOF("solider.txd") and fileIsEOF("solider.dff") then 
    engineImportTXD(engineLoadTXD("solider.txd"), 16) 
    engineReplaceModel(engineLoadDFF("solider.dff", 0), 16) 
    killTimer ( soliderload ) 
    outputChatBox("soliderload") 
else 
    outputChatBox("soliderload dont are loaded") 
end 
end 
  

Posted

You're supposed to use file element not the name as string..

It wouldn't work anyway as it only checks if the position inside the file used in file functions is at the end of the file. That's not what you want.

Posted

ok and how i check when is file completely downloaded ? because if file dont are checked and dont are loaded correctly

then dont work help MIKI

Posted

Yes i try this function but it dont work and mod dont are loaded

this dont work

function onDownloadFinish ( file, success ) 
    if ( source == resourceRoot ) then                            - 
        if ( success ) then                                        
            if ( file == "solider.txd" and file == "solider.dff" ) then                      
    engineImportTXD(engineLoadTXD("solider.txd"), 16) 
    engineReplaceModel(engineLoadDFF("solider.dff", 0), 16) 
    outputChatBox("soliderload") 
            end 
        end 
    end 
end 
addEventHandler ( "onClientFileDownloadComplete", getRootElement(), onDownloadFinish ) 

Posted

It's not a function.. it's an event.

Of course it won't work.. it gets triggered for each file separately.

Use something like this:

  
local filesDownloaded = {} 
function onDownloadFinish ( file, success )                     
        if ( success ) then 
            filesDownloaded[file] = true                                    
               if ( filesDownloaded["solider.txd"] and filesDownloaded["solider.dff"] ) then                     
                      engineImportTXD(engineLoadTXD("solider.txd"), 16) 
                      engineReplaceModel(engineLoadDFF("solider.dff", 0), 16) 
                      outputChatBox("soliderload") 
                end 
            end 
        end 
end 
addEventHandler ( "onClientFileDownloadComplete", resourceRoot, onDownloadFinish ) 

Posted

Now i test it but this dont work (no errors or warnings)

It's not a function.. it's an event.

Of course it won't work.. it gets triggered for each file separately.

Use something like this:

  
local filesDownloaded = {} 
function onDownloadFinish ( file, success )                     
        if ( success ) then 
            filesDownloaded[file] = true                                    
               if ( filesDownloaded["solider.txd"] and filesDownloaded["solider.dff"] ) then                     
                      engineImportTXD(engineLoadTXD("solider.txd"), 16) 
                      engineReplaceModel(engineLoadDFF("solider.dff", 0), 16) 
                      outputChatBox("soliderload") 
                end 
            end 
        end 
end 
addEventHandler ( "onClientFileDownloadComplete", resourceRoot, onDownloadFinish ) 

  • MTA Team
Posted

Did you also use this?

addEventHandler("onClientResourceStart",resourceRoot, 
    function () 
    downloadFile ( "solider.txd" ) 
    downloadFile ( "solider.dff" ) 
    end 
) 

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