Skip to content

Commit

Permalink
serverside stress
Browse files Browse the repository at this point in the history
  • Loading branch information
TonybynMp4 authored Apr 6, 2024
1 parent fef0fde commit bfd604c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ local function drunkLoop()
end)
end

lib.callback.register('consumables:client:DrinkAlcohol', function(params)
lib.callback.register('consumables:client:DrinkAlcohol', function(anim, prop)
if lib.progressBar({
duration = math.random(3000, 6000),
label = 'Drinking liquor...',
Expand All @@ -79,12 +79,12 @@ lib.callback.register('consumables:client:DrinkAlcohol', function(params)
mouse = false,
combat = true
},
anim = params.anim or {
anim = anim or {
clip = 'loop_bottle',
dict = 'mp_player_intdrink',
flag = 49
},
prop = params.prop or {
prop = prop or {
{
model = 'prop_amb_beer_bottle',
bone = 18905,
Expand Down
4 changes: 2 additions & 2 deletions server/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ for alcohol, params in pairs(config.alcoholItems) do
}
end

local drank = lib.callback.await('consumables:client:DrinkAlcohol', source, { anim = params.anim, prop = params.prop, stressRelief = params.stressRelief})
local drank = lib.callback.await('consumables:client:DrinkAlcohol', source, params.anim, params.prop)
if not drank then return end
if not exports.ox_inventory:RemoveItem(source, item.name, 1, nil, item.slot) then return end
local sustenance = lib.math.clamp(playerState.thirst + math.random(params.min, params.max), 0, 100)
Expand All @@ -33,7 +33,7 @@ for alcohol, params in pairs(config.alcoholItems) do
exports.qbx_core:Notify(source, 'You feel like you can handle your liquor better now', 'success')
end

playerState:set('stress', lib.math.clamp(playerState.stress - math.random(params.stressRelief.min, params.stressRelief.max), 0, 100), true)
playerState:set('stress', lib.math.clamp((playerState.stress or 0) - math.random(params.stressRelief.min, params.stressRelief.max), 0, 100), true)
TriggerClientEvent('hud:client:UpdateNeeds', source, playerState.thirst, sustenance)
end)
end
Expand Down

0 comments on commit bfd604c

Please sign in to comment.