diff --git a/resources/[jobs]/[crime]/nordi_containerheist/client/main.lua b/resources/[jobs]/[crime]/nordi_containerheist/client/main.lua index fb401e6bd..dfdd453a6 100644 --- a/resources/[jobs]/[crime]/nordi_containerheist/client/main.lua +++ b/resources/[jobs]/[crime]/nordi_containerheist/client/main.lua @@ -449,36 +449,46 @@ CreateThread(function() -- Wait for target system to be ready Wait(1000) - -- Add target for all container types - for _, containerType in pairs(Config.ContainerTypes) do - exports['qb-target']:AddTargetModel(containerType.model, { - options = { - { - type = "client", - event = "container_heist:client:startRobbery", - icon = "fas fa-angle-double-right", - label = "Break into " .. containerType.label, - containerType = containerType, - } - }, - distance = 3.0 - }) + -- Check if Config.ContainerTypes exists and is not empty + if Config.ContainerTypes and next(Config.ContainerTypes) then + -- Add target for all container types + for _, containerType in pairs(Config.ContainerTypes) do + exports['qb-target']:AddTargetModel(containerType.model, { + options = { + { + type = "client", + event = "container_heist:client:startRobbery", + icon = "fas fa-angle-double-right", + label = "Break into " .. containerType.label, + containerType = containerType, + } + }, + distance = 3.0 + }) + end + else + print("[Container Heist] Error: Config.ContainerTypes is nil or empty!") end - -- Spawn containers at fixed locations if configured - for _, location in pairs(Config.ContainerLocations) do - if location.spawnContainer then - local hash = GetHashKey(location.model) - RequestModel(hash) - while not HasModelLoaded(hash) do - Wait(10) + -- Check if Config.ContainerLocations exists and is not empty + if Config.ContainerLocations and next(Config.ContainerLocations) then + -- Spawn containers at fixed locations if configured + for _, location in pairs(Config.ContainerLocations) do + if location.spawnContainer then + local hash = GetHashKey(location.model) + RequestModel(hash) + while not HasModelLoaded(hash) do + Wait(10) + end + + local container = CreateObject(hash, location.coords.x, location.coords.y, location.coords.z, true, false, false) + SetEntityHeading(container, location.heading) + FreezeEntityPosition(container, true) + SetModelAsNoLongerNeeded(hash) end - - local container = CreateObject(hash, location.coords.x, location.coords.y, location.coords.z, true, false, false) - SetEntityHeading(container, location.heading) - FreezeEntityPosition(container, true) - SetModelAsNoLongerNeeded(hash) end + else + print("[Container Heist] Warning: Config.ContainerLocations is nil or empty!") end end)