From fef0fde5a798f60727f9b5edfc6d3717904ba2c2 Mon Sep 17 00:00:00 2001 From: Antony <97451137+TonybynMp4@users.noreply.github.com> Date: Sat, 6 Apr 2024 23:27:21 +0200 Subject: [PATCH 1/2] stress serverside --- server/main.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/server/main.lua b/server/main.lua index b780b1a..2bad719 100644 --- a/server/main.lua +++ b/server/main.lua @@ -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 - math.random(params.stressRelief.min, params.stressRelief.max), 0, 100), true) TriggerClientEvent('hud:client:UpdateNeeds', source, playerState.thirst, sustenance) end) end From bfd604c0101cfda1566871c5355e3ea1e1bd5871 Mon Sep 17 00:00:00 2001 From: Antony <97451137+TonybynMp4@users.noreply.github.com> Date: Sat, 6 Apr 2024 23:30:12 +0200 Subject: [PATCH 2/2] serverside stress --- client/main.lua | 6 +++--- server/main.lua | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/client/main.lua b/client/main.lua index 6b879ac..ec440d9 100644 --- a/client/main.lua +++ b/client/main.lua @@ -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...', @@ -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, diff --git a/server/main.lua b/server/main.lua index 2bad719..692da6f 100644 --- a/server/main.lua +++ b/server/main.lua @@ -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) @@ -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