Merge pull request #146 from solaire-fivem/fix-issue-with-the-GetHunger-and-GetThirst-server-sided-functions
Fix issue with GetThirst and GetHunger not working in ESX
This commit is contained in:
1 file changed
+16
-6
@@ -248,22 +248,32 @@ Framework.AddHunger = function(src, value)
|
|||||||
return levelForEsx
|
return levelForEsx
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @description This will get the hunger of a player
|
--- @description This will get the hunger of a player (ESX we get the percent of the status)
|
||||||
--- @param src number
|
--- @param src number
|
||||||
--- @return number | nil
|
--- @return number | nil
|
||||||
Framework.GetHunger = function(src)
|
Framework.GetHunger = function(src)
|
||||||
local status = Framework.GetStatus(src, "status")
|
local status = Framework.GetStatus(src, "status")
|
||||||
if not status then return 0 end
|
if not status then return nil end
|
||||||
return status.hunger
|
|
||||||
|
for _, entry in ipairs(status) do
|
||||||
|
if entry.name == "hunger" then
|
||||||
|
return math.floor(entry.percent)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @description This will get the thirst of a player
|
--- @description This will get the thirst of a player (ESX we get the percent of the status)
|
||||||
--- @param src any
|
--- @param src any
|
||||||
--- @return number | nil
|
--- @return number | nil
|
||||||
Framework.GetThirst = function(src)
|
Framework.GetThirst = function(src)
|
||||||
local status = Framework.GetStatus(src, "status")
|
local status = Framework.GetStatus(src, "status")
|
||||||
if not status then return 0 end
|
if not status then return nil end
|
||||||
return status.thirst
|
|
||||||
|
for _, entry in ipairs(status) do
|
||||||
|
if entry.name == "thirst" then
|
||||||
|
return math.floor(entry.percent)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @description This will get the phone number of a player
|
--- @description This will get the phone number of a player
|
||||||
|
|||||||
Reference in new issue
Block a user