Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stress serverside #6

Merged
merged 2 commits into from
Apr 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading