From 2d83d70640a51151e064569f3271d33fd9be5db4 Mon Sep 17 00:00:00 2001 From: Kenshin13 <63159154+Kenshiin13@users.noreply.github.com> Date: Sun, 22 Dec 2024 23:23:56 +0100 Subject: [PATCH 1/2] refactor(client/main): remove redundant AddEventHandler --- client/main.lua | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/client/main.lua b/client/main.lua index 3799159..d855b47 100644 --- a/client/main.lua +++ b/client/main.lua @@ -45,8 +45,7 @@ AddEventHandler('esx_status:unregisterStatus', function(name) end end) -RegisterNetEvent('esx:onPlayerLogout') -AddEventHandler('esx:onPlayerLogout', function() +RegisterNetEvent('esx:onPlayerLogout', function() ESX.PlayerLoaded = false Status = {} if Config.Display then @@ -57,8 +56,7 @@ AddEventHandler('esx:onPlayerLogout', function() end end) -RegisterNetEvent('esx_status:load') -AddEventHandler('esx_status:load', function(status) +RegisterNetEvent('esx_status:load', function(status) OriginalStatus = status ESX.PlayerLoaded = true TriggerEvent('esx_status:loaded') @@ -96,8 +94,7 @@ AddEventHandler('esx_status:load', function(status) end) end) -RegisterNetEvent('esx_status:set') -AddEventHandler('esx_status:set', function(name, val) +RegisterNetEvent('esx_status:set', function(name, val) for i=1, #Status, 1 do if Status[i].name == name then Status[i].set(val) @@ -112,8 +109,7 @@ AddEventHandler('esx_status:set', function(name, val) end end) -RegisterNetEvent('esx_status:add') -AddEventHandler('esx_status:add', function(name, val) +RegisterNetEvent('esx_status:add', function(name, val) for i=1, #Status, 1 do if Status[i].name == name then Status[i].add(val) @@ -128,8 +124,7 @@ AddEventHandler('esx_status:add', function(name, val) end end) -RegisterNetEvent('esx_status:remove') -AddEventHandler('esx_status:remove', function(name, val) +RegisterNetEvent('esx_status:remove', function(name, val) for i=1, #Status, 1 do if Status[i].name == name then Status[i].remove(val) From 4bb446da947eb18b2c0a46e212f7db9ae74bfa29 Mon Sep 17 00:00:00 2001 From: Kenshin13 <63159154+Kenshiin13@users.noreply.github.com> Date: Sun, 22 Dec 2024 23:37:27 +0100 Subject: [PATCH 2/2] fix(client/main): remove manually setting ESX.PlayerLoaded The import does that for us already. --- client/main.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/main.lua b/client/main.lua index d855b47..a09c8ca 100644 --- a/client/main.lua +++ b/client/main.lua @@ -46,7 +46,6 @@ AddEventHandler('esx_status:unregisterStatus', function(name) end) RegisterNetEvent('esx:onPlayerLogout', function() - ESX.PlayerLoaded = false Status = {} if Config.Display then SendNUIMessage({ @@ -57,8 +56,9 @@ RegisterNetEvent('esx:onPlayerLogout', function() end) RegisterNetEvent('esx_status:load', function(status) + while not ESX.PlayerLoaded do Wait(0) end + OriginalStatus = status - ESX.PlayerLoaded = true TriggerEvent('esx_status:loaded') if Config.Display then TriggerEvent('esx_status:setDisplay', 0.5) end