A standalone utility for managing licenses, such as driving or firearm licenses, independent of any framework. It provides functionality to fetch, update, and check license statuses both client and server-side.
Client Functions
get_licences
Gets all licence data for the player and logs response.
--- Utils object
local player_licences = utils.licences.get_licences()
if player_licences then
print('Licences:', json.encode(player_licences))
else
print('No licences found.')
end
--- Direct export
exports.boii_utils:get_licences()
update_licence
Updates a specific licences status.
--- Define licence id
local licence_id = 'driving'
--- Specify test type
local test_type = 'practical'
--- Specify status
local passed = true
--- Utils object
utils.licences.update(licence_id, test_type, passed)
--- Direct export
exports.boii_utils:update_licence(licence_id, test_type, passed)
check_licence
Checks if a player has the required licence status.
--- Define licence id
local licence_id = 'driving'
--- Define test type
local test_type = 'theory'
--- Utils object
utils.licences.check_licence(licence_id, test_type, function(has_passed)
if has_passed then
print("Player has passed the theory test.")
else
print("Player has not passed the theory test.")
end
end)
--- Direct export
exports.boii_utils:check_licence(...)
Server Functions
get_licences
Use the following to get the players licences.
--- Utils object
local licences = utils.licences.get(source)
print('Licences:', licences)
--- Direct export
local licences = exports.boii_utils:get_licences(source)
update_licence
Use the following the update a players licence status.
--- Specify licence id
local licence_id = 'car'
--- Specify test type
local test_type = 'practical'
--- Specify passed state
local passed = true
--- Utils object
utils.licences.update(source, licence_id, test_type, passed)
--- Direct export
exports.boii_utils:update(source, licence_id, test_type, passed)
update_licence_data
Use the following to update a players licence data.
--- Specify licence
local licence = 'car'
--- Specify licence data
local licence_data = {
fn = 'John',
ln = 'Doe',
}
--- Utils object
utils.licences.update_data(source, licence, licence_data)
--- Direct export
exports.boii_utils:update_licence_data(source, licence, licence_data)
check_licence_passed
Use the following to check if a player has passed a licence.
--- Specify licence
local licence = 'car'
--- Specify test type
local test_type = 'practical'
--- Utils object
utils.licences.check_passed(source, licence, test_type)
--- Direct export
exports.boii_utils:check_licence_passed(source, licence, test_type)