JCKSDocs
JCKS JobsV1Referência

Default editable files

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

These are the editable files exactly as JCKS Jobs 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
ClientEditable.CanOpenMenu
ClientEditable.OnDutyChanged
ClientEditable.IsDown
ClientEditable.OnRestrained
ClientEditable.DispatchAlert
lua
ClientEditable = {}

function ClientEditable.CanOpenMenu(app)
    local ped = PlayerPedId()
    if IsEntityDead(ped) or IsPedCuffed(ped) then return false end
    if LocalPlayer.state.isDead or LocalPlayer.state.dead or LocalPlayer.state.isCuffed then return false end
    return true
end

function ClientEditable.OnDutyChanged(onDuty, jobName)
end

function ClientEditable.IsDown(serverId, ped)
    local state = Player(serverId).state
    if state.isDead or state.dead or state.inLastStand or state.laststand then return true end
    if IsPedDeadOrDying(ped, true) or IsPedFatallyInjured(ped) then return true end
    return IsEntityPlayingAnim(ped, 'combat@damage@writhe', 'writhe_loop', 3) or IsEntityPlayingAnim(ped, 'dead', 'dead_a', 3)
end

function ClientEditable.OnRestrained(kind)
end

function ClientEditable.DispatchAlert(call)
end

ClientEditable.Overrides = {
}

server/editable.lua

Imported into editable/server.lua by V2.

Function What it does
ServerEditable.CanHire
ServerEditable.OnHired
ServerEditable.OnFired
ServerEditable.OnDutyChanged
ServerEditable.IsDown
ServerEditable.OnRestrained
ServerEditable.SendInvoice
ServerEditable.OnPanic
ServerEditable.OnServiceCall
ServerEditable.OnRespawn
ServerEditable.Revive
ServerEditable.Heal
ServerEditable.OnImpound
lua
ServerEditable = {}

function ServerEditable.CanHire(src, jobName, grade)
    return true
end

function ServerEditable.OnHired(identifier, jobName, grade, src)
end

function ServerEditable.OnFired(identifier, jobName, src)
end

function ServerEditable.OnDutyChanged(src, jobName, onDuty, shiftSeconds)
end

local QBCore = nil
function ServerEditable.IsDown(src)
    local state = Player(src).state
    if state.isDead or state.dead or state.inLastStand or state.laststand then return true end
    if Bridge.Name == 'qb' then
        QBCore = QBCore or exports['qb-core']:GetCoreObject()
        local p = QBCore.Functions.GetPlayer(src)
        local meta = p and p.PlayerData.metadata
        if meta and (meta.isdead or meta.inlaststand) then return true end
    end
    local ped = GetPlayerPed(src)
    return ped ~= 0 and GetEntityHealth(ped) <= 0
end

function ServerEditable.OnRestrained(target, kind, src)
end

function ServerEditable.SendInvoice(src, target, jobName, amount, reason)
    return false
end

function ServerEditable.OnPanic(src, jobName, coords)
end

function ServerEditable.OnServiceCall(src, jobName, message, coords)
    return false
end

function ServerEditable.OnRespawn(src)
end

function ServerEditable.Revive(target, src)
    if Medical and Medical.Enabled() then
        Medical.Revive(target, src, { force = true })
    elseif GetResourceState('esx_ambulancejob') == 'started' then
        TriggerClientEvent('esx_ambulancejob:revive', target)
    elseif GetResourceState('qb-ambulancejob') == 'started' then
        TriggerClientEvent('hospital:client:Revive', target)
    else
        TriggerClientEvent('jcks_jobs:client:revive', target)
    end
end

function ServerEditable.Heal(target, src)
    if Medical and Medical.Enabled() then
        Medical.Heal(target, src)
    elseif GetResourceState('esx_ambulancejob') == 'started' then
        TriggerClientEvent('esx_ambulancejob:heal', target, 'big', true)
    else
        TriggerClientEvent('jcks_jobs:client:heal', target)
    end
end

function ServerEditable.OnImpound(src, vehicle, plate)
    if GetResourceState('jcks_vehicles') == 'started' then
        exports.jcks_vehicles:ImpoundVehicle(plate, { entity = vehicle, by = src })
    end
    return true
end