Skip to content

Commit

Permalink
fix: prevent dumb errors (you never know with fiveM)
Browse files Browse the repository at this point in the history
  • Loading branch information
TonybynMp4 committed Mar 4, 2024
1 parent b9cedb8 commit fb848cc
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions client/main.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local config = require('config.client')
local alcoholLevel = LocalPlayer.state.alcohol or 0
local playerWalk
local playerState = LocalPlayer.state
local alcoholLevel = playerState.alcohol or 0
local playerWalk

local function resetEffect()
exports.scully_emotemenu:setWalk(playerWalk or 'move_m@casual@a')
Expand Down Expand Up @@ -101,7 +101,8 @@ lib.callback.register('consumables:client:DrinkAlcohol', function(params)
end)

AddStateBagChangeHandler('alcohol', ('player:%s'):format(cache.serverId), function(_, _, value)
if alcoholLevel <= 0 and value > 0 then
if type(value) ~= 'number' then return end
if (not alcoholLevel or alcoholLevel < 0) and value > 0 then
alcoholLevel = value
SetTimeout(config.delayEffect, drunkLoop)
return
Expand All @@ -126,4 +127,4 @@ AddEventHandler('onResourceStart', function(resource)
resetEffect()
end
end
end)
end)

0 comments on commit fb848cc

Please sign in to comment.