Hale Posted January 8, 2017 Share Posted January 8, 2017 (edited) Hello everyone, I have a custom modloader that keeps dumping errors for loading each DFF and TXD, and since I have 13 files in total it outputs 26 errors every time I join my server or restart the resource (the consequences are same). Here's the thing: I restart the resource, which executes the event "onClientResourceStart", and in its function a GUI loads up and at the end it executes "refreshMods()" which cycles through the mods and applies them with function ApplyPatch(), and it actually works as in-game the textures can actually be seen. The only problem is the debug error, which says: "Attempt to load 'folder/file.txd' before onClientFileDownloadComplete event". Any ideas on how to fix it? ApplyPatch() Spoiler function ApplyPatch(Item) local folder = getElementData(Item,"folder"); local txd = getElementData(Item,"txd"); local dff = getElementData(Item,"dff"); local modelid = getElementData(Item,"modelid"); local inUse = getElementData(Item,"inUse"); local patched = getElementData(Item,"patched"); local downloading = getElementData(Item,"downloading"); if (downloading) then return false else if (not patched) then if (inUse==0) then setElementData(Item,"inUse",1); inUse=1; if (not xmlFindChild(xmlAutoPatchsFile,getElementData(Item,"selfname"),0)) then xmlCreateChild(xmlAutoPatchsFile, getElementData(Item,"selfname")); xmlSaveFile(xmlAutoPatchsFile); end end if (fileExists("mods/"..folder.."/"..txd) and fileExists("mods/"..folder.."/"..dff)) then local iTXD = engineLoadTXD ( "mods/"..folder.."/"..txd ) engineImportTXD ( iTXD, modelid ) local iDFF = engineLoadDFF ( "mods/"..folder.."/"..dff, modelid ) engineReplaceModel ( iDFF, modelid ) setElementData(Item,"patched",true); patched=true; else if not fileExists("mods/"..folder.."/"..txd) then setElementData(Item,"downloaded:txd",false); downloadFile("mods/"..folder.."/"..txd); end if not fileExists("mods/"..folder.."/"..dff) then setElementData(Item,"downloaded:dff",false); downloadFile("mods/"..folder.."/"..dff); end setElementData(Item,"downloading",true); return; end else if (inUse==1) then setElementData(Item,"inUse",0); inUse=0; if (xmlFindChild(xmlAutoPatchsFile,getElementData(Item,"selfname"),0)) then xmlDestroyNode(xmlFindChild(xmlAutoPatchsFile,getElementData(Item,"selfname"),0)); xmlSaveFile(xmlAutoPatchsFile); end end engineRestoreModel ( modelid ) setElementData(Item,"patched",false); patched=false; end end end Event "onClientFileDownloadComplete": Spoiler function FileDownloaded(file, success) if (success) then for _, Item in ipairs(gui:SDT_ListGetItems(Windows.ModLoader.ModLoader_lstbox)) do local folder = getElementData(Item,"folder"); local txd = getElementData(Item,"txd"); local dff = getElementData(Item,"dff"); if (("mods/"..folder.."/"..dff) == file) or (("mods/"..folder.."/"..txd) == file) then local dffdownload = getElementData(Item,"downloaded:dff"); local txddownload = getElementData(Item,"downloaded:txd"); if (("mods/"..folder.."/"..txd) == file) then txddownload = true; elseif (("mods/"..folder.."/"..dff) == file) then dffdownload=true; end if (dffdownload and txddownload) then setElementData(Item,"downloading",false); setTimer(ApplyPatch, 500, 1, Item); else setElementData(Item,"downloaded:dff",dffdownload); setElementData(Item,"downloaded:txd",txddownload); end return; end end else for _, Item in ipairs(gui:SDT_ListGetItems(Windows.ModLoader.ModLoader_lstbox)) do local folder = getElementData(Item,"folder"); local txd = getElementData(Item,"txd"); local dff = getElementData(Item,"dff"); if (("mods/"..folder.."/"..dff) == file) or (("mods/"..folder.."/"..txd) == file) then outputChatBox("#058093<ModLoader>: #FF0000File downloading error '"..file.."', please try again...",255,255,255,true) setElementData(Item, "downloading",false); setElementData(Item,"downloaded:dff",false); setElementData(Item,"downloaded:txd",false); return; end end end end addEventHandler("onClientFileDownloadComplete", getRootElement(),FileDownloaded); Edited January 8, 2017 by Luka Havrlisan 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