Untitled

 avatar
unknown
plain_text
a year ago
3.5 kB
26
Indexable
RegisterNetEvent("s:statusUpdated")
AddEventHandler(
    "s:statusUpdated",
    function(status)
        if status == "choosing" then
            isSpawned = false
        elseif status == "spawned" or status == "dead" then
            isSpawned = true
            isDead = (status == "dead")
        end
    end
)

if (Config.target.enabled and Config.target.system) then
    local status = exports.data:getUserVar("status")
    if status == "spawned" or status == "dead" then
        isSpawned = true
        isDead = (status == "dead")
    end

    Citizen.CreateThread(function()
        Citizen.Wait(500)
        for type, data in pairs(Config.TrackedEntities) do
            local models = {}
            for _, model in pairs(data.models) do
                table.insert(models, GetHashKey(model))
            end

            for _, model in pairs(models) do
                exports.target:AddTargetObject(models, {
                    actions = {
                        scarlift = {
                            cb = function(carliftdata)
                                TriggerEvent("kg_carlift:stop")
                            end,
                            canInteract = function(entity)
                                local object = GetClosestObjectOfType(GetEntityCoords(entity), 1.0, model, 0, 0, 0)
                                local job = Entity(object).state.job
                                local event = Entity(object).state.event
                                return event ~= 'none' and event ~= nil and (not job or playerJob == nil or Contains(job, playerJob))
                            end,
                            icon = "fas fa-stop",
                            label = "Stop Carlift"
                        },
                        dcarlift = {
                            cb = function()
                                TriggerEvent("kq_carlift:down")
                            end,
                            canInteract = function(entity)
                                local object = GetClosestObjectOfType(GetEntityCoords(entity), 1.0, model, 0, 0, 0)
                                local job = Entity(object).state.job
                                local event = Entity(object).state.event
                                return event ~= 'down' and event ~= nil and (not job or playerJob == nil or Contains(job, playerJob))
                            end,
                            icon = "fas fa-arrow-down",
                            label = "Down Carlift"
                        },
                        ucarlift = {
                            cb = function()
                                TriggerEvent("kq_carlift:up")
                            end,
                            canInteract = function(entity)
                                local object = GetClosestObjectOfType(GetEntityCoords(entity), 1.0, model, 0, 0, 0)
                                local job = Entity(object).state.job
                                local event = Entity(object).state.event
                                return event ~= 'up' and event ~= nil and (not job or playerJob == nil or Contains(job, playerJob))
                            end,
                            icon = "fas fa-arrow-up",
                            label = "Up Carlift"
                        }
                    },
                    distance = 5.0
                })
            end
        end
    end)
end
Editor is loading...