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}
|
{newLevel, bowlId}
|
||||||
)
|
)
|
||||||
|
|
||||||
-- Apply effects to player - FIXED VERSION
|
-- Apply effects to player - FIXED VERSION FOR DIFFERENT QBCORE VERSIONS
|
||||||
local effects = Config.Effects[bowl.type]
|
local effects = Config.Effects[bowl.type]
|
||||||
if effects then
|
if effects then
|
||||||
-- Get player metadata
|
-- Get player metadata
|
||||||
local metadata = Player.PlayerData.metadata
|
local metadata = Player.PlayerData.metadata
|
||||||
|
|
||||||
-- Apply hunger effect
|
-- Apply hunger effect for food bowls
|
||||||
if effects.hunger and bowl.type == 'food' then
|
if effects.hunger and bowl.type == 'food' then
|
||||||
metadata.hunger = math.min(100, metadata.hunger + effects.hunger)
|
-- Direct HUD update for hunger
|
||||||
Player.Functions.SetMetadata('hunger', metadata.hunger)
|
TriggerClientEvent('hud:client:UpdateHunger', src, effects.hunger, true)
|
||||||
print('^2[Pet-Bowls]^7 Updated player hunger to ' .. metadata.hunger)
|
print('^2[Pet-Bowls]^7 Updated player hunger by +' .. effects.hunger)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Apply thirst effect
|
-- Apply thirst effect for water bowls
|
||||||
if effects.thirst and bowl.type == 'water' then
|
if effects.thirst and bowl.type == 'water' then
|
||||||
metadata.thirst = math.min(100, metadata.thirst + effects.thirst)
|
-- Direct HUD update for thirst
|
||||||
Player.Functions.SetMetadata('thirst', metadata.thirst)
|
TriggerClientEvent('hud:client:UpdateThirst', src, effects.thirst, true)
|
||||||
print('^2[Pet-Bowls]^7 Updated player thirst to ' .. metadata.thirst)
|
print('^2[Pet-Bowls]^7 Updated player thirst by +' .. effects.thirst)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Apply stress effect (if your server uses this)
|
-- Apply stress effect (if your server uses this)
|
||||||
if effects.stress then
|
if effects.stress then
|
||||||
if metadata.stress then
|
-- Try to update stress using common event
|
||||||
metadata.stress = math.max(0, metadata.stress + effects.stress) -- Stress is negative in config
|
TriggerClientEvent('hud:client:UpdateStress', src, effects.stress)
|
||||||
Player.Functions.SetMetadata('stress', metadata.stress)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Sync the updated status to the client
|
|
||||||
TriggerClientEvent('hud:client:UpdateNeeds', src, metadata.hunger, metadata.thirst)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Update all clients
|
-- Update all clients
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue