From 050144b201aa024cd2f7b63eae35ac975fb90fc2 Mon Sep 17 00:00:00 2001 From: Mycroft Date: Sun, 6 Mar 2022 12:30:19 +0000 Subject: [PATCH] Tweak (ESX Weaponshops): Optimisations --- [esx_addons]/esx_weaponshop/client/main.lua | 15 +++++++++++---- [esx_addons]/esx_weaponshop/config.lua | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/[esx_addons]/esx_weaponshop/client/main.lua b/[esx_addons]/esx_weaponshop/client/main.lua index f8553d9f..d494ba0f 100644 --- a/[esx_addons]/esx_weaponshop/client/main.lua +++ b/[esx_addons]/esx_weaponshop/client/main.lua @@ -155,30 +155,34 @@ end) -- Display markers CreateThread(function() while true do - Wait(0) + local Sleep = 1500 local coords = GetEntityCoords(PlayerPedId()) for k,v in pairs(Config.Zones) do for i = 1, #v.Locations, 1 do if (Config.Type ~= -1 and #(coords - v.Locations[i]) < Config.DrawDistance) then + Sleep = 0 DrawMarker(Config.Type, v.Locations[i], 0.0, 0.0, 0.0, 0, 0.0, 0.0, Config.Size.x, Config.Size.y, Config.Size.z, Config.Color.r, Config.Color.g, Config.Color.b, 100, false, true, 2, false, false, false, false) end end end + Wait(Sleep) end end) -- Enter / Exit marker events CreateThread(function() while true do - Wait(0) + local Sleep = 1000 + local coords = GetEntityCoords(PlayerPedId()) local isInMarker, currentZone = false, nil for k,v in pairs(Config.Zones) do for i=1, #v.Locations, 1 do if #(coords - v.Locations[i]) < Config.Size.x then + Sleep = 0 isInMarker, ShopItems, currentZone, LastZone = true, v.Items, k, k end end @@ -192,15 +196,17 @@ CreateThread(function() HasAlreadyEnteredMarker = false TriggerEvent('esx_weaponshop:hasExitedMarker', LastZone) end + Wait(Sleep) end end) -- Key Controls CreateThread(function() while true do - Wait(0) - + local Sleep = 1500 + if CurrentAction ~= nil then + Sleep = 0 ESX.ShowHelpNotification(CurrentActionMsg) if IsControlJustReleased(0, 38) then @@ -222,5 +228,6 @@ CreateThread(function() CurrentAction = nil end end + Wait(Sleep) end end) diff --git a/[esx_addons]/esx_weaponshop/config.lua b/[esx_addons]/esx_weaponshop/config.lua index 2adc1412..63a3b425 100644 --- a/[esx_addons]/esx_weaponshop/config.lua +++ b/[esx_addons]/esx_weaponshop/config.lua @@ -1,6 +1,6 @@ Config = {} -Config.DrawDistance = 100 +Config.DrawDistance = 10 Config.Size = { x = 1.5, y = 1.5, z = 0.5 } Config.Color = { r = 0, g = 128, b = 255 } Config.Type = 1