Skip to content

Commit

Permalink
fix(server/player): status desync (#459)
Browse files Browse the repository at this point in the history
This fixes an issue where the statebag statuses were clamped to 0-100 while the meta statuses wcould go over 100. causing them to become desynced. this would cause huds that use metadata values to say that players had more hunger/thirst than they really had and they would start dying for no apparent reason. it will now clamp both to 100.
  • Loading branch information
Demigod916 committed Apr 24, 2024
1 parent 144e7bf commit 5d7e879
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion server/player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,8 @@ function CreatePlayer(playerData, Offline)
function self.Functions.SetMetaData(meta, val)
if not meta or type(meta) ~= 'string' then return end
if (meta == 'hunger' or meta == 'thirst' or meta == 'stress') and self.PlayerData.source then
Player(self.PlayerData.source).state:set(meta, lib.math.clamp(val, 0, 100), true)
val = lib.math.clamp(val, 0, 100)
Player(self.PlayerData.source).state:set(meta, val, true)
end

local oldVal = self.PlayerData.metadata[meta]
Expand Down

0 comments on commit 5d7e879

Please sign in to comment.