Skip to content

Commit

Permalink
Merge pull request #13 from CodeCool-Developer/patch-2
Browse files Browse the repository at this point in the history
Restore original status value
  • Loading branch information
Gellipapa authored May 19, 2024
2 parents 36d8e04 + e0e1b15 commit 2e8f3cf
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 2e8f3cf

Please sign in to comment.