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

esx_hud stressed and drunk #80

Closed
Rangerhitam12 opened this issue Jun 6, 2024 · 2 comments
Closed

esx_hud stressed and drunk #80

Rangerhitam12 opened this issue Jun 6, 2024 · 2 comments

Comments

@Rangerhitam12
Copy link

Rangerhitam12 commented Jun 6, 2024

add stress and hangovers

@github-project-automation github-project-automation bot moved this to 🆕 New in ESX Roadmap Jun 6, 2024
@github-project-automation github-project-automation bot moved this from 🆕 New to ✅ Done in ESX Roadmap Jun 6, 2024
@Rangerhitam12 Rangerhitam12 reopened this Jun 7, 2024
@Rangerhitam12
Copy link
Author

if not Config.Disable.Status then
local values = {}
local playerId = PlayerId()

AddEventHandler("esx_status:onTick", function(data)
    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()

    values.healthBar = math.floor((GetEntityHealth(ped) - 100) / (GetEntityMaxHealth(ped) - 100) * 100)
    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, 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

        -- 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

@Gellipapa
Copy link
Collaborator

Check pm, please open pull request

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

2 participants