diff --git a/[esx]/es_extended/client/common.lua b/[esx]/es_extended/client/common.lua index 26020ace..c088fb90 100644 --- a/[esx]/es_extended/client/common.lua +++ b/[esx]/es_extended/client/common.lua @@ -5,3 +5,8 @@ end) if GetResourceState('ox_inventory') ~= 'missing' then Config.OxInventory = true end + +AddEventHandler("esx:getSharedObject", function() + local Invoke = GetInvokingResource() + print(("[^1ERROR^7] Resource ^5%s^7 Used the ^5getSharedObject^7 Event, this event ^1no longer exists!^7 Visit https://documentation.esx-framework.org/tutorials/sharedevent for how to fix!"):format(Invoke)) +end) diff --git a/[esx]/es_extended/server/common.lua b/[esx]/es_extended/server/common.lua index c8d004b4..6aaf87c8 100644 --- a/[esx]/es_extended/server/common.lua +++ b/[esx]/es_extended/server/common.lua @@ -14,6 +14,10 @@ Core.Pickups = {} Core.PickupId = 0 Core.PlayerFunctionOverrides = {} +AddEventHandler("esx:getSharedObject", function() + local Invoke = GetInvokingResource() + print(("[^1ERROR^7] Resource ^5%s^7 Used the ^5getSharedObject^7 Event, this event ^1no longer exists!^7 Visit https://documentation.esx-framework.org/tutorials/sharedevent for how to fix!"):format(Invoke)) +end) exports('getSharedObject', function() return ESX diff --git a/[esx_addons]/esx_ambulancejob/fxmanifest.lua b/[esx_addons]/esx_ambulancejob/fxmanifest.lua index 4b2c33a1..9800bf24 100644 --- a/[esx_addons]/esx_ambulancejob/fxmanifest.lua +++ b/[esx_addons]/esx_ambulancejob/fxmanifest.lua @@ -29,5 +29,6 @@ client_scripts { dependencies { 'es_extended', 'esx_skin', + 'esx_society', 'esx_vehicleshop' } diff --git a/[esx_addons]/esx_ambulancejob/server/main.lua b/[esx_addons]/esx_ambulancejob/server/main.lua index 6b22684a..c5265ab2 100644 --- a/[esx_addons]/esx_ambulancejob/server/main.lua +++ b/[esx_addons]/esx_ambulancejob/server/main.lua @@ -4,9 +4,9 @@ if GetResourceState("esx_phone") ~= 'missing' then TriggerEvent('esx_phone:registerNumber', 'ambulance', TranslateCap('alert_ambulance'), true, true) end -if GetResourceState("esx_society") ~= 'missing' then -TriggerEvent('esx_society:registerSociety', 'ambulance', 'Ambulance', 'society_ambulance', 'society_ambulance', 'society_ambulance', {type = 'public'}) -end +CreateThread(function() + exports["esx_society"]:registerSociety('ambulance', 'Ambulance', 'society_ambulance', 'society_ambulance', 'society_ambulance', {type = 'public'}) +end) RegisterNetEvent('esx_ambulancejob:revive') AddEventHandler('esx_ambulancejob:revive', function(playerId) diff --git a/[esx_addons]/esx_bankerjob/fxmanifest.lua b/[esx_addons]/esx_bankerjob/fxmanifest.lua index 664018c5..47eb4d5f 100644 --- a/[esx_addons]/esx_bankerjob/fxmanifest.lua +++ b/[esx_addons]/esx_bankerjob/fxmanifest.lua @@ -24,4 +24,7 @@ client_scripts { 'client/main.lua' } -dependency 'es_extended' +dependencies { + 'es_extended', + 'esx_society' +} diff --git a/[esx_addons]/esx_bankerjob/server/main.lua b/[esx_addons]/esx_bankerjob/server/main.lua index 30bb523a..33dd831c 100644 --- a/[esx_addons]/esx_bankerjob/server/main.lua +++ b/[esx_addons]/esx_bankerjob/server/main.lua @@ -1,5 +1,7 @@ TriggerEvent('esx_phone:registerNumber', 'banker', _('phone_receive'), false, false) -TriggerEvent('esx_society:registerSociety', 'banker', TranslateCap('phone_label'), 'society_banker', 'society_banker', 'society_banker', {type = 'public'}) +CreateThread(function() + exports["esx_society"]:registerSociety('banker', TranslateCap('phone_label'), 'society_banker', 'society_banker', 'society_banker', {type = 'public'}) +end) RegisterServerEvent('esx_bankerjob:customerDeposit') AddEventHandler('esx_bankerjob:customerDeposit', function (target, amount) diff --git a/[esx_addons]/esx_mechanicjob/server/main.lua b/[esx_addons]/esx_mechanicjob/server/main.lua index 4f8db966..0727d680 100644 --- a/[esx_addons]/esx_mechanicjob/server/main.lua +++ b/[esx_addons]/esx_mechanicjob/server/main.lua @@ -5,7 +5,10 @@ if Config.MaxInService ~= -1 then end TriggerEvent('esx_phone:registerNumber', 'mechanic', TranslateCap('mechanic_customer'), true, true) -TriggerEvent('esx_society:registerSociety', 'mechanic', 'mechanic', 'society_mechanic', 'society_mechanic', 'society_mechanic', {type = 'private'}) + +CreateThread(function() + exports["esx_society"]:registerSociety('mechanic', 'mechanic', 'society_mechanic', 'society_mechanic', 'society_mechanic', {type = 'private'}) +end) local function Harvest(source) SetTimeout(4000, function() diff --git a/[esx_addons]/esx_policejob/fxmanifest.lua b/[esx_addons]/esx_policejob/fxmanifest.lua index 9a3355d2..d8070a66 100644 --- a/[esx_addons]/esx_policejob/fxmanifest.lua +++ b/[esx_addons]/esx_policejob/fxmanifest.lua @@ -27,5 +27,6 @@ client_scripts { dependencies { 'es_extended', 'esx_billing', + 'esx_society', 'esx_vehicleshop' } diff --git a/[esx_addons]/esx_policejob/server/main.lua b/[esx_addons]/esx_policejob/server/main.lua index 1bffdee9..5aa7712f 100644 --- a/[esx_addons]/esx_policejob/server/main.lua +++ b/[esx_addons]/esx_policejob/server/main.lua @@ -5,7 +5,9 @@ if Config.EnableESXService then end TriggerEvent('esx_phone:registerNumber', 'police', TranslateCap('alert_police'), true, true) -TriggerEvent('esx_society:registerSociety', 'police', 'Police', 'society_police', 'society_police', 'society_police', {type = 'public'}) +CreateThread(function() + exports["esx_society"]:registerSociety('police', 'Police', 'society_police', 'society_police', 'society_police', {type = 'public'}) +end) RegisterNetEvent('esx_policejob:confiscatePlayerItem') AddEventHandler('esx_policejob:confiscatePlayerItem', function(target, itemType, itemName, amount) diff --git a/[esx_addons]/esx_property/fxmanifest.lua b/[esx_addons]/esx_property/fxmanifest.lua index e14af88a..36c5035c 100644 --- a/[esx_addons]/esx_property/fxmanifest.lua +++ b/[esx_addons]/esx_property/fxmanifest.lua @@ -42,5 +42,6 @@ client_scripts { } dependencies { - 'es_extended' + 'es_extended', + 'esx_society' } diff --git a/[esx_addons]/esx_property/server/main.lua b/[esx_addons]/esx_property/server/main.lua index fc55b196..e1e0b3ea 100644 --- a/[esx_addons]/esx_property/server/main.lua +++ b/[esx_addons]/esx_property/server/main.lua @@ -147,7 +147,7 @@ CreateThread(function() Wait(10) ESX.RefreshJobs() - TriggerEvent('esx_society:registerSociety', 'realestateagent', 'realestateagent', 'society_realestateagent', 'society_realestateagent', 'society_realestateagent', {type = 'private'}) + exports["esx_society"]:registerSociety('realestateagent', 'realestateagent', 'society_realestateagent', 'society_realestateagent', 'society_realestateagent', {type = 'private'}) end end) diff --git a/[esx_addons]/esx_society/README.md b/[esx_addons]/esx_society/README.md index 444a73eb..6ca83c1a 100644 --- a/[esx_addons]/esx_society/README.md +++ b/[esx_addons]/esx_society/README.md @@ -1,36 +1,7 @@ -# esx_society +
Discord - Website - Documentation Society management for ESX. Adds employee management (hire, fire, promote / demote, change salary), society bank accounts and money washing. It's crucial that this script gets started before all resources that utilize societies do, or else many things will go wrong. -## Requirements -- [cron](https://github.com/esx-framework/esx-legacy/tree/main/%5Besx%5D/cron) -- [esx_addonaccount](https://github.com/esx-framework/esx-legacy/tree/main/%5Besx_addons%5D/esx_addonaccount) - -## Download & Installation - -### Using [fvm](https://github.com/qlaffont/fvm-installer) -``` -fvm install --save --folder=esx esx-org/esx_society -``` - -### Using Git -``` -cd resources -git clone https://github.com/ESX-Org/esx_society [esx]/esx_society -``` - -### Manually -- Download https://github.com/ESX-Org/esx_society/archive/master.zip -- Put it in the `[esx]` directory - -## Installation -- Import `esx_society.sql` in your database -- Add this in your `server.cfg`: - -``` -start esx_society -``` - ## Explanation ESX Society works with addon accounts named 'society_xxx', for example 'society_taxi' or 'society_realestateagent'. If you job grade is 'boss' the society money will be displayed in your hud. diff --git a/[esx_addons]/esx_society/server/main.lua b/[esx_addons]/esx_society/server/main.lua index be5e0d3d..0630695a 100644 --- a/[esx_addons]/esx_society/server/main.lua +++ b/[esx_addons]/esx_society/server/main.lua @@ -9,24 +9,24 @@ function GetSociety(name) end end -AddEventHandler('onResourceStart', function(resourceName) - if resourceName == GetCurrentResourceName() then - local result = MySQL.query.await('SELECT * FROM jobs') +exports("GetSociety", GetSociety) - for i = 1, #result, 1 do - Jobs[result[i].name] = result[i] - Jobs[result[i].name].grades = {} - end +CreateThread(function() + local result = MySQL.query.await('SELECT * FROM jobs') - local result2 = MySQL.query.await('SELECT * FROM job_grades') + for i = 1, #result, 1 do + Jobs[result[i].name] = result[i] + Jobs[result[i].name].grades = {} + end - for i = 1, #result2, 1 do - Jobs[result2[i].job_name].grades[tostring(result2[i].grade)] = result2[i] - end + local result2 = MySQL.query.await('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) +function registerSociety(name, label, account, datastore, inventory, data) local found = false local society = { @@ -46,9 +46,13 @@ AddEventHandler('esx_society:registerSociety', function(name, label, account, da end if not found then - table.insert(RegisteredSocieties, society) + RegisteredSocieties[#RegisteredSocieties + 1] = society + print(("[^2INFO^7] Registered Society ^5%s^7"):format(label)) end -end) +end + +AddEventHandler('esx_society:registerSociety',registerSociety) +exports("registerSociety", registerSociety) AddEventHandler('esx_society:getSocieties', function(cb) cb(RegisteredSocieties) diff --git a/[esx_addons]/esx_taxijob/fxmanifest.lua b/[esx_addons]/esx_taxijob/fxmanifest.lua index 36fa1f0d..bc2408b8 100644 --- a/[esx_addons]/esx_taxijob/fxmanifest.lua +++ b/[esx_addons]/esx_taxijob/fxmanifest.lua @@ -22,4 +22,7 @@ server_scripts { 'server/main.lua' } -dependency 'es_extended' +dependencies { + 'es_extended', + 'esx_society' +} diff --git a/[esx_addons]/esx_taxijob/server/main.lua b/[esx_addons]/esx_taxijob/server/main.lua index 9bfdc4f9..e84561ad 100644 --- a/[esx_addons]/esx_taxijob/server/main.lua +++ b/[esx_addons]/esx_taxijob/server/main.lua @@ -5,9 +5,11 @@ if Config.MaxInService ~= -1 then end TriggerEvent('esx_phone:registerNumber', 'taxi', TranslateCap('taxi_client'), true, true) -TriggerEvent('esx_society:registerSociety', 'taxi', 'Taxi', 'society_taxi', 'society_taxi', 'society_taxi', { - type = 'public' -}) +CreateThread(function() + exports["esx_society"]:registerSociety('taxi', 'Taxi', 'society_taxi', 'society_taxi', 'society_taxi', { + type = 'public' + }) +end) RegisterNetEvent('esx_taxijob:success') AddEventHandler('esx_taxijob:success', function() diff --git a/[esx_addons]/esx_vehicleshop/fxmanifest.lua b/[esx_addons]/esx_vehicleshop/fxmanifest.lua index dce7743a..f9f16497 100644 --- a/[esx_addons]/esx_vehicleshop/fxmanifest.lua +++ b/[esx_addons]/esx_vehicleshop/fxmanifest.lua @@ -26,6 +26,10 @@ client_scripts { 'client/main.lua' } -dependency 'es_extended' +dependencies { + 'es_extended', + 'esx_society' +} + export 'GeneratePlate' diff --git a/[esx_addons]/esx_vehicleshop/server/main.lua b/[esx_addons]/esx_vehicleshop/server/main.lua index d07bbffc..a86f65cc 100644 --- a/[esx_addons]/esx_vehicleshop/server/main.lua +++ b/[esx_addons]/esx_vehicleshop/server/main.lua @@ -1,7 +1,9 @@ local categories, vehicles = {}, {} TriggerEvent('esx_phone:registerNumber', 'cardealer', TranslateCap('dealer_customers'), false, false) -TriggerEvent('esx_society:registerSociety', 'cardealer', TranslateCap('car_dealer'), 'society_cardealer', 'society_cardealer', 'society_cardealer', {type = 'private'}) +CreateThread(function() + exports["esx_society"]:registerSociety('cardealer', TranslateCap('car_dealer'), 'society_cardealer', 'society_cardealer', 'society_cardealer', {type = 'private'}) +end) CreateThread(function() local char = Config.PlateLetters