📝Configuration

Client config

Config = {}

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

Config.getVehicleLabel = function(hash)
    local veh = GetDisplayNameFromVehicleModel(hash)
    local label = GetLabelText(veh) ~= 'NULL' and GetLabelText(veh) or nil
    return label or veh
end

RegisterCommand('bossmenu', function()
    openBossmenu()
end)

Config.hireAlert = function(name, job)
    local alert = lib.alertDialog({
        header = 'Attention!',
        content = name .. ' invited you to work for ' .. job .. '.  \nDo you accept the invitation?',
        centered = true,
        cancel = true
    })
    return alert == 'confirm' and true or false
end

Config.dutyOptions = function(job)
    {
        {
            icon = 'fas fa-business-time',
            label = 'Go on duty',
            distance = 2.0,
            groups = {
                [job.onduty] = 0,
                [job.offduty] = 0
            },
            onSelect = function(data)
                TriggerServerEvent('pp-bossmenu:setDuty', true, job)
            end
        },
        {
            icon = 'fas fa-business-time',
            label = 'Go off duty',
            distance = 2.0,
            groups = {
                [job.onduty] = 0,
                [job.offduty] = 0
            },
            onSelect = function(data)
                TriggerServerEvent('pp-bossmenu:setDuty', false, job)
            end
        }
    }
end

Config.dutyProgress = function(onduty)
    local progress = lib.progressBar({
        duration = 5000,
        label = onduty and 'Entering duty' or 'Leaving duty',
        useWhileDead = false,
        canCancel = true,
        disable = {
            car = true,
            move = true
        },
    })
    return progress
end

Server config

Config = {}

Config.locales = 'en' -- 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 = { -- job name
        grantLicense = 3, -- permission = grade
        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 = {'badge', 'image'} -- additional employee details data

Config.moneyItem = 'money'

Config.Queries = {
    ['image'] = "SELECT mdt_image AS image FROM `users` WHERE `identifier` = ?",
    ['changeBadge'] = "UPDATE users SET badge = @badge WHERE identifier = @identifier",
    ['hireSSN'] = 'SELECT identifier FROM users WHERE ssn = @ssn',
    ['saveNotes'] = 'UPDATE owned_vehicles SET notes = @notes WHERE plate = @plate',
    ['changeVehOwner'] = 'UPDATE owned_vehicles SET owner = @newowner WHERE plate = @plate'
}

Config.getAccount = function(job, cb)
    TriggerEvent('esx_addonaccount:getSharedAccount', 'society_' .. job.name, function(account)
        cb(account)
    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.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 licensesData = {}

    MySQL.Async.fetchAll('SELECT ul.date, COALESCE(l.label, ul.type) AS name FROM user_licenses ul LEFT JOIN licenses l ON ul.type = l.type WHERE ul.owner = @owner', {
        ['@owner'] = identifier
    }, function(result)
        for i=1, #result, 1 do
            table.insert(licensesData, {
                date = Config.convertTimestamp(tonumber(result[i].date / 1000)), 
                name = result[i].name
            })
        end
        if cb then
            cb(licensesData)
        end
    end)
end

Config.revokeLicense = function(license, identifier, cb)
    MySQL.Async.execute('DELETE FROM user_licenses WHERE owner = ? AND type = ?', {identifier, license}, function(rowsChanged) 
        cb(rowsChanged > 0)
    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 COUNT(*) FROM user_licenses WHERE type = ? AND owner = ?', {license, identifier}, function(count)
        if count > 0 then
            cb(false)
        else
            MySQL.Async.execute('INSERT INTO user_licenses (type, owner) VALUES (?, ?)', {license, 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 owned_vehicles SET job = @job, owner = NULL WHERE plate = @plate'
}

Last updated