Skip to content

Commit

Permalink
feat: stress serverside (#6)
Browse files Browse the repository at this point in the history
* stress serverside

* serverside stress
  • Loading branch information
TonybynMp4 committed Apr 6, 2024
1 parent e69f141 commit 29376dd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 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
3 changes: 2 additions & 1 deletion 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,6 +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 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 29376dd

Please sign in to comment.