From 33cafef736634d94669595f795b8b91e028cc53a Mon Sep 17 00:00:00 2001 From: Mycroft Date: Mon, 5 Apr 2021 21:36:39 +0100 Subject: [PATCH 1/3] Fixes --- client/main.lua | 72 ++++++++++++++++++------------------------------- server/main.lua | 6 ++++- 2 files changed, 31 insertions(+), 47 deletions(-) diff --git a/client/main.lua b/client/main.lua index 93c548cf..eb78237f 100644 --- a/client/main.lua +++ b/client/main.lua @@ -10,29 +10,7 @@ Citizen.CreateThread(function() Citizen.Wait(0) end - Citizen.Wait(10000) - - ESX.TriggerServerCallback('esx_vehicleshop:getCategories', function(categories) - Categories = categories - end) - - ESX.TriggerServerCallback('esx_vehicleshop:getVehicles', function(vehicles) - Vehicles = vehicles - end) - - if Config.EnablePlayerManagement then - if ESX.PlayerData.job.name == 'cardealer' then - Config.Zones.ShopEntering.Type = 1 - - if ESX.PlayerData.job.grade_name == 'boss' then - Config.Zones.BossActions.Type = 1 - end - - else - Config.Zones.ShopEntering.Type = -1 - Config.Zones.BossActions.Type = -1 - end - end + PlayerManagement() end) function getVehicleLabelFromModel(model) @@ -45,10 +23,17 @@ function getVehicleLabelFromModel(model) return end -RegisterNetEvent('esx:playerLoaded') -AddEventHandler('esx:playerLoaded', function(xPlayer) - ESX.PlayerData = xPlayer +function getVehicles() + ESX.TriggerServerCallback('esx_vehicleshop:getCategories', function(categories) + Categories = categories + end) + ESX.TriggerServerCallback('esx_vehicleshop:getVehicles', function(vehicles) + Vehicles = vehicles + end) +end + +function PlayerManagement() if Config.EnablePlayerManagement then if ESX.PlayerData.job.name == 'cardealer' then Config.Zones.ShopEntering.Type = 1 @@ -62,6 +47,14 @@ AddEventHandler('esx:playerLoaded', function(xPlayer) Config.Zones.BossActions.Type = -1 end end +end + +RegisterNetEvent('esx:playerLoaded') +AddEventHandler('esx:playerLoaded', function(xPlayer) + ESX.PlayerData = xPlayer + + PlayerManagement() + getVehicles() end) RegisterNetEvent('esx_vehicleshop:sendCategories') @@ -74,6 +67,11 @@ AddEventHandler('esx_vehicleshop:sendVehicles', function(vehicles) Vehicles = vehicles end) +RegisterNetEvent('esx:setJob') +AddEventHandler('esx:setJob', function(job) + PlayerManagement() +end) + function DeleteDisplayVehicleInsideShop() local attempt = 0 @@ -647,24 +645,6 @@ function OpenPutStocksMenu() end) end -RegisterNetEvent('esx:setJob') -AddEventHandler('esx:setJob', function(job) - ESX.PlayerData.job = job - - if Config.EnablePlayerManagement then - if ESX.PlayerData.job.name == 'cardealer' then - Config.Zones.ShopEntering.Type = 1 - - if ESX.PlayerData.job.grade_name == 'boss' then - Config.Zones.BossActions.Type = 1 - end - else - Config.Zones.ShopEntering.Type = -1 - Config.Zones.BossActions.Type = -1 - end - end -end) - AddEventHandler('esx_vehicleshop:hasEnteredMarker', function(zone) if zone == 'ShopEntering' then @@ -787,7 +767,7 @@ end) -- Enter / Exit marker events & Draw Markers Citizen.CreateThread(function() while true do - Citizen.Wait(0) + Citizen.Wait(4) local playerCoords = GetEntityCoords(PlayerPedId()) local isInMarker, letSleep, currentZone = false, true @@ -827,7 +807,7 @@ end) -- Key controls Citizen.CreateThread(function() while true do - Citizen.Wait(0) + Citizen.Wait(5) if CurrentAction then ESX.ShowHelpNotification(CurrentActionMsg) diff --git a/server/main.lua b/server/main.lua index 8eadb127..504d9083 100644 --- a/server/main.lua +++ b/server/main.lua @@ -23,7 +23,11 @@ function RemoveOwnedVehicle(plate) end AddEventHandler('onResourceStart', function(resourceName) - Wait(1000) + Wait(420) + SQLVehiclesAndCategories() +end) + +MySQL.ready(function() SQLVehiclesAndCategories() end) From ec343d99d0dd2fc559dfe3bf33c087e85f917fbe Mon Sep 17 00:00:00 2001 From: Mycroft Date: Mon, 5 Apr 2021 23:00:09 +0100 Subject: [PATCH 2/3] Update main.lua --- server/main.lua | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/server/main.lua b/server/main.lua index 504d9083..8fb1f12a 100644 --- a/server/main.lua +++ b/server/main.lua @@ -23,12 +23,9 @@ function RemoveOwnedVehicle(plate) end AddEventHandler('onResourceStart', function(resourceName) - Wait(420) - SQLVehiclesAndCategories() -end) - -MySQL.ready(function() - SQLVehiclesAndCategories() + if resourceName == GetCurrentResourceName() then + MySQL.ready(function() SQLVehiclesAndCategories() end) + end end) function SQLVehiclesAndCategories() From fc3559073ccc58b18f7c3bb2f5acd058f084abeb Mon Sep 17 00:00:00 2001 From: Mycroft Date: Tue, 6 Apr 2021 01:02:44 +0100 Subject: [PATCH 3/3] Update main.lua --- client/main.lua | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/client/main.lua b/client/main.lua index eb78237f..90aea3f6 100644 --- a/client/main.lua +++ b/client/main.lua @@ -67,10 +67,8 @@ AddEventHandler('esx_vehicleshop:sendVehicles', function(vehicles) Vehicles = vehicles end) -RegisterNetEvent('esx:setJob') -AddEventHandler('esx:setJob', function(job) - PlayerManagement() -end) + +RegisterNetEvent('esx:setJob') AddEventHandler('esx:setJob', PlayerManagement) function DeleteDisplayVehicleInsideShop() local attempt = 0