JCKSDocs
JCKS BridgeV1Reference

Default editable files

The complete default editable files of JCKS Bridge 1.0.0, to copy a function that is missing in your own file.

These are the editable files exactly as JCKS Bridge 1.0.0 ships them. Your own copies in editable/ are never replaced by an update. When the console says a function is missing, the default below runs instead of it. Copy the function into your file only if you want to change it.

Files of other versions: changelog.

client/editable.lua

Imported into editable/client.lua by V2.

Function What it does
Editable.Notify
Editable.Progress
Editable.CancelProgress
Editable.ShowTextUI
Editable.HideTextUI
Editable.SetClipboard
Editable.OpenWardrobe
Editable.RestoreCivilian
Editable.SetFuel
Editable.GetFuel
lua
Editable = {}

local function jui()
    return GetResourceState('jcks_ui') == 'started' and exports.jcks_ui or nil
end

function Editable.Notify(data)
    local ui = jui()
    if ui then return ui:Notify(data) end
    lib.notify({
        title = data.title,
        description = data.description,
        type = data.type or 'inform',
        duration = data.duration or 5000,
        position = Config.NotifyPosition,
    })
end

function Editable.Progress(opts)
    local data = {
        duration = opts.duration,
        label = opts.label,
        useWhileDead = false,
        canCancel = opts.canCancel ~= false,
        disable = { move = true, car = true, combat = true },
        anim = opts.scenario and { scenario = opts.scenario } or opts.anim,
        prop = opts.prop,
    }
    local ui = jui()
    if ui then
        data.style = Config.ProgressStyle
        return ui:Progress(data)
    end
    data.position = 'bottom'
    if Config.ProgressStyle == 'bar' then return lib.progressBar(data) end
    return lib.progressCircle(data)
end

function Editable.CancelProgress()
    local ui = jui()
    if ui then return ui:CancelProgress() end
    if lib.progressActive() then lib.cancelProgress() end
end

function Editable.ShowTextUI(text, icon)
    local ui = jui()
    if ui then return ui:ShowTextUI(text, { icon = icon, position = Config.TextUIPosition }) end
    lib.showTextUI(text, { position = Config.TextUIPosition, icon = icon })
end

function Editable.HideTextUI()
    local ui = jui()
    if ui then return ui:HideTextUI() end
    lib.hideTextUI()
end

function Editable.SetClipboard(text)
    local ui = jui()
    if ui then return ui:SetClipboard(text) end
    print('^3[jcks_bridge] no clipboard implementation available, copy skipped^7')
    return false
end

function Editable.OpenWardrobe()
    local system = Bridge.ClothingSystem
    if system == 'illenium-appearance' then
        TriggerEvent('illenium-appearance:client:openOutfitMenu')
    elseif system == 'fivem-appearance' then
        TriggerEvent('fivem-appearance:client:openWardrobe')
    elseif system == 'qb-clothing' then
        TriggerEvent('qb-clothing:client:openOutfitMenu')
    elseif system == 'esx_skin' then
        TriggerEvent('esx_skin:openSaveableMenu')
    else
        return false
    end
    return true
end

function Editable.RestoreCivilian()
    local system = Bridge.ClothingSystem
    if system == 'illenium-appearance' then
        ExecuteCommand('reloadskin')
    elseif system == 'qb-clothing' then
        TriggerServerEvent('qb-clothes:loadPlayerSkin')
    elseif system == 'esx_skin' and Bridge.Framework == 'esx' then
        local ESX = exports.es_extended:getSharedObject()
        ESX.TriggerServerCallback('esx_skin:getPlayerSkin', function(skin)
            TriggerEvent('skinchanger:loadSkin', skin)
        end)
    else
        return false
    end
    return true
end

function Editable.SetFuel(vehicle, fuel)
    local system = Bridge.FuelSystem
    fuel = fuel + 0.0
    if system == 'ox_fuel' then
        Entity(vehicle).state:set('fuel', fuel, true)
    elseif system ~= 'none' then
        pcall(function() exports[system]:SetFuel(vehicle, fuel) end)
    end
    SetVehicleFuelLevel(vehicle, fuel)
end

function Editable.GetFuel(vehicle)
    local system = Bridge.FuelSystem
    if system == 'ox_fuel' then
        local fuel = Entity(vehicle).state.fuel
        if fuel then return fuel + 0.0 end
    elseif system ~= 'none' then
        local ok, fuel = pcall(function() return exports[system]:GetFuel(vehicle) end)
        if ok and tonumber(fuel) then return tonumber(fuel) + 0.0 end
    end
    return GetVehicleFuelLevel(vehicle) + 0.0
end

server/editable.lua

Imported into editable/server.lua by V2.

Function What it does
Editable.GiveKeys
Editable.RemoveKeys
Editable.Notify
Editable.IsAdmin
lua
Editable = {}

function Editable.GiveKeys(src, vehicle, plate)
    local system = Bridge.KeysSystem
    if system == 'qbx_vehiclekeys' then
        exports.qbx_vehiclekeys:GiveKeys(src, vehicle)
    elseif system == 'qb-vehiclekeys' then
        TriggerClientEvent('vehiclekeys:client:SetOwner', src, plate)
    elseif system == 'wasabi_carlock' then
        exports.wasabi_carlock:GiveKey(src, plate)
    elseif system == 'MrNewbVehicleKeys' then
        exports.MrNewbVehicleKeys:GiveKeys(src, vehicle)
    elseif system == 'Renewed-Vehiclekeys' then
        exports['Renewed-Vehiclekeys']:addKey(src, plate)
    elseif system == 'jcks_vehicles' and GetResourceState('jcks_vehicles') == 'started' then
        exports.jcks_vehicles:GiveKey(src, plate, vehicle)
    end
end

function Editable.RemoveKeys(src, vehicle, plate)
    local system = Bridge.KeysSystem
    if system == 'qbx_vehiclekeys' then
        exports.qbx_vehiclekeys:RemoveKeys(src, vehicle)
    elseif system == 'wasabi_carlock' then
        exports.wasabi_carlock:RemoveKey(src, plate)
    elseif system == 'Renewed-Vehiclekeys' then
        exports['Renewed-Vehiclekeys']:removeKey(src, plate)
    elseif system == 'jcks_vehicles' and GetResourceState('jcks_vehicles') == 'started' then
        exports.jcks_vehicles:RemoveKey(src, plate, vehicle)
    end
end

function Editable.Notify(src, data)
    TriggerClientEvent('jcks_bridge:client:notify', src, data)
end

function Editable.IsAdmin(src)
    return false
end