local resourceName = GetCurrentResourceName() local lastRestore = 0 local function restoreWorldStreaming(reason) local ped = PlayerPedId() if ped == 0 or not DoesEntityExist(ped) then return false end -- A stale scripted focus/load-scene is one of the most common causes for -- half-loaded streets after leaving an instanced interior. NewLoadSceneStop() ClearFocus() ClearHdArea() local coords = GetEntityCoords(ped) RequestCollisionAtCoord(coords.x, coords.y, coords.z) RequestAdditionalCollisionAtCoord(coords.x, coords.y, coords.z) SetFocusEntity(ped) local deadline = GetGameTimer() + 5000 while not HasCollisionLoadedAroundEntity(ped) and GetGameTimer() < deadline do RequestCollisionAtCoord(coords.x, coords.y, coords.z) RequestAdditionalCollisionAtCoord(coords.x, coords.y, coords.z) Wait(0) end ClearFocus() lastRestore = GetGameTimer() if reason then print(('[devx_ipl] Weltstreaming wiederhergestellt (%s).'):format(reason)) end return HasCollisionLoadedAroundEntity(ped) end exports('RestoreWorldStreaming', restoreWorldStreaming) RegisterNetEvent('devx_ipl:client:restoreWorld', function(reason) CreateThread(function() restoreWorldStreaming(reason or 'event') end) end) RegisterCommand('fixworld', function() CreateThread(function() local ok = restoreWorldStreaming('command') if GetResourceState('devx_core') == 'started' then exports.devx_core:Notify(ok and 'Weltstreaming wurde neu aufgebaut.' or 'Kollision lädt noch. Bewege dich kurz oder verbinde dich neu.') end end) end, false) -- Do not globally request/remove apartment or mission IPLs here. Those IPLs -- share hidden coordinates and were the source of overlapping geometry in the -- earlier versions. Each feature now loads only what it needs, on demand. CreateThread(function() Wait(1500) restoreWorldStreaming('resource-start') print('[devx_ipl] DevX Streaming-Guard v0.4.3 aktiv. Keine globalen Apartment-/Warehouse-IPLs.') end) AddEventHandler('onClientResourceStart', function(resource) if resource == resourceName and GetGameTimer() - lastRestore > 1000 then CreateThread(function() Wait(800) restoreWorldStreaming('client-resource-start') end) end end) AddEventHandler('playerSpawned', function() CreateThread(function() Wait(1200) restoreWorldStreaming('player-spawned') end) end) AddEventHandler('devx_core:client:playerLoaded', function() CreateThread(function() Wait(800) restoreWorldStreaming('character-loaded') end) end)