Skip to content

Commit

Permalink
tweak(client): Auto Register Status
Browse files Browse the repository at this point in the history
avoid duplicate status being registered 👎  esx status 😦
  • Loading branch information
renzuzu committed Aug 20, 2021
1 parent c7de029 commit bf7a679
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 12 deletions.
37 changes: 26 additions & 11 deletions renzu_hud/client/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -295,19 +295,10 @@ CreateThread(function()
end
if config.enablestatus then
while not Hud.reorder do Wait(100) end
for k,v in ipairs(config.statusordering) do -- register all status
if config.registerautostatus and v.custom and not DecorGetBool(PlayerPedId(), "PLAYERLOADED") then
local remove_value = v.statusremove
print("Auto Status Register: ",v.status,v.startvalue,v.statusremove)
TriggerEvent('esx_status:registerStatus', v.status, tonumber(v.startvalue), '#CFAD0F', function(status)
return true
end, function(status)
status.remove(remove_value)
end)
end
end
if not config.QbcoreStatusDefault and config.framework == 'QBCORE' or config.framework == 'STANDALONE' or config.framework == 'ESX' then
--RegisterNetEvent("esx_status:onTick")
local register = {}
local registered = false
AddEventHandler("esx_status:onTick", function(vitals) -- use renzu_status
local vitals = vitals
if vitals[1] ~= nil then -- esx status (if index int is not nil, its a normal esx_status) else its renzu_status
Expand All @@ -321,12 +312,36 @@ CreateThread(function()
for k,v in ipairs(vitals) do
if config.statusordering[v.name] ~= nil then
vitals[v.name] = v.val -- populate the data from esx_status and convert to renzu_status format
vitals[k] = nil
else
vitals[k] = nil
end
end
else
Hud.esx_status = false
end
Hud:UpdateStatus(false,vitals)

for k,v in pairs(vitals) do
register[k] = true
end

if config.registerautostatus and not registered then
DecorRegister("STATUSR", 1)
for k,v in pairs(config.statusordering) do -- register all status
if v.custom and register[v.status] == nil and not DecorGetBool(PlayerPedId(), "STATUSR") then
local remove_value = v.statusremove
print("Auto Status Register: ",v.status,v.startvalue,v.statusremove)
TriggerEvent('esx_status:registerStatus', v.status, tonumber(v.startvalue), '#CFAD0F', function(status)
return true
end, function(status)
status.remove(remove_value)
end)
end
end
DecorSetBool(PlayerPedId(), "STATUSR", true)
registered = true
end
end)
end
if config.framework == 'QBCORE' then
Expand Down
2 changes: 1 addition & 1 deletion renzu_hud/conf/status.lua
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ config.statusordering = { -- SET enable = false to disable the status (the statu
[1] = {type = 1, enable = true, status = 'armor', hideifmax = true, custom = false, value = 0, notify_lessthan = false, notify_message = 'i am very hungry', notify_value = 20, display = 'none', offset = '275', i_id_1_color = 'rgb(1, 103, 255)', fa = 'far fa-shield-alt', i_id_2_color = 'rgb(0, 41, 129)'},
[2] = {type = 1, enable = true, status = 'hunger', hideifmax = false, custom = true, value = 0, startvalue = 1000000, statusremove = 100, notify_lessthan = false, notify_message = 'i am very hungry', notify_value = 20, display = 'block', offset = '275', i_id_1_color = 'rgb(221, 144, 0)', fa = 'fad fa-cheeseburger', i_id_2_color = 'rgb(114, 68, 0)'},
[3] = {type = 1, enable = true, status = 'thirst', hideifmax = false, custom = true, value = 0, startvalue = 1000000, statusremove = 100, notify_lessthan = false, notify_message = 'i am very thirsty', notify_value = 20, display = 'block', offset = '275', i_id_1_color = 'rgb(36, 113, 255)', fa = 'fad fa-glass', i_id_2_color = 'rgb(0, 11, 112)'},
[4] = {type = 1, enable = true, status = 'stress', hideifmax = true, min_val_hide = 50, custom = true, value = 0, startvalue = 0, statusremove = 100, notify_lessthan = true, notify_message = 'i see some dragons', notify_value = 80, display = 'block', offset = '275', i_id_1_color = 'rgb(255, 16, 68)', fa = 'fad fa-head-side-brain', i_id_2_color = 'rgba(35, 255, 101, 0.842)'},
[4] = {type = 1, enable = true, status = 'stress', hideifmax = false, min_val_hide = 50, custom = true, value = 0, startvalue = 0, statusremove = 0, notify_lessthan = true, notify_message = 'i see some dragons', notify_value = 80, display = 'block', offset = '275', i_id_1_color = 'rgb(255, 16, 68)', fa = 'fad fa-head-side-brain', i_id_2_color = 'rgba(35, 255, 101, 0.842)'},
[5] = {type = 1, enable = true, status = 'stamina', hideifmax = true, min_val_hide = 100, custom = false, value = 0, notify_lessthan = false, notify_message = 'running makes me thirsty', notify_value = 20, display = 'block', offset = '275', i_id_1_color = 'rgb(16, 255, 136)', fa = 'fad fa-running', i_id_2_color = 'rgba(0, 119, 57, 0.945)'},
[6] = {type = 1, enable = true, status = 'oxygen', hideifmax = true, min_val_hide = 100, custom = false, value = 0, notify_lessthan = false, notify_message = 'my oxygen is almost gone', notify_value = 20, display = 'block', offset = '275', i_id_1_color = 'rgb(15, 227, 255)', fa = 'fad fa-lungs', i_id_2_color = 'rgba(8, 76, 85, 0.788)'},
[7] = {type = 1, enable = true, status = 'energy', hideifmax = true, min_val_hide = 50, custom = true, value = 0, startvalue = 1000000, statusremove = 100, notify_lessthan = false, notify_message = 'i am very tired', notify_value = 20, display = 'block', offset = '275', i_id_1_color = 'rgb(233, 233, 233)', fa = 'fas fa-snooze', i_id_2_color = 'color:rgb(243, 57, 0)'},
Expand Down

0 comments on commit bf7a679

Please sign in to comment.