diff --git a/functions.lua b/functions.lua index 90fea12..870ab9a 100644 --- a/functions.lua +++ b/functions.lua @@ -10,18 +10,51 @@ end local time = 100 function loadModel(model) - if not HasModelLoaded(model) then if Config.System.Debug then print("^6Bridge^7: ^2Loading Model^7: '^6"..model.."^7'") end - while not HasModelLoaded(model) do if time > 0 then time -= 1 RequestModel(model) - else time = 1000 print("^6Bridge^7: ^3LoadModel^7: ^2Timed out loading model ^7'^6"..model.."^7'") break end - Wait(10) end + if not IsModelValid(model) then print("^6Bridge^7: ^1ERROR^7: ^2Model^7 - '^6"..model.."^7' ^2does not exist in server") return + else + if not HasModelLoaded(model) then + if Config.System.Debug then + print("^6Bridge^7: ^2Loading Model^7: '^6"..model.."^7'") + end + if lib then lib.requestModel(model, time) + else while not HasModelLoaded(model) and time > 0 do time -= 1 end end + if not HasModelLoaded(model) then time = 100 print("^6Bridge^7: ^3LoadModel^7: ^2Timed out loading model ^7'^6"..model.."^7'") end + end + end +end +function unloadModel(model) if Config.System.Debug then print("^6Bridge^7: ^2Removing Model from memory cache^7: '^6"..model.."^7'") end SetModelAsNoLongerNeeded(model) end + +function loadAnimDict(animDict) + if not DoesAnimDictExist(animDict) then print("^6Bridge^7: ^1ERROR^7: ^2Anim Dictionary^7 - '^6"..animDict.."^7' ^2does not exist in server") return + else + if Config.System.Debug then print("^6Bridge^7: ^2Loading Anim Dictionary^7: '^6"..animDict.."^7'") end + if lib then lib.requestAnimDict(animDict, 100) + else while not HasAnimDictLoaded(animDict) do RequestAnimDict(animDict) Wait(5) end end + end +end +function unloadAnimDict(animDict) if Config.System.Debug then print("^6Bridge^7: ^2Removing Anim Dictionary from memory cache^7: '^6"..animDict.."^7'") end RemoveAnimDict(animDict) end + +function loadPtfxDict(ptFxName) + if not HasNamedPtfxAssetLoaded(ptFxName) then + if Config.System.Debug then + if not HasNamedPtfxAssetLoaded(ptFxName) then + print("^6Bridge^7: ^2Loading Ptfx Dictionary^7: '^6"..ptFxName.."^7'") + end + end + if lib then lib.requestNamedPtfxAsset(ptFxName, 100) + else while not HasNamedPtfxAssetLoaded(ptFxName) do RequestNamedPtfxAsset(ptFxName) Wait(5) end end end end -function unloadModel(model) if Config.System.Debug then print("^6Bridge^7: ^2Removing Model^7: '^6"..model.."^7'") end SetModelAsNoLongerNeeded(model) end -function loadAnimDict(dict) if Config.System.Debug then print("^6Bridge^7: ^2Loading Anim Dictionary^7: '^6"..dict.."^7'") end while not HasAnimDictLoaded(dict) do RequestAnimDict(dict) Wait(5) end end -function unloadAnimDict(dict) if Config.System.Debug then print("^6Bridge^7: ^2Removing Anim Dictionary^7: '^6"..dict.."^7'") end RemoveAnimDict(dict) end -function loadPtfxDict(dict) if Config.System.Debug then if not HasNamedPtfxAssetLoaded(dict) then print("^6Bridge^7: ^2Loading Ptfx Dictionary^7: '^6"..dict.."^7'") end end while not HasNamedPtfxAssetLoaded(dict) do RequestNamedPtfxAsset(dict) Wait(5) end end function unloadPtfxDict(dict) if Config.System.Debug then print("^6Bridge^7: ^2Removing Ptfx Dictionary^7: '^6"..dict.."^7'") end RemoveNamedPtfxAsset(dict) end -function loadTextureDict(dict) if Config.System.Debug then print("^6Bridge^7: ^2Loading Texture Dictionary^7: '^6"..dict.."^7'") end while not HasStreamedTextureDictLoaded(dict) do RequestNamedPtfxAsset(dict) Wait(5) end end +function loadTextureDict(dict) + if not HasStreamedTextureDictLoaded(dict) then + if Config.System.Debug then + print("^6Bridge^7: ^2Loading Texture Dictionary^7: '^6"..dict.."^7'") + end + if lib then lib.requestStreamedTextureDict(textureDict, timeout) + else while not HasStreamedTextureDictLoaded(dict) do RequestNamedPtfxAsset(dict) Wait(5) end end + end +end function countTable(table) local i = 0 for keys in pairs(table) do i += 1 end return i end diff --git a/fxmanifest.lua b/fxmanifest.lua index 0eeb09f..1b54e06 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -1,6 +1,6 @@ name "Jim_Bridge" author "Jimathy" -version "1.0.9" +version "1.0.10" description "Framework Bridge By Jimathy" fx_version "cerulean" game "gta5" diff --git a/version.txt b/version.txt index ab7e7da..fb0df62 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -1.0.9 +1.0.10