Functions

Information regarding boii_base server utility functions

Locals

Local functions are assigned to the boii object you can access this object by adding the export below into your server side files.

local boii = exports['boii_base']:get_object()
boii.print = print_message
boii.chat_message =  chat_message
boii.get_identifier = get_identifier
boii.get_unique_id = get_unique_id
boii.get_user = get_user
boii.get_pending_paychecks = get_pending_paychecks
boii.get_last_payment_time = get_last_payment_time

Utility function to print a formatted message to the console.

boii.print(1, 'SYSTEM', 'Test print..')
local function print_message(colour, type, message)
    print('^'..colour..'['..type..'] ^7- '..message)
end

chat_message(source, message)

Utility function to send a chat message to client.

boii.chat_message(source, 'Test chat message..')
local function chat_message(source, message)
    TriggerClientEvent('chat:addMessage', source, {
        args = {message}
    })
end

get_user(source)

Utility function to get the correct user from the connect_users table.

local player = source
local player = boii.get_user(player)
local function get_user(source)
    return boii.connected_users[source]
end

get_identifier(source, id_type)

Utility function to get a players identifier by type.

local license = boii.get_identifier(source, 'license')
local function get_identifier(source, id_type)
    local ids = GetPlayerIdentifiers(source)
    for _, id in pairs(ids) do
        if string.find(id, id_type) then
            return id
        end
    end
    return nil
end

get_unique_id(license)

Utiliity function to get a players unique id by license.

local license = boii.get_identifier(_src, 'license2')
local unique_id = boii.get_unique_id(license)
local function get_unique_id(license)
    local query = 'SELECT unique_id FROM users WHERE license = ?'
    local params = {license}
    local result = MySQL.query.await(query, params)
    if result[1] ~= nil then
        return result[1].unique_id
    end
end

get_last_payment_time(player, job_id)

Utility function to get the last time the player received a new paycheck.

local last_payment_time = boii.get_last_payment_time(source, 'lspd')
local function get_last_payment_time(player, job_id)
    if player.paychecks[job_id] and #player.paychecks[job_id] > 0 then
        return player.paychecks[job_id][#player.paychecks[job_id]].timestamp
    end
    return 0
end

get_pending_paychecks(player, job_id)

Utility function to return a players pending paychecks.

local function get_pending_paychecks(player, job_id)
    if player.paychecks[job_id] then
        return player.paychecks[job_id]
    else
        return {}
    end
end

Last updated