From ae969f9e9c4292ffec5ed2b3fa8dbca4021a08a5 Mon Sep 17 00:00:00 2001 From: Thekuca <63980591+Thekuca@users.noreply.github.com> Date: Mon, 29 Jan 2024 23:57:51 +0100 Subject: [PATCH] refactor(es_extended/client/functions): cache addon resource states Cache addon resource states instead of checking it every time a function is called --- [core]/es_extended/client/functions.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/[core]/es_extended/client/functions.lua b/[core]/es_extended/client/functions.lua index 9be8155c..ec5d9b31 100644 --- a/[core]/es_extended/client/functions.lua +++ b/[core]/es_extended/client/functions.lua @@ -24,8 +24,15 @@ function ESX.GetPlayerData() return ESX.PlayerData end +local addonResourcesState = { + ['esx_progressbar'] = GetResourceState('esx_progressbar') ~= 'missing', + ['esx_notify'] = GetResourceState('esx_notify') ~= 'missing', + ['esx_textui'] = GetResourceState('esx_textui') ~= 'missing', + ['esx_context'] = GetResourceState('esx_context') ~= 'missing' +} + local function IsResourceFound(resource) - return GetResourceState(resource) ~= 'missing' or print(('[^1ERROR^7] ^5%s^7 is Missing!'):format(resource)) + return addonResourcesState[resource] or print(('[^1ERROR^7] ^5%s^7 is Missing!'):format(resource)) end function ESX.SearchInventory(items, count)