Skip to content

Commit

Permalink
refactor: es_extended\client\modules\streaming.lua
Browse files Browse the repository at this point in the history
  • Loading branch information
bitpredator committed Oct 21, 2024
1 parent cfee6b5 commit 41453ff
Showing 1 changed file with 20 additions and 68 deletions.
Original file line number Diff line number Diff line change
@@ -1,85 +1,37 @@
function ESX.Streaming.RequestModel(modelHash, cb)
modelHash = (type(modelHash) == "number" and modelHash or joaat(modelHash))

if not HasModelLoaded(modelHash) and IsModelInCdimage(modelHash) then
RequestModel(modelHash)

while not HasModelLoaded(modelHash) do
Wait(0)
end
end

if cb ~= nil then
cb()
end
modelHash = type(modelHash) == "number" and modelHash or joaat(modelHash)
if not IsModelInCdimage(modelHash) then return end
RequestModel(modelHash)
while not HasModelLoaded(modelHash) do Wait() end
return cb and cb(modelHash) or modelHash
end

function ESX.Streaming.RequestStreamedTextureDict(textureDict, cb)
if not HasStreamedTextureDictLoaded(textureDict) then
RequestStreamedTextureDict(textureDict)

while not HasStreamedTextureDictLoaded(textureDict) do
Wait(0)
end
end

if cb ~= nil then
cb()
end
RequestStreamedTextureDict(textureDict)
while not HasStreamedTextureDictLoaded(textureDict) do Wait() end
return cb and cb(textureDict) or textureDict
end

function ESX.Streaming.RequestNamedPtfxAsset(assetName, cb)
if not HasNamedPtfxAssetLoaded(assetName) then
RequestNamedPtfxAsset(assetName)

while not HasNamedPtfxAssetLoaded(assetName) do
Wait(0)
end
end

if cb ~= nil then
cb()
end
RequestNamedPtfxAsset(assetName)
while not HasNamedPtfxAssetLoaded(assetName) do Wait() end
return cb and cb(assetName) or assetName
end

function ESX.Streaming.RequestAnimSet(animSet, cb)
if not HasAnimSetLoaded(animSet) then
RequestAnimSet(animSet)

while not HasAnimSetLoaded(animSet) do
Wait(0)
end
end

if cb ~= nil then
cb()
end
RequestAnimSet(animSet)
while not HasAnimSetLoaded(animSet) do Wait() end
return cb and cb(animSet) or animSet
end

function ESX.Streaming.RequestAnimDict(animDict, cb)
if not HasAnimDictLoaded(animDict) then
RequestAnimDict(animDict)

while not HasAnimDictLoaded(animDict) do
Wait(0)
end
end

if cb ~= nil then
cb()
end
RequestAnimDict(animDict)
while not HasAnimDictLoaded(animDict) do Wait() end
return cb and cb(animDict) or animDict
end

function ESX.Streaming.RequestWeaponAsset(weaponHash, cb)
if not HasWeaponAssetLoaded(weaponHash) then
RequestWeaponAsset(weaponHash)

while not HasWeaponAssetLoaded(weaponHash) do
Wait(0)
end
end

if cb ~= nil then
cb()
end
RequestWeaponAsset(weaponHash)
while not HasWeaponAssetLoaded(weaponHash) do Wait() end
return cb and cb(weaponHash) or weaponHash
end

0 comments on commit 41453ff

Please sign in to comment.