qb-hud
Keep track of your vitals in style
Last updated
Was this helpful?
Keep track of your vitals in style
Last updated
Was this helpful?
Player heads-up display that tracks vital information such as health, armor, food level, thirst level, etc.
Player settings are stored using KVP which is located on the player's machine so the only way to reset them is by using the in-game menu buttons
Source code for reference
RegisterNetEvent('hud:server:GainStress', function(amount)
local src = source
local Player = QBCore.Functions.GetPlayer(src)
local newStress
if not Player or (Config.DisablePoliceStress and Player.PlayerData.job.name == 'police') then return end
if not ResetStress then
if not Player.PlayerData.metadata['stress'] then
Player.PlayerData.metadata['stress'] = 0
end
newStress = Player.PlayerData.metadata['stress'] + amount
if newStress <= 0 then newStress = 0 end
else
newStress = 0
end
if newStress > 100 then
newStress = 100
end
Player.Functions.SetMetaData('stress', newStress)
TriggerClientEvent('hud:client:UpdateStress', src, newStress)
TriggerClientEvent('QBCore:Notify', src, Lang:t("notify.stress_gain"), 'error', 1500)
end)
How to use
TriggerServerEvent('hud:server:GainStress', --[[number]]))
OR
TriggerServerEvent('hud:server:GainStress', math.random(1, 3))
Source code for reference
RegisterNetEvent('hud:server:RelieveStress', function(amount)
local src = source
local Player = QBCore.Functions.GetPlayer(src)
local newStress
if not Player then return end
if not ResetStress then
if not Player.PlayerData.metadata['stress'] then
Player.PlayerData.metadata['stress'] = 0
end
newStress = Player.PlayerData.metadata['stress'] - amount
if newStress <= 0 then newStress = 0 end
else
newStress = 0
end
if newStress > 100 then
newStress = 100
end
Player.Functions.SetMetaData('stress', newStress)
TriggerClientEvent('hud:client:UpdateStress', src, newStress)
TriggerClientEvent('QBCore:Notify', src, Lang:t("notify.stress_removed"))
end)
How to use
TriggerServerEvent('hud:server:RelieveStress', --[[number]]))
OR
TriggerServerEvent('hud:server:RelieveStress', math.random(1, 3))