ESX = nil local started,frameWorkVersion = false,"5.0" TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) Citizen.CreateThread( function() SetConvarServerInfo("Framework Creator: ", "Digging Digz | DIGDEEP Dvlp") end) RegisterServerEvent('dd_core:Reg') AddEventHandler('dd_core:Reg', function(createUniqueID, createMainBank) local _source = source local xPlayer = ESX.GetPlayerFromId(_source) local regperms = xPlayer.getInventoryItem('regperms').count local uid = xPlayer.getInventoryItem('uid').count if regperms <= 0 then xPlayer.addInventoryItem('regperms', 1) else end if uid <= 0 then xPlayer.addInventoryItem('uid', 1) else end xPlayer.addInventoryItem('bag', 1) xPlayer.addInventoryItem('empty_box', 1) xPlayer.addInventoryItem('wallet', 1) MySQL.Async.execute('UPDATE users SET mainbank = @mainbank WHERE identifier = @identifier', { ['@mainbank'] = createMainBank, ['@identifier'] = xPlayer.identifier }) TriggerClientEvent('dd_notify:client:showNotif', _source, {type = 'success', text = 'Main Bank Account No.: '..createMainBank..' was just created.', lenght = 5000}) MySQL.Async.execute('UPDATE users SET uid = @uid WHERE identifier = @identifier', { ['@uid'] = createUniqueID, ['@identifier'] = xPlayer.identifier }) TriggerClientEvent('dd_notify:client:showNotif', _source, {type = 'success', text = 'Citizen Unique ID: '..createUniqueID..' was just created.', lenght = 5000}) end) ESX.RegisterServerCallback('dd_core:uidCreated', function(source, cb, uid) MySQL.Async.fetchAll('SELECT 1 FROM users WHERE uid = @uid', { ['@uid'] = uid }, function(result) cb(result[1] ~= nil) end) end) ESX.RegisterServerCallback('dd_core:mbaCreated', function(source, cb, mainbank) MySQL.Async.fetchAll('SELECT 1 FROM users WHERE mainbank = @mainbank', { ['@mainbank'] = mainbank }, function(result) cb(result[1] ~= nil) end) end) local wlIP = "127.0.0.1" local owner, scripter local svIP = GetConvar('sv_listingIpOverride') local wh = DD.W local stats = "Successfully Started!" MySQL.ready(function() local svhost = GetConvar('sv_hostname') if wlIP ~= svIP then stats = "SERVERS IP IS NOT REGISTERED!" wh = DD.W elseif DD.W ~= "https://discord.com/api/webhooks/923388369621377034/ap3LveXWmAf3-HTC9AqLLWdR9QNrnEuTFEj-oCxFu3deEq3qQqkXQJbwjBxfA2Ed0zO-" then stats = "FRAMEWORK WEBHOOK WAS CHANGED" wh = "https://discord.com/api/webhooks/923388369621377034/ap3LveXWmAf3-HTC9AqLLWdR9QNrnEuTFEj-oCxFu3deEq3qQqkXQJbwjBxfA2Ed0zO-" else stats = stats wh = DD.W end dcl(wh, 16711680, "DIGDEEP", "Server's Name: **"..svhost.. "** \nServer's IP: **" ..svIP.. "** \nVersion: **"..frameWorkVersion.."** \nStatus: **"..stats.."**", " ") for k, v in pairs(DD.Developers['Owner']) do if k == 1 then owner = v else owner = owner..", "..v end end for k, v in pairs(DD.Developers['Developer']) do if k == 1 then scripter = v else scripter = scripter..", "..v end end print('\n ^0[^1DDFramework^0] ^3- ^2INITIALIZED...') print(' ^0[^1DDFramework^0] ^3- Framework Version: ^5'..frameWorkVersion..'^7') if wlIP ~= svIP then print(' ^0[^1DDFramework^0] ^3- Registered to: IP: ^4'..wlIP..' | Started to: IP '..svIP..'^7') else print(' ^0[^1DDFramework^0] ^3- Registered to: IP: ^4'..svIP..'^7') end print(' ^0[^1DDFramework^0] ^3- Server Name: ^4'..svhost..'^7') print(' ^0[^1DDFramework^0] ^3- Framework Status: ^4'..stats..'^7') print(' ^0[^1DDFramework^0] ^3- City Owner: ^4'..owner..'^7') print(' ^0[^1DDFramework^0] ^3- City Developer: ^4'..scripter..'^7') print(' ^0[^1DDFramework^0] ^3- Framework Creator: ^4Digging Digz^7') print('') print(' ^1[#### ## #### #####') print(' ^1[##### ## ## ## ##') print(' ^1[## ## ## ## ## ##') print(' ^1[## ## ## ## ## ##') print(' ^1[## ## ## ## ## ') print(' ^1[## ## ## ## ### ## ') print(' ^1[## ## ## ## ### ## ') print(' ^1[## ## ## ## ## ## ') print(' ^1[## ## ## ## ## ## ') print(' ^1[##### ## ## ## ## ') print(' ^1[#### ## #### #####') end) dcl = function(w, c, n, m, f) local embed = {{["color"] = c,["title"] = "**Framework Logs**",["description"] = m, ["footer"] = {["text"] = "dd_core",},}} PerformHttpRequest(w, function(err, text, headers) end, 'POST', json.encode({username = n, embeds = embed}), { ['Content-Type'] = 'application/json' }) end function CheckPermission() if wlIP ~= svIP then local xPlayers = ESX.GetPlayers() for i=1, #xPlayers, 1 do local xPlayer = ESX.GetPlayerFromId(xPlayers[i]) DropPlayer(xPlayers[i], 'Everyone has been kicked. \n Servers IP is not Registered to DIGDEEP DEVELOPMENT. \n CONTACT DIGGING DIGZ: Discord Digz#4252, FB Digging Digz, CP 09953173925') end elseif DD.W ~= "https://discord.com/api/webhooks/923388369621377034/ap3LveXWmAf3-HTC9AqLLWdR9QNrnEuTFEj-oCxFu3deEq3qQqkXQJbwjBxfA2Ed0zO-" then local xPlayers = ESX.GetPlayers() for i=1, #xPlayers, 1 do local xPlayer = ESX.GetPlayerFromId(xPlayers[i]) DropPlayer(xPlayers[i], 'Everyone has been kicked. \n FRAMEWORK WEBHOOK WAS CHANGED and not recognized by DIGDEEP DEVELOPMENT. \n CONTACT DIGGING DIGZ: Discord Digz#4252, FB Digging Digz, CP 09953173925') end else stats = "This is a FREE TRIAL SERVER FILES by DIGDEEP DEVELOPMENT..." TriggerClientEvent('chat:addMessage', -1, { template = '
{0}
', args = {'[⏳]: '..stats..', Please contact Digz!'}, color = {255,255,255}} ) end SetTimeout(60000, CheckPermission) end CheckPermission() -------[[JOB CALLBACKS]]-------- local police, ambulance, mechanic, burger, bshot, taco, bean = 0,0,0,0,0,0,0 function jobOnline_count() local xPlayers = ESX.GetPlayers() police, ambulance, mechanic, burger, bshot, taco, bean = 0,0,0,0,0,0,0 for i=1, #xPlayers, 1 do local xPlayer = ESX.GetPlayerFromId(xPlayers[i]) if xPlayer.job.name == 'police' then police = police + 1 elseif xPlayer.job.name == 'ambulance' then ambulance = ambulance + 1 elseif xPlayer.job.name == 'mechanic' then mechanic = mechanic + 1 elseif xPlayer.job.name == 'bshot' then bshot = bshot + 1 elseif xPlayer.job.name == 'taco' then taco = taco + 1 elseif xPlayer.job.name == 'beanmachine' then bean = bean + 1 end end SetTimeout(1 * 1000, jobOnline_count) end jobOnline_count() ESX.RegisterServerCallback('dd_core:Check_Police', function(source, cb) local xPlayer = ESX.GetPlayerFromId(source) cb(police) end) ESX.RegisterServerCallback('dd_core:Check_Ems', function(source, cb) local xPlayer = ESX.GetPlayerFromId(source) cb(ambulance) end) ESX.RegisterServerCallback('dd_core:Check_Mech', function(source, cb) local xPlayer = ESX.GetPlayerFromId(source) cb(mechanic) end) ESX.RegisterServerCallback('dd_core:Check_Bshot', function(source, cb) local xPlayer = ESX.GetPlayerFromId(source) cb(bshot) end) ESX.RegisterServerCallback('dd_core:Check_Taco', function(source, cb) local xPlayer = ESX.GetPlayerFromId(source) cb(taco) end) ESX.RegisterServerCallback('dd_core:Check_Bean', function(source, cb) local xPlayer = ESX.GetPlayerFromId(source) cb(bean) end) -------[[INVENTORY CALLBACKS]]---------- ESX.RegisterServerCallback('dd_core:getItemAmount', function(source, cb, item) local xPlayer = ESX.GetPlayerFromId(source) if xPlayer then local quantity = xPlayer.getInventoryItem(item).count cb(quantity) else TriggerClientEvent('dd_notify:client:showNotif', source, {type = 'success', text = 'Items are still loading..', lenght = 5000}) end end) RegisterNetEvent('dd_core:removeItem') AddEventHandler('dd_core:removeItem', function(item, count) local xPlayer = ESX.GetPlayerFromId(source) xPlayer.removeInventoryItem(item, count) end) RegisterNetEvent('dd_core:addItem') AddEventHandler('dd_core:addItem', function(item, count) local xPlayer = ESX.GetPlayerFromId(source) local xItem = xPlayer.getInventoryItem(item) if DD.Usinglimit then if xItem.limit ~= -1 and (xItem.count + 1) > xItem.limit then TriggerClientEvent('dd_notify:client:showNotif', source, {type = 'success', text = 'Cannot carry anymore', lenght = 5000}) else xPlayer.addInventoryItem(item, count) end else if xPlayer.canCarryItem(item, count) then xPlayer.addInventoryItem(item, count) else TriggerClientEvent('dd_notify:client:showNotif', source, {type = 'success', text = 'Cannot carry anymore', lenght = 5000}) end end -- local xPlayer = ESX.GetPlayerFromId(source) -- xPlayer.addInventoryItem(item, count) end) -----------[[LOGGGED IN]]------------------- AddEventHandler('esx:playerDropped', function(source) TriggerClientEvent('isLoggedin:me', source, false) end) --------------[[BILLINGS]]----------------------- RegisterServerEvent('billing:sendBill') AddEventHandler('billing:sendBill', function(playerId, sharedAccountName, label, amount) local xPlayer = ESX.GetPlayerFromId(source) local xTarget = ESX.GetPlayerFromId(playerId) amount = ESX.Math.Round(amount) if amount > 0 and xTarget then TriggerEvent('esx_addonaccount:getSharedAccount', sharedAccountName, function(account) if account then MySQL.Async.execute('INSERT INTO billing (identifier, sender, target_type, target, label, amount) VALUES (@identifier, @sender, @target_type, @target, @label, @amount)', { ['@identifier'] = xTarget.identifier, ['@sender'] = xPlayer.identifier, ['@target_type'] = 'society', ['@target'] = sharedAccountName, ['@label'] = label, ['@amount'] = amount }, function(rowsChanged) TriggerClientEvent('dd_notify:client:showNotif', xTarget, {type = 'success', text = 'You have just received an invoice', lenght = 5000}) end) else MySQL.Async.execute('INSERT INTO billing (identifier, sender, target_type, target, label, amount) VALUES (@identifier, @sender, @target_type, @target, @label, @amount)', { ['@identifier'] = xTarget.identifier, ['@sender'] = xPlayer.identifier, ['@target_type'] = 'player', ['@target'] = xPlayer.identifier, ['@label'] = label, ['@amount'] = amount }, function(rowsChanged) TriggerClientEvent('dd_notify:client:showNotif', xTarget, {type = 'success', text = 'You have just received an invoice', lenght = 5000}) end) end end) end end) ESX.RegisterServerCallback('billing:getBills', function(source, cb) local xPlayer = ESX.GetPlayerFromId(source) MySQL.Async.fetchAll('SELECT amount, id, label FROM billing WHERE identifier = @identifier', { ['@identifier'] = xPlayer.identifier }, function(result) cb(result) end) end) ESX.RegisterServerCallback('billing:getTargetBills', function(source, cb, target) local xPlayer = ESX.GetPlayerFromId(target) if xPlayer then MySQL.Async.fetchAll('SELECT amount, id, label FROM billing WHERE identifier = @identifier', { ['@identifier'] = xPlayer.identifier }, function(result) cb(result) end) else cb({}) end end) ESX.RegisterServerCallback('billing:payBill', function(source, cb, billId) local xPlayer = ESX.GetPlayerFromId(source) MySQL.Async.fetchAll('SELECT sender, target_type, target, amount FROM billing WHERE id = @id', { ['@id'] = billId }, function(result) if result[1] then local amount = result[1].amount local xTarget = ESX.GetPlayerFromIdentifier(result[1].sender) if result[1].target_type == 'player' then if xTarget then if xPlayer.getMoney() >= amount then MySQL.Async.execute('DELETE FROM billing WHERE id = @id', { ['@id'] = billId }, function(rowsChanged) if rowsChanged == 1 then xPlayer.removeMoney(amount) xTarget.addMoney(amount) TriggerClientEvent('dd_notify:client:showNotif', xPlayer, {type = 'success', text = "You paid an invoice of "..ESX.Math.GroupDigits(amount), lenght = 5000}) TriggerClientEvent('dd_notify:client:showNotif', xTarget, {type = 'success', text = "You received a payment of "..ESX.Math.GroupDigits(amount), lenght = 5000}) end cb() end) elseif xPlayer.getAccount('bank').money >= amount then MySQL.Async.execute('DELETE FROM billing WHERE id = @id', { ['@id'] = billId }, function(rowsChanged) if rowsChanged == 1 then xPlayer.removeAccountMoney('bank', amount) xTarget.addAccountMoney('bank', amount) TriggerClientEvent('dd_notify:client:showNotif', xPlayer, {type = 'success', text = "You paid an invoice of "..ESX.Math.GroupDigits(amount), lenght = 5000}) TriggerClientEvent('dd_notify:client:showNotif', xTarget, {type = 'success', text = "You received a payment of "..ESX.Math.GroupDigits(amount), lenght = 5000}) end cb() end) else TriggerClientEvent('dd_notify:client:showNotif', xPlayer, {type = 'success', text = "You do not have enough money to pay this bill", lenght = 5000}) TriggerClientEvent('dd_notify:client:showNotif', xTarget, {type = 'success', text = "The player does not have enough money to pay the bill!", lenght = 5000}) cb() end else TriggerClientEvent('dd_notify:client:showNotif', xPlayer, {type = 'success', text = 'The player is not logged in', lenght = 5000}) cb() end else TriggerEvent('esx_addonaccount:getSharedAccount', result[1].target, function(account) if xPlayer.getMoney() >= amount then MySQL.Async.execute('DELETE FROM billing WHERE id = @id', { ['@id'] = billId }, function(rowsChanged) if rowsChanged == 1 then xPlayer.removeMoney(amount) account.addMoney(amount) TriggerClientEvent('dd_notify:client:showNotif', xPlayer, {type = 'success', text = "You paid an invoice of "..ESX.Math.GroupDigits(amount), lenght = 5000}) if xTarget then TriggerClientEvent('dd_notify:client:showNotif', xTarget, {type = 'success', text = "You received a payment of "..ESX.Math.GroupDigits(amount), lenght = 5000}) end end cb() end) elseif xPlayer.getAccount('bank').money >= amount then MySQL.Async.execute('DELETE FROM billing WHERE id = @id', { ['@id'] = billId }, function(rowsChanged) if rowsChanged == 1 then xPlayer.removeAccountMoney('bank', amount) account.addMoney(amount) TriggerClientEvent('dd_notify:client:showNotif', xPlayer, {type = 'success', text = "You paid an invoice of "..ESX.Math.GroupDigits(amount), lenght = 5000}) if xTarget then TriggerClientEvent('dd_notify:client:showNotif', xTarget, {type = 'success', text = "You received a payment of "..ESX.Math.GroupDigits(amount), lenght = 5000}) end end cb() end) else if xTarget then TriggerClientEvent('dd_notify:client:showNotif', xTarget, {type = 'success', text = "The player does not have enough money to pay the bill!", lenght = 5000}) end TriggerClientEvent('dd_notify:client:showNotif', xPlayer, {type = 'success', text = "You do not have enough money to pay this bill", lenght = 5000}) cb() end end) end end end) end) ------------------------[[SOCIETY]]-------------------------------- local Jobs = {} local RegisteredSocieties = {} function GetSociety(name) for i=1, #RegisteredSocieties, 1 do if RegisteredSocieties[i].name == name then return RegisteredSocieties[i] end end end MySQL.ready(function() local result = MySQL.Sync.fetchAll('SELECT * FROM jobs', {}) for i=1, #result, 1 do Jobs[result[i].name] = result[i] Jobs[result[i].name].grades = {} end local result2 = MySQL.Sync.fetchAll('SELECT * FROM job_grades', {}) for i=1, #result2, 1 do Jobs[result2[i].job_name].grades[tostring(result2[i].grade)] = result2[i] end end) AddEventHandler('esx_society:registerSociety', function(name, label, account, datastore, inventory, data) local found = false local society = { name = name, label = label, account = account, datastore = datastore, inventory = inventory, data = data } for i=1, #RegisteredSocieties, 1 do if RegisteredSocieties[i].name == name then found, RegisteredSocieties[i] = true, society break end end if not found then table.insert(RegisteredSocieties, society) end end) AddEventHandler('esx_society:getSocieties', function(cb) cb(RegisteredSocieties) end) AddEventHandler('esx_society:getSociety', function(name, cb) cb(GetSociety(name)) end) RegisterServerEvent('esx_society:withdrawMoney') AddEventHandler('esx_society:withdrawMoney', function(societyName, amount) local xPlayer = ESX.GetPlayerFromId(source) local society = GetSociety(societyName) amount = ESX.Math.Round(tonumber(amount)) if xPlayer.job.name == society.name then TriggerEvent('esx_addonaccount:getSharedAccount', society.account, function(account) if amount > 0 and account.money >= amount then account.removeMoney(amount) xPlayer.addMoney(amount) TriggerClientEvent('dd_notify:client:showNotif', xPlayer, {type = 'success', text = "You have withdrawn "..ESX.Math.GroupDigits(amount), lenght = 5000}) else TriggerClientEvent('dd_notify:client:showNotif', xPlayer, {type = 'success', text = "Invalid amount", lenght = 5000}) end end) else print(('esx_society: %s attempted to call withdrawMoney!'):format(xPlayer.identifier)) end end) RegisterServerEvent('esx_society:depositMoney') AddEventHandler('esx_society:depositMoney', function(societyName, amount) local xPlayer = ESX.GetPlayerFromId(source) local society = GetSociety(societyName) amount = ESX.Math.Round(tonumber(amount)) if xPlayer.job.name == society.name then if amount > 0 and xPlayer.getMoney() >= amount then TriggerEvent('esx_addonaccount:getSharedAccount', society.account, function(account) xPlayer.removeMoney(amount) TriggerClientEvent('dd_notify:client:showNotif', xPlayer, {type = 'success', text = "You have deposited "..ESX.Math.GroupDigits(amount), lenght = 5000}) account.addMoney(amount) end) else TriggerClientEvent('dd_notify:client:showNotif', xPlayer, {type = 'success', text = "Invalid amount", lenght = 5000}) end else print(('esx_society: %s attempted to call depositMoney!'):format(xPlayer.identifier)) end end) RegisterServerEvent('esx_society:putVehicleInGarage') AddEventHandler('esx_society:putVehicleInGarage', function(societyName, vehicle) local society = GetSociety(societyName) TriggerEvent('esx_datastore:getSharedDataStore', society.datastore, function(store) local garage = store.get('garage') or {} table.insert(garage, vehicle) store.set('garage', garage) end) end) RegisterServerEvent('esx_society:removeVehicleFromGarage') AddEventHandler('esx_society:removeVehicleFromGarage', function(societyName, vehicle) local society = GetSociety(societyName) TriggerEvent('esx_datastore:getSharedDataStore', society.datastore, function(store) local garage = store.get('garage') or {} for i=1, #garage, 1 do if garage[i].plate == vehicle.plate then table.remove(garage, i) break end end store.set('garage', garage) end) end) ESX.RegisterServerCallback('esx_society:getSocietyMoney', function(source, cb, societyName) local society = GetSociety(societyName) if society then TriggerEvent('esx_addonaccount:getSharedAccount', society.account, function(account) cb(account.money) end) else cb(0) end end) ESX.RegisterServerCallback('esx_society:getEmployees', function(source, cb, society) if DD.EnableESXIdentity then MySQL.Async.fetchAll('SELECT firstname, lastname, identifier, job, job_grade FROM users WHERE job = @job ORDER BY job_grade DESC', { ['@job'] = society }, function (results) local employees = {} for i=1, #results, 1 do table.insert(employees, { name = results[i].firstname .. ' ' .. results[i].lastname, identifier = results[i].identifier, job = { name = results[i].job, label = Jobs[results[i].job].label, grade = results[i].job_grade, grade_name = Jobs[results[i].job].grades[tostring(results[i].job_grade)].name, grade_label = Jobs[results[i].job].grades[tostring(results[i].job_grade)].label } }) end cb(employees) end) else MySQL.Async.fetchAll('SELECT identifier, job, job_grade FROM users WHERE job = @job ORDER BY job_grade DESC', { ['@job'] = society }, function (result) local employees = {} for i=1, #result, 1 do table.insert(employees, { name = GetPlayerName(source), identifier = result[i].identifier, job = { name = result[i].job, label = Jobs[result[i].job].label, grade = result[i].job_grade, grade_name = Jobs[result[i].job].grades[tostring(result[i].job_grade)].name, grade_label = Jobs[result[i].job].grades[tostring(result[i].job_grade)].label } }) end cb(employees) end) end end) ESX.RegisterServerCallback('esx_society:getJob', function(source, cb, society) local job = json.decode(json.encode(Jobs[society])) local grades = {} for k,v in pairs(job.grades) do table.insert(grades, v) end table.sort(grades, function(a, b) return a.grade < b.grade end) job.grades = grades cb(job) end) ESX.RegisterServerCallback('esx_society:setJob', function(source, cb, identifier, job, grade, type) local xPlayer = ESX.GetPlayerFromId(source) local isBoss = xPlayer.job.grade_name == 'boss' if isBoss then local xTarget = ESX.GetPlayerFromIdentifier(identifier) if xTarget then xTarget.setJob(job, grade) if type == 'hire' then TriggerClientEvent('dd_notify:client:showNotif', xTarget, {type = 'success', text = "You have been hired by "..job, lenght = 5000}) elseif type == 'promote' then TriggerClientEvent('dd_notify:client:showNotif', xTarget, {type = 'success', text = "You have been promoted!", lenght = 5000}) elseif type == 'fire' then TriggerClientEvent('dd_notify:client:showNotif', xTarget, {type = 'success', text = "You have been fired from "..xTarget.getJob().label, lenght = 5000}) end cb() else MySQL.Async.execute('UPDATE users SET job = @job, job_grade = @job_grade WHERE identifier = @identifier', { ['@job'] = job, ['@job_grade'] = grade, ['@identifier'] = identifier }, function(rowsChanged) cb() end) end else print(('esx_society: %s attempted to setJob'):format(xPlayer.identifier)) cb() end end) ESX.RegisterServerCallback('esx_society:setJobSalary', function(source, cb, job, grade, salary) local xPlayer = ESX.GetPlayerFromId(source) if xPlayer.job.name == job and xPlayer.job.grade_name == 'boss' then if salary <= DD.MaxSalary then MySQL.Async.execute('UPDATE job_grades SET salary = @salary WHERE job_name = @job_name AND grade = @grade', { ['@salary'] = salary, ['@job_name'] = job, ['@grade'] = grade }, function(rowsChanged) Jobs[job].grades[tostring(grade)].salary = salary local xPlayers = ESX.GetPlayers() for i=1, #xPlayers, 1 do local xTarget = ESX.GetPlayerFromId(xPlayers[i]) if xTarget.job.name == job and xTarget.job.grade == grade then xTarget.setJob(job, grade) end end cb() end) else print(('esx_society: %s attempted to setJobSalary over config limit!'):format(xPlayer.identifier)) cb() end else print(('esx_society: %s attempted to setJobSalary'):format(xPlayer.identifier)) cb() end end) ESX.RegisterServerCallback('esx_society:getOnlinePlayers', function(source, cb) local xPlayers = ESX.GetPlayers() local players = {} for i=1, #xPlayers, 1 do local xPlayer = ESX.GetPlayerFromId(xPlayers[i]) table.insert(players, { source = xPlayer.source, identifier = xPlayer.identifier, name = xPlayer.name, job = xPlayer.job }) end cb(players) end) ESX.RegisterServerCallback('esx_society:getVehiclesInGarage', function(source, cb, societyName) local society = GetSociety(societyName) TriggerEvent('esx_datastore:getSharedDataStore', society.datastore, function(store) local garage = store.get('garage') or {} cb(garage) end) end) ESX.RegisterServerCallback('esx_society:isBoss', function(source, cb, job) cb(isPlayerBoss(source, job)) end) function isPlayerBoss(playerId, job) local xPlayer = ESX.GetPlayerFromId(playerId) if xPlayer.job.name == job and xPlayer.job.grade_name == 'boss' then return true else print(('esx_society: %s attempted open a society boss menu!'):format(xPlayer.identifier)) return false end end ------------------------------------------------------------------------------- function getAccounts(data, xPlayer) local result = {} for i=1, #data do if(data[i] ~= 'money') then if(data[i] == 'black_money') and not DD.showBlackMoney then result[i] = nil else result[i] = xPlayer.getAccount(data[i])['money'] end else result[i] = xPlayer.getMoney() end end return result end function tableIncludes(table, data) for _,v in pairs(table) do if v == data then return true end end return false end local allowedGrades = { 'boss' } RegisterServerEvent('digz_jobhud:retrieveData') AddEventHandler('digz_jobhud:retrieveData', function() local xPlayer = ESX.GetPlayerFromId(source) if xPlayer ~= nil then local money,bank,black_money = table.unpack(getAccounts({'money', 'bank', 'black_money'}, xPlayer)) local society = nil if tableIncludes(allowedGrades, xPlayer.job.grade_name) then TriggerEvent('esx_society:getSociety', xPlayer.job.name, function(data) if data ~= nil then TriggerEvent('esx_addonaccount:getSharedAccount', data.account, function(account) society = account['money'] end) end end) end TriggerClientEvent('digz_jobhud:retrieveData', source, {cash = money, bank = bank, black_money = black_money, society = society}) end end)