1
0
Fork 0
forked from Simnation/Main

Update server.lua

This commit is contained in:
Nordi98 2025-08-02 14:37:33 +02:00
parent 3c6281a3d5
commit e5cefcb85b

View file

@ -143,38 +143,33 @@ 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)
-- Try to update stress using common event
TriggerClientEvent('hud:client:UpdateStress', src, effects.stress)
end
end
-- Sync the updated status to the client
TriggerClientEvent('hud:client:UpdateNeeds', src, metadata.hunger, metadata.thirst)
end
-- Update all clients
TriggerClientEvent('pet-bowls:client:updateBowlLevel', -1, bowlId, newLevel)
TriggerClientEvent('ox_lib:notify', src, Config.Notifications.consumed)