🖼️QBCore & QBOX

  1. Run this in your database:

ALTER TABLE `player_vehicles`
ADD COLUMN IF NOT EXISTS `job` varchar(50) DEFAULT NULL,
ADD COLUMN IF NOT EXISTS `notes` text DEFAULT NULL;
  1. Go to /config/config_s.lua and replace it with:

Config = {}

Config.locales = 'pl' -- en | pl

Config.debug = true -- debug logs 

Config.Search = 'id' -- ssn (fill hireSSN in Config.Queries) | id (server ID)

Config.hireDistance = 10 -- distance between players 

Config.daysOfWeek = {
    [1] = "Sunday",
    [2] = "Monday",
    [3] = "Tuesday",
    [4] = "Wednesday",
    [5] = "Thursday",
    [6] = "Friday",
    [7] = "Saturday"
}

Config.Jobs = {
    {
        onduty = 'police',
        offduty = 'offpolice',
        target = {
            {
                coords = vec3(440.46, -974.84, 30.69),
                size = vec3(2.6, 1.1, 1.0),
                rotation = 270,
            }
        }
    }
}



Config.licenses = {
    ['police'] = {
        {value = 'weapon', label = "Weapon license"},
        {value = 'swat', label = "SWAT license"},
        {value = 'dtu', label = "DTU license"}
    }
}

Config.chartColors = {
    ['end_day'] = {
        background = "rgba(241, 196, 15, 0.2)",
        border = "#f1c40f"
    },
    ['vehicles'] = {
        background = {
            "rgba(255, 99, 132, 0.2)", 
            "rgba(54, 162, 235, 0.2)", 
            "rgba(255, 206, 86, 0.2)"
        },
        border = {
            "rgba(255, 99, 132, 1)", 
            "rgba(54, 162, 235, 1)", 
            "rgba(255, 206, 86, 1)"
        }
    },
    ['vehicles_availability'] = {
        background = {
            "rgba(75, 192, 192, 0.2)", 
            "rgba(255, 99, 132, 0.2)"
        },
        border = {
            "rgba(75, 192, 192, 1)", 
            "rgba(255, 99, 132, 1)"
        }
    },
    ['employees'] = {
        background = {
            "rgba(75, 192, 192, 0.2)", 
            "rgba(255, 99, 132, 0.2)"
        },
        border = {
            "rgba(75, 192, 192, 1)", 
            "rgba(255, 99, 132, 1)"
        }
    },
}

Config.perms = {
    police = {
        grantLicense = 3,
        changeBadge = 2,
        promoteEmployee = 4,
        fireEmployee = 1,
        hireEmployee = 1
    }
}

Config.databaseTables = {
    vehicle = {
        job = 'job',
        notes = 'notes'
    },
    player_jobs = {
        player_jobs = 'player_jobs',
        identifier = 'identifier',
        grade = 'grade',
        job = 'job',
    }
}

Config.giveJob = {
    enabled = true,
    name = 'givejob', -- command name
    restricted = 'group.admin'
}

Config.webhook = function(title, description) 
    local embed = {
        {
            ["title"] = title,
            ["description"] = description,
            ['color'] = 16763904,
            ["timestamp"] = os.date("!%Y-%m-%dT%H:%M:%SZ"),
        }
    }
    local username = 'Bossmenu Logs'
    return {embed = embed, username = username}
end

Config.additionalEmployeeData = {'cid', metadata = { 'callsign as badge'}}

Config.moneyItem = 'money'

Config.Queries = {
    ['image'] = "SELECT JSON_UNQUOTE(JSON_EXTRACT(charinfo, '$.profilepic')) AS image FROM `players` WHERE `citizenid` = ?",
    ['changeBadge'] = "UPDATE players SET metadata = JSON_SET(metadata, '$.callsign', @badge) WHERE citizenid = @identifier",
    ['hireSSN'] = 'SELECT identifier FROM users WHERE ssn = @ssn',
    ['saveNotes'] = 'UPDATE player_vehicles SET notes = @notes WHERE plate = @plate',
    ['changeVehOwner'] = 'UPDATE player_vehicles SET citizenid = @newowner WHERE plate = @plate'
}

Config.getAccount = function(job, cb)
    local banking = exports['qb-banking']
    local account = banking:GetAccount(job.name)
    if not account then return cb(nil) end
    cb({
        money = account.account_balance,
        removeMoney = function(amount)
            banking:RemoveMoney(job.name, amount)
        end,
        addMoney = function(amount)
            banking:AddMoney(job.name, amount)
        end
    })
end


Config.Notify = function(source, message)
    TriggerClientEvent('ox_lib:notify', source, {
        title = 'Bossmenu',
        description = message,
        position = 'center-left'
    })
end

Config.hirePlayer = function(player, job, grade) -- player = framework player
    player.Functions.SetJob(job, grade)
end

Config.formatTime = function(totalSeconds)
    local hours = math.floor(totalSeconds / 3600)
    local minutes = math.floor((totalSeconds % 3600) / 60)
    local seconds = totalSeconds % 60

    return string.format("%02d:%02d:%02d", hours, minutes, seconds)
end

Config.convertTimestamp = function(timestamp)
    local time = os.date("*t", timestamp)
    return string.format("%02d/%02d/%04d - %02d:%02d:%02d", time.day, time.month, time.year, time.hour, time.min, time.sec)
end

Config.getLicenses = function(identifier, cb)
    local licenselabels = {
        ['weapon'] = 'Weapon License' -- add more labels if you want
    }
    MySQL.Async.fetchScalar("SELECT metadata FROM players WHERE citizenid = ?", {identifier}, function(metadata)
        if metadata then
            local metadataTable = json.decode(metadata)
            local licenses = metadataTable.licences

            local validLicenses = {}

            if licenses then
                for license, granted in pairs(licenses) do
                    if granted then
                        table.insert(validLicenses, {name = licenselabels[license] or license, date = nil, nadana = nil})
                    end
                end
            end

            cb(validLicenses)
        else
            cb({})
        end
    end)
end


Config.revokeLicense = function(license, identifier, cb)
    MySQL.Async.fetchScalar('SELECT metadata FROM players WHERE citizenid = ?', {identifier}, function(metadata)
        if not metadata then return cb(false) end
        local meta = json.decode(metadata)
        meta.licences[license] = false
        MySQL.Async.execute('UPDATE players SET metadata = ? WHERE citizenid = ?', {json.encode(meta), identifier}, function(rowsChanged)
            cb(rowsChanged > 0)
        end)
    end)
end

Config.transfer = function(accountnumber, amount, title, cb)
    cb(true) -- FILL WITH YOUR BANKING FUNCTIONS
end

Config.AddLicense = function(license, identifier, cb)
    MySQL.Async.fetchScalar('SELECT metadata FROM players WHERE citizenid = ?', {identifier}, function(metadata)
        if not metadata then return cb(false) end
        local meta = json.decode(metadata)
        local licensefound = false
        for name, status in pairs(meta.licences) do
            if name == license then
                if status then
                    licensefound = true
                    cb(false)
                else
                    licensefound = true
                    meta.licences[name] = true
                    MySQL.Async.execute('UPDATE players SET metadata = ? WHERE citizenid = ?', {json.encode(meta), identifier}, function(rowsChanged)
                        cb(rowsChanged > 0)
                    end)
                end
            end
        end
        if not licensefound then
            meta.licences[license] = true
            MySQL.Async.execute('UPDATE players SET metadata = ? WHERE citizenid = ?', {json.encode(meta), identifier}, function(rowsChanged)
                cb(rowsChanged > 0)
            end)
        end
    end)
end

Config.setDuty = function(player, duty, job, grade)
    if duty then
        Framework.setJob(player, job.onduty, grade)
        Config.Notify(source, 'You are on duty now')
    else
        Framework.setJob(player, job.offduty, grade)
        Config.Notify(source, 'You are off duty now')
    end
end

Config.checkDuty = function(onduty, playerJob, job, source)
    if onduty then
        if playerJob.name == job.onduty then
            Config.Notify(source, t('backend.already_on_duty'))
            return false
        end
    elseif not onduty and playerJob.name == job.offduty then
        Config.Notify(source, t('backend.already_off_duty'))
        return false
    else
        return true
    end
end

Config.giveJobVehicle = {
    enabled = true,
    name = 'givejobveh', -- command name
    restricted = 'group.admin',
    query = 'UPDATE player_vehicles SET job = @job, citizenid = NULL WHERE plate = @plate'
}

Last updated