From 092b843674177f7712d58bfa90a683a82b9e8c53 Mon Sep 17 00:00:00 2001 From: Kenshin13 <63159154+Kenshiin13@users.noreply.github.com> Date: Sat, 7 Dec 2024 00:22:02 +0100 Subject: [PATCH] feat(es_extended/client/modules/actions): track current ped weapon --- [core]/es_extended/client/modules/actions.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/[core]/es_extended/client/modules/actions.lua b/[core]/es_extended/client/modules/actions.lua index 23189d98b..16c75c80e 100644 --- a/[core]/es_extended/client/modules/actions.lua +++ b/[core]/es_extended/client/modules/actions.lua @@ -4,6 +4,7 @@ Actions._index = Actions Actions.inVehicle = false Actions.enteringVehicle = false Actions.inPauseMenu = false +Actions.currentWeapon = false function Actions:GetSeatPedIsIn() for i = -1, 16 do @@ -132,12 +133,24 @@ function Actions:TrackVehicle() end end +function Actions:TrackWeapon() + ---@type number|false + local newWeapon = GetSelectedPedWeapon(ESX.PlayerData.ped) + newWeapon = newWeapon ~= `WEAPON_UNARMED` and newWeapon or false + + if newWeapon ~= self.currentWeapon then + self.currentWeapon = newWeapon + TriggerEvent("esx:weaponChanged", self.currentWeapon) + end +end + function Actions:SlowLoop() CreateThread(function() while ESX.PlayerLoaded do self:TrackPedCoords() self:TrackPauseMenu() self:TrackVehicle() + self:TrackWeapon() Wait(500) end end)