Skip to content

Commit

Permalink
restore original value
Browse files Browse the repository at this point in the history
restore original value  after create status from on trigger event 'esx_status:registerStatus'
  • Loading branch information
CodeCool-Developer committed Apr 14, 2024
1 parent cccf710 commit e0e1b15
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions client/main.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
local Status, isPaused = {}, false
local OriginalStatus, Status, isPaused = {}, {}, false

function GetStatusData(minimal)
local status = {}
Expand Down Expand Up @@ -26,6 +26,13 @@ end

AddEventHandler('esx_status:registerStatus', function(name, default, color, visible, tickCallback)
local status = CreateStatus(name, default, color, visible, tickCallback)

for i=1, #OriginalStatus, 1 do
if status.name == OriginalStatus[i].name then
status.set(OriginalStatus[i].val)
end
end

table.insert(Status, status)
end)

Expand All @@ -52,15 +59,9 @@ end)

RegisterNetEvent('esx_status:load')
AddEventHandler('esx_status:load', function(status)
OriginalStatus = status
ESX.PlayerLoaded = true
TriggerEvent('esx_status:loaded')
for i=1, #Status, 1 do
for j=1, #status, 1 do
if Status[i].name == status[j].name then
Status[i].set(status[j].val)
end
end
end

if Config.Display then TriggerEvent('esx_status:setDisplay', 0.5) end

Expand Down

0 comments on commit e0e1b15

Please sign in to comment.