Snakegold Posted January 23 Share Posted January 23 Hi everyone, i have downloader system it loads all the vehicles/wps/skins correctly but fails to replace wheels why ? ["wheels/wheel17.dff"] = 1098, ["wheels/wheels.txd"] = 1098, ["wheels/wheel16.dff"] = 1097, ["wheels/wheels.txd"] = 1097, ["wheels/wheel15.dff"] = 1096, ["wheels/wheels.txd"] = 1096, ["wheels/wheel14.dff"] = 1085, ["wheels/wheels.txd"] = 1085, ["wheels/wheel13.dff"] = 1084, ["wheels/wheels.txd"] = 1084, ["wheels/wheel12.dff"] = 1083, ["wheels/wheels.txd"] = 1083, ["wheels/wheel11.dff"] = 1082, ["wheels/wheels.txd"] = 1082, ["wheels/wheel10.dff"] = 1081, ["wheels/wheels.txd"] = 1081, ["wheels/wheel9.dff"] = 1080, ["wheels/wheels.txd"] = 1080, ["wheels/wheel8.dff"] = 1079, ["wheels/wheels.txd"] = 1079, ["wheels/wheel7.dff"] = 1078, ["wheels/wheels.txd"] = 1078, ["wheels/wheel6.dff"] = 1077, ["wheels/wheels.txd"] = 1077, ["wheels/wheel5.dff"] = 1076, ["wheels/wheels.txd"] = 1076, ["wheels/wheel4.dff"] = 1075, ["wheels/wheels.txd"] = 1075, ["wheels/wheel3.dff"] = 1074, ["wheels/wheels.txd"] = 1074, ["wheels/wheel2.dff"] = 1073, ["wheels/wheels.txd"] = 1073, ["wheels/wheel1.dff"] = 1025, ["wheels/wheel1.txd"] = 1025, client side: local tempTable = {} local modCount = 0 local allModCount = 0 local keys = 0 local loadedMods = {} local modKeys = {} local currentFileNumber = 0 local currentFileName = "" function addFile(file, mod) if not downloadFile(file) then outputDebugString(file .. " not found!") else allModCount = allModCount + 1 modCache[file] = mod currentFileNumber = currentFileNumber + 1 currentFileName = file if not modKeys[mod] then keys = keys + 1 modKeys[mod] = keys end end end local sx,sy = guiGetScreenSize() local imgrot = 0 function renderGTAVLoading() local percent = math.floor((modCount / allModCount) * 100) if percent == 100 then allModCount = 0 modCount = 0 buggedVehs = 1 tempTable = {} modKeys = {} keys = 0 removeEventHandler("onClientRender", root, renderGTAVLoading) end local filePath = "cars" -- replace this with the actual file path local text = "Downloading (" .. filePath .. ", " .. currentFileName .. "... " .. percent .. "%) " local textWidth = dxGetTextWidth(text, 1, "bankgothic") imgrot = imgrot + 5 dxDrawImage(sx - textWidth / 2 - 195, 12, 20, 20, "loading.png", imgrot, 0, 0, nil, true) dxDrawText(text, (sx - textWidth) / 2, 14, (sx + textWidth) / 2, 20, tocolor(255, 255, 255, 255), 1, "bankgothic", "center", "top", false, false, true) end function restoreAllModels() -- teljes ram tisztítás local restored = {} for k,v in pairs(loadedMods) do if not restored[k] then engineRestoreModel(k) restored[k] = true end end loadedMods = {} for k,_ in pairs(vehicleParts) do for key,value in pairs(vehicleParts[k]) do if not restored[value] then engineRestoreModel(value) restored[value] = true end end end restored = nil end addCommandHandler("restoremodels", restoreAllModels) local startTimer function loadMods() startTimer = setTimer(function() if not isTransferBoxActive() then killTimer(startTimer) loadedMods = {} for k,v in pairs(modCache) do addFile(k, v) end for k,_ in pairs(vehicleParts) do for key,value in pairs(vehicleParts[k]) do addFile(key, value) end end addEventHandler("onClientRender", root, renderGTAVLoading) end end, 2000, 0) end addEventHandler("onClientResourceStart", resourceRoot, loadMods) addCommandHandler("be", loadMods) addCommandHandler("reloadcar", function(cmd, id) local id = tonumber(id) or 0 local i = 0 for k,v in pairs(modCache) do if v == id then addFile(k, v) i = i + 1 end end if i > 0 then addEventHandler("onClientRender", root, renderGTAVLoading) outputChatBox("[HL] #FFFFFFVehicle reloaded!", 0, 255, 0, true) else outputChatBox("[HL] #FFFFFFThere is no such vehicle in the list!", 0, 255, 0, true) end end) addEventHandler("onClientFileDownloadComplete", root, function(file,success) if source == resourceRoot then if success then local kit = string.sub(file, -4) if kit == ".dff" then local name = file:gsub(".dff", "") local mod = tonumber(modCache[file]) or 0 if mod < 1000 and mod > 0 then if modCache[name..".txd"] then if fileExists(name..".txd") then if not loadedMods[mod] then loadVehicleMod(name, mod, modKeys[mod]) end end else if not loadedMods[mod] then loadDFF(name,mod) end end modKeys[file] = nil end modCount = modCount + 1 elseif kit == ".txd" then local name = file:gsub(".txd", "") local mod = tonumber(modCache[file]) or 0 if mod < 1000 and mod > 0 then if modCache[name..".dff"] then if fileExists(name..".dff") then if not loadedMods[mod] then loadVehicleMod(name, mod, modKeys[mod]) end end else if not loadedMods[mod] then loadTXD(name, mod) end end modKeys[file] = nil end modCount = modCount + 1 end end end end) function loadVehicleMod(file, mod, key) if key then local bugged = buggedVehicles[mod] if not bugged then loadTXD(file, mod) loadDFF(file, mod) -- Use 'mod' instead of 'file' to maintain consistency else loadTXD(file, mod) setTimer(loadBuggedParts, 200 * key, 1, file, mod) end end end function loadTXD(file, mod) txd = fileExists(file .. ".txd") and engineLoadTXD(file .. ".txd") or false if txd then engineImportTXD(txd, mod) else outputDebugString("Failed to load TXD: " .. file .. ".txd for mod: " .. mod) outputDebugString("Full path: " .. file .. ".txd") end end function loadDFF(file, mod) file = file:gsub(".dff", "") dff = fileExists(file .. ".dff") and engineLoadDFF(file .. ".dff", mod) or false if dff then engineReplaceModel(dff, mod) loadedMods[mod] = true else outputDebugString("Failed to load DFF: " .. file .. ".dff for mod: " .. mod) outputDebugString("Full path: " .. file .. ".dff") end end function loadBuggedParts(file,mod) if vehicleParts[mod] then local dff = fileExists(file..".dff") and engineLoadDFF(file..".dff", mod) or false if dff then engineReplaceModel(dff, mod) loadedMods[mod] = true end for k,v in pairs(vehicleParts[mod]) do local dff = fileExists(k) and engineLoadDFF(k, mod) or false if dff then engineReplaceModel(dff, v) end end end end 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