From 3892aa9b8f7aab1faa731e6b2ece0dac85eafb07 Mon Sep 17 00:00:00 2001 From: Mycroft Date: Wed, 4 Jan 2023 18:59:30 +0000 Subject: [PATCH] fix: society race conditions --- [esx_addons]/esx_ambulancejob/fxmanifest.lua | 1 + [esx_addons]/esx_ambulancejob/server/main.lua | 6 +++--- [esx_addons]/esx_bankerjob/fxmanifest.lua | 5 ++++- [esx_addons]/esx_mechanicjob/server/main.lua | 5 ++++- [esx_addons]/esx_policejob/fxmanifest.lua | 1 + [esx_addons]/esx_policejob/server/main.lua | 4 +++- [esx_addons]/esx_property/fxmanifest.lua | 3 ++- [esx_addons]/esx_property/server/main.lua | 2 +- [esx_addons]/esx_taxijob/fxmanifest.lua | 5 ++++- [esx_addons]/esx_taxijob/server/main.lua | 8 +++++--- [esx_addons]/esx_vehicleshop/server/main.lua | 4 +++- 11 files changed, 31 insertions(+), 13 deletions(-) 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_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_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/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