Accessible code
function OpenManageEmployeesMenu()
if IsESX() then
TriggerEvent('esx_society:openBossMenu', GetJob(), function(data, menu)
end, { wash = false }) -- disable washing money
elseif IsQBCore() then
if Jobs[PlayerData.job.name] then
TriggerEvent('qb-bossmenu:client:OpenMenu')
else
if Jobs[PlayerData.gang.name] then
TriggerEvent('qb-gangmenu:client:OpenMenu')
end
end
end
end
function Notify(description, type)
lib.notify({
description = description,
duration = 4500,
type = type,
position = Config.NotifyPosition
})
end
RegisterNetEvent('uniq-jobcreator:notify', Notify)
local oxinv = GetResourceState('ox_inventory'):find('start')
local qsinv = GetResourceState('qs-inventory'):find('start')
local qbinv = GetResourceState('qb-inventory'):find('start')
local psinv = GetResourceState('ps-inventory'):find('start')
function OpenStash(id, slots, weight)
if oxinv then
exports.ox_inventory:openInventory('stash', id)
elseif qsinv or qbinv or psinv then
TriggerServerEvent("inventory:server:OpenInventory", "stash", id, {
maxweight = weight,
slots = slots,
})
TriggerEvent('inventory:client:SetCurrentStash', id)
end
end
-- event/export here
function GiveCarKeys(plate)
-- TriggerServerEvent('qb-vehiclekeys:server:GiveVehicleKeys', cache.serverId, plate)
-- TriggerEvent("vehiclekeys:client:SetOwner", plate)
end
local illenium = GetResourceState('illenium-appearance'):find('start')
local wasabi = GetResourceState('fivem-appearance'):find('start')
function OpenWardrobe()
if illenium then
TriggerEvent('illenium-appearance:client:openOutfitMenu')
elseif wasabi then
exports['fivem-appearance']:openWardrobe()
end
end
function OpenNearbyPlayerInventory(id)
if id then
if oxinv then
exports.ox_inventory:openInventory('player', id)
elseif qsinv or qbinv or psinv then
TriggerServerEvent("inventory:server:OpenInventory", "otherplayer", id)
end
end
end
local oxinv = GetResourceState('ox_inventory'):find('start')
local qsinv = GetResourceState('qs-inventory'):find('start')
local qbinv = GetResourceState('qb-inventory'):find('start')
local psinv = GetResourceState('ps-inventory'):find('start')
function RegisterStash(id, slots, weight)
if qsinv then
exports['qs-inventory']:RegisterStash('', id, slots, weight)
elseif oxinv then
exports.ox_inventory:RegisterStash(id, '', slots, weight, nil)
end
end
lib.callback.register('uniq-jobcreator:fetchCars', function(source)
if IsESX() then
local xPlayer = ESX.GetPlayerFromId(source)
local identifier = xPlayer.identifier
local vehicles = {}
local results = MySQL.query.await("SELECT `plate`, `vehicle`, `stored` FROM `owned_vehicles` WHERE `owner` = ? AND `type` = ?", {identifier, 'car'})
if results[1] then
for i = 1, #results do
local result = results[i]
local veh = json.decode(result.vehicle) -- vehicle properties
if result.stored == 1 or result.stored == true then
-- what is important is to send vehicle plate and vehicle properties
vehicles[#vehicles + 1] = { plate = result.plate, vehicle = veh }
end
end
end
return vehicles
elseif IsQBCore() then
local Player = QBCore.Functions.GetPlayer(source)
local identifier = Player.PlayerData.citizenid
local vehicles = {}
local results = MySQL.query.await("SELECT `plate`, `mods`, `state` FROM `player_vehicles` WHERE `citizenid` = ?", { identifier })
if results[1] then
for i = 1, #results do
local result = results[i]
local veh = json.decode(result.mods) -- vehicle properties
if result.state == true or result.state == 1 then
-- what is important is to send vehicle plate and vehicle properties
vehicles[#vehicles + 1] = { plate = result.plate, vehicle = veh }
end
end
end
return vehicles
end
return {}
end)
lib.callback.register('uniq-jobcreator:GetItems', function(source)
local items = {}
local accounts = {}
if oxinv then
for k,v in pairs(exports.ox_inventory:Items()) do
items[v.name] = { label = v.label, value = v.name }
end
elseif qsinv or qbinv or psinv then
for k,v in pairs(QBCore.Shared.Items) do
items[v.name] = { label = v.label, value = v.name }
end
end
if IsESX() then
for k,v in pairs(ESX.GetConfig().Accounts) do
accounts[#accounts + 1] = {label = v.label, value = k}
end
if not oxinv then
for k,v in pairs(ESX.Items) do
items[v.name] = { label = v.label, value = v.name }
end
end
elseif IsQBCore() then
for k,v in pairs(QBCore.Config.Money.MoneyTypes) do
accounts[#accounts + 1] = {label = k:upper(), value = k}
end
end
return items, accounts
end)
RegisterNetEvent('uniq-jobcreator:changeStored', function(plate)
if IsESX() then
MySQL.update('UPDATE `owned_vehicles` SET `stored` = 0 WHERE `plate` = ?', {string.strtrim(plate)})
elseif IsQBCore() then
MySQL.update('UPDATE `player_vehicles` SET `state` = 0 WHERE `plate` = ?', {string.strtrim(plate)})
end
end)
RegisterNetEvent('uniq-jobcreator:ShopBuy', function(data)
local src = source
if IsESX() then
local xPlayer = ESX.GetPlayerFromId(src)
if xPlayer then
local price = data.price * data.count
local money = xPlayer.getAccount(data.currency).money
if money >= price then
xPlayer.removeAccountMoney(data.currency, price)
xPlayer.addInventoryItem(data.item, data.count)
else
TriggerClientEvent('uniq-jobcreator:notify', src, 'You dont have enough money', 'error')
end
end
elseif IsQBCore() then
local Player = QBCore.Functions.GetPlayer(src)
if Player then
local price = data.price * data.count
local money = Player.PlayerData.money[data.currency]
if money >= price then
Player.Functions.RemoveMoney(data.currency, price)
Player.Functions.AddItem(data.item, data.count)
end
end
end
end)
function SetJob(source, job, grade, isGang)
if IsESX() then
local xPlayer = ESX.GetPlayerFromId(source)
if xPlayer then
xPlayer.setJob(job, grade)
end
elseif IsQBCore() then
local Player = QBCore.Functions.GetPlayer(source)
if Player then
if not isGang then
Player.Functions.SetJob(job, grade)
else
Player.Functions.SetGang(job, grade)
end
end
end
end
-- when you create new job this is triggered
function AddSocietyJob(society, label)
local query = {}
if IsESX() then
local name = ('society_%s'):format(society)
query[#query + 1] = { query = 'INSERT INTO `addon_account` (name, label, shared) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE label = VALUES(label), shared = VALUES(shared)', values = { name, label, "1" }}
query[#query + 1 ] = { query = 'INSERT INTO `datastore` (name, label, shared) VALUES (?, ?, ?)', values = { name, label, 1 } }
query[#query + 1 ] = { query = 'INSERT INTO `addon_inventory` (name, label, shared) VALUES (?, ?, ?)', values = { name, label, 1 } }
query[#query + 1] = { query = 'INSERT INTO `addon_account_data` (account_name, money) VALUES (?, ?)', values = {name, 0} }
local success, response = pcall(MySQL.transaction.await, query)
if not success then
print(response)
end
TriggerEvent('esx_addonaccount:refreshAccounts')
Wait(100)
TriggerEvent('esx_society:registerSociety', society, label, name, name, name, { type = 'public' })
end
end
-- when script is started, esx only
function RegisterSociety(society, label)
if IsESX() then
local name = ('society_%s'):format(society)
TriggerEvent('esx_society:registerSociety', society, label, name, name, name, { type = 'public' })
end
end
function DeleteStash(id)
if oxinv then
exports.ox_inventory:ClearInventory(id)
elseif qsinv then
MySQL.prepare.await('DELETE FROM `inventory_stash` WHERE `stash` LIKE ?', {id})
elseif qbinv or psinv then
MySQL.prepare.await('DELETE FROM `stashitems` WHERE `stash` LIKE ?', {id})
end
end
function DeleteJob(name)
if IsESX() then
local society = ('society_%s'):format(name)
local deleteQuery = {
{query = 'DELETE FROM `addon_account` WHERE `name` = ?', values = {society}},
{query = 'DELETE FROM `addon_inventory` WHERE `name` = ?', values = {society}},
{query = 'DELETE FROM `datastore` WHERE `name` = ?', values = {society}},
{query = 'DELETE FROM `datastore_data` WHERE `name` = ?', values = {society}},
{query = 'DELETE FROM `addon_account_data` WHERE `account_name` = ?', values = {society}},
{query = 'DELETE FROM `jobs` WHERE `name` = ?', values = {name}},
{query = 'DELETE FROM `job_grades` WHERE `job_name` = ?', values = {name}},
{query = 'DELETE FROM `uniq_jobs` WHERE name = ?', values = {name}},
}
local success, response = pcall(MySQL.transaction.await, deleteQuery)
if not success then print(response) end
elseif IsQBCore() then
local deleteQuery = { {query = 'DELETE FROM `uniq_jobs` WHERE name = ?', values = {name}} }
local success, response = pcall(MySQL.transaction.await, deleteQuery)
if not success then print(response) end
end
end
function CreateJobs()
end
Config = {
Locale = 'en',
DrawMarkerDistance = 15.0,
-- if you enable actions menu while creating job, this key will be set at default
ActionsMenuKey = 'F6',
ActionsMenuPosition = 'top-right',
freezeWhileCuffed = true,
moneyLabels = {
-- esx
money = 'Money',
bank = 'Bank',
black_money = 'Black Money',
-- qb
cash = 'Cash',
crypto = 'Crypto'
},
/*
ox
ImagePath = 'https://cfx-nui-ox_inventory/web/images/%s.png',
qs inv
ImagePath = 'https://cfx-nui-qs-inventory/html/images/%s.png',
qb inv
ImagePath = 'https://cfx-nui-qb-inventory/html/images/%s.png',
if you use some external link for images then put that link here
*/
ImagePath = 'https://cfx-nui-ox_inventory/web/images/%s.png',
Commands = {
creator = {
name = 'jobcreator',
restricted = 'group.admin'
},
addNewMarker = {
name = 'newmarker',
restricted = 'group.admin'
},
deleteJob = {
name = 'deletejob',
restricted = 'group.admin'
},
editJobOutfit = {
name = 'editjoboutfit',
restricted = 'group.admin'
},
editVehicles = {
name = 'editvehicle',
restricted = 'group.admin'
},
editBoat = {
name = 'editboat',
restricted = 'group.admin'
},
editHelicopter = {
name = 'editheli',
restricted = 'group.admin'
},
teleportToMarker = {
name = 'tpbase',
restricted = 'group.admin'
},
deleteMarker = {
name = 'deletemarker',
restricted = 'group.admin'
},
editShop = {
name = 'editshop',
restricted = 'group.admin'
},
editActionMenu = {
name = 'editmenu',
restricted = 'group.admin'
}
},
NotifyPosition = 'bottom-right',
}
Discord = {
url = '', -- url here
title = 'Server Name',
/*
https://www.spycolor.com/
['default'] = 14423100,
['blue'] = 255,
['red'] = 16711680,
['green'] = 65280,
['white'] = 16777215,
['black'] = 0,
['orange'] = 16744192,
['yellow'] = 16776960,
['pink'] = 16761035,
['lightgreen'] = 65309,
*/
color = 65309, -- 255
imageUrl = 'https://cdn.discordapp.com/attachments/1126197898439295066/1129791542379434004/discord_banner_uniq.png', -- optional, if you dont want it put ''
}
Last updated