Refactor hunger and thirst retrieval methods

Simplified Framework.GetHunger and Framework.GetThirst functions in both qb-core and qbx_core by using Framework.GetPlayerMetaData instead of accessing player data directly. This improves code readability and consistency.
This commit is contained in:
MrNewb committed 2025-09-10 11:29:42 -04:00
1 parent 08c3d937d6
commit f4e5d9485f
2 files changed
+8 -16

No files matched your search

+4 -8
View File
@@ -112,19 +112,15 @@ end
---This will get the hunger of a player
---@return number
Framework.GetHunger = function()
local player = Framework.GetPlayerData()
if not player then return 0 end
local playerData = player.PlayerData
return math.floor((playerData.metadata.hunger) + 0.5) or 0
local hunger = Framework.GetPlayerMetaData("hunger") or 0
return math.floor((hunger) + 0.5) or 0
end
---This will get the thirst of a player
---@return number
Framework.GetThirst = function()
local player = Framework.GetPlayerData()
if not player then return 0 end
local playerData = player.PlayerData
return math.floor((playerData.metadata.thirst) + 0.5) or 0
local thirst = Framework.GetPlayerMetaData("thirst") or 0
return math.floor((thirst) + 0.5) or 0
end
---This will get the players identifier (citizenid) etc.