forked from Simnation/Main
Update server.lua
This commit is contained in:
parent
3c6281a3d5
commit
e5cefcb85b
1 changed files with 11 additions and 16 deletions
|
@ -143,36 +143,31 @@ RegisterNetEvent('pet-bowls:server:consumeBowl', function(bowlId)
|
|||
{newLevel, bowlId}
|
||||
)
|
||||
|
||||
-- Apply effects to player - FIXED VERSION
|
||||
-- Apply effects to player - FIXED VERSION FOR DIFFERENT QBCORE VERSIONS
|
||||
local effects = Config.Effects[bowl.type]
|
||||
if effects then
|
||||
-- Get player metadata
|
||||
local metadata = Player.PlayerData.metadata
|
||||
|
||||
-- Apply hunger effect
|
||||
-- Apply hunger effect for food bowls
|
||||
if effects.hunger and bowl.type == 'food' then
|
||||
metadata.hunger = math.min(100, metadata.hunger + effects.hunger)
|
||||
Player.Functions.SetMetadata('hunger', metadata.hunger)
|
||||
print('^2[Pet-Bowls]^7 Updated player hunger to ' .. metadata.hunger)
|
||||
-- Direct HUD update for hunger
|
||||
TriggerClientEvent('hud:client:UpdateHunger', src, effects.hunger, true)
|
||||
print('^2[Pet-Bowls]^7 Updated player hunger by +' .. effects.hunger)
|
||||
end
|
||||
|
||||
-- Apply thirst effect
|
||||
-- Apply thirst effect for water bowls
|
||||
if effects.thirst and bowl.type == 'water' then
|
||||
metadata.thirst = math.min(100, metadata.thirst + effects.thirst)
|
||||
Player.Functions.SetMetadata('thirst', metadata.thirst)
|
||||
print('^2[Pet-Bowls]^7 Updated player thirst to ' .. metadata.thirst)
|
||||
-- Direct HUD update for thirst
|
||||
TriggerClientEvent('hud:client:UpdateThirst', src, effects.thirst, true)
|
||||
print('^2[Pet-Bowls]^7 Updated player thirst by +' .. effects.thirst)
|
||||
end
|
||||
|
||||
-- Apply stress effect (if your server uses this)
|
||||
if effects.stress then
|
||||
if metadata.stress then
|
||||
metadata.stress = math.max(0, metadata.stress + effects.stress) -- Stress is negative in config
|
||||
Player.Functions.SetMetadata('stress', metadata.stress)
|
||||
end
|
||||
-- Try to update stress using common event
|
||||
TriggerClientEvent('hud:client:UpdateStress', src, effects.stress)
|
||||
end
|
||||
|
||||
-- Sync the updated status to the client
|
||||
TriggerClientEvent('hud:client:UpdateNeeds', src, metadata.hunger, metadata.thirst)
|
||||
end
|
||||
|
||||
-- Update all clients
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue