Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update status.lua #84

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 28 additions & 19 deletions client/player/status.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@ if not Config.Disable.Status then
local playerId = PlayerId()

AddEventHandler("esx_status:onTick", function(data)
local hunger, thirst
local hunger, thirst, stress
for i = 1, #data do
if data[i].name == "thirst" then
thirst = math.floor(data[i].percent)
end
if data[i].name == "hunger" then
hunger = math.floor(data[i].percent)
end
if data[i].name == "stress" then
stress = math.floor(data[i].percent)
end
end

local ped = PlayerPedId()
Expand All @@ -19,26 +22,32 @@ if not Config.Disable.Status then
values.armorBar = GetPedArmour(ped)
values.drinkBar = thirst
values.foodBar = hunger
values.stressBar = stress
end)

function HUD:StatusThread()
values = {}
CreateThread(function()
while ESX.PlayerLoaded do
local oxygen, stamina
oxygen = math.floor(GetPlayerUnderwaterTimeRemaining(playerId) * 10)
stamina = math.floor(100 - GetPlayerSprintStaminaRemaining(playerId))
if stamina == 0 then
stamina = 1
end
if stamina == 100 then
stamina = 0
end
values.oxygenBar = IsPedSwimmingUnderWater(PlayerPedId()) and oxygen or 0
values.staminaBar = stamina
SendNUIMessage({ type = "STATUS_HUD", value = values })
Wait(200)
values = {}
CreateThread(function()
while ESX.PlayerLoaded do
local oxygen, stamina, drunk
oxygen = math.floor(GetPlayerUnderwaterTimeRemaining(playerId) * 10)
stamina = math.floor(100 - GetPlayerSprintStaminaRemaining(playerId))
if stamina == 0 then
stamina = 1
end
if stamina == 100 then
stamina = 0
end
end)
end

-- Add drunk status calculation here
drunk = math.floor(ESX.Game.GetPlayerDrunkLevel(playerId) or 0) -- Assuming there is a method to get the player's drunk level

values.oxygenBar = IsPedSwimmingUnderWater(PlayerPedId()) and oxygen or 0
values.staminaBar = stamina
values.drunkBar = drunk -- Add drunk level to the values table
SendNUIMessage({ type = "STATUS_HUD", value = values })
Wait(200)
end
end)
end

Loading