Skip to content

Commit

Permalink
feat: health status
Browse files Browse the repository at this point in the history
  • Loading branch information
Andyyy7666 committed Feb 22, 2024
1 parent b7de268 commit 493bbef
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Planning to add what happens when a status is low, such as dissiness when hungry or thirsty. Drunk and drug screen effect & walking style when any of those are high.
# ND_Status
This resource enables hunger, thirst, stamina and more. You can add more status or remove in config file.
11 changes: 11 additions & 0 deletions config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,17 @@ config = {
icon = "fa-solid fa-person-running",
}
},
{
type = "health",
enabled = true,
max = 100.0,
action = "health",
style = {
circleColor = "#e44949",
iconColor = "#ffffff",
icon = "fa-solid fa-heart",
}
},
{
type = "armor",
enabled = true,
Expand Down
18 changes: 18 additions & 0 deletions source/actions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,24 @@ function actions.armor(ped, info, status)
status.status = (armor / (maxArmor*scalingFactor))*100
end

function actions.health(ped, info, status)
local health = GetEntityHealth(ped)
local maxHealth = GetEntityMaxHealth(ped)
if health > maxHealth then
health = maxHealth
elseif health < 0 then
health = 0
end

local total = (health/maxHealth)*100
local scalingFactor = (health/maxHealth)+((100-total)/60)
if scalingFactor < 0 then
scalingFactor = -scalingFactor
end

status.status = (health / (maxHealth*scalingFactor))*100
end

local lastFlashTime = 0
local lastStarveNotifiaction = 0
function actions.starve(ped, info, status)
Expand Down

0 comments on commit 493bbef

Please sign in to comment.