boro Posted November 4, 2014 Share Posted November 4, 2014 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 Link to comment
MTA Team botder Posted November 4, 2014 MTA Team Share Posted November 4, 2014 Could you use OnClientFileDownloadComplete instead? Link to comment
boro Posted November 4, 2014 Author Share Posted November 4, 2014 i try this function but this dont work good Link to comment
MIKI785 Posted November 4, 2014 Share Posted November 4, 2014 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. Link to comment
boro Posted November 4, 2014 Author Share Posted November 4, 2014 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 Link to comment
MIKI785 Posted November 4, 2014 Share Posted November 4, 2014 Using OnClientFileDownloadComplete is the best way. Link to comment
boro Posted November 4, 2014 Author Share Posted November 4, 2014 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 ) Link to comment
MIKI785 Posted November 4, 2014 Share Posted November 4, 2014 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 ) Link to comment
boro Posted November 4, 2014 Author Share Posted November 4, 2014 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 ) Link to comment
MTA Team botder Posted November 4, 2014 MTA Team Share Posted November 4, 2014 Did you also use this? addEventHandler("onClientResourceStart",resourceRoot, function () downloadFile ( "solider.txd" ) downloadFile ( "solider.dff" ) end ) Link to comment
Et-win Posted November 5, 2014 Share Posted November 5, 2014 https://forum.multitheftauto.com/viewtopic.php?f=91&t=78826 Link to comment
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