Skip to content

Commit

Permalink
feat(es_extended/client/modules/actions): track current ped weapon
Browse files Browse the repository at this point in the history
  • Loading branch information
Kenshiin13 committed Dec 6, 2024
1 parent 65e8c94 commit 092b843
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions [core]/es_extended/client/modules/actions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 092b843

Please sign in to comment.