1
0
Fork 0
forked from Simnation/Main

Update client.lua

This commit is contained in:
Nordi98 2025-07-29 00:44:44 +02:00
parent 28b4007be3
commit 330458a574

View file

@ -64,6 +64,7 @@ function ConsumeItem(name)
type = "holdInteract",
bool = true
})
while PerformingAction == "consume" and timeLeft > 0 do
if anim.time - timeLeft > 100 and not IsEntityPlayingAnim(ped, anim.dict, anim.anim, 13) then
timeLeft = timeLeft - 100
@ -79,14 +80,35 @@ function ConsumeItem(name)
type = "holdInteract",
bool = false
})
ClearPedTasks(ped)
if timeLeft > 0 and anim.time - timeLeft <= 100 then
-- Store animation time in a local variable to avoid nil reference
local animTime = anim.time
-- Check if timeLeft is nil and provide a default
if timeLeft == nil then
timeLeft = 0
end
-- Now use the local variable for comparison
if timeLeft > 0 and animTime and (animTime - timeLeft <= 100) then
OptionsMenu()
PerformingAction = nil
elseif timeLeft <= 0 then
lib.callback("pickle_consumables:useItem", "", function(result, uses)
-- Check if cfg still exists (could have changed during callback)
if not cfg then
PerformingAction = nil
return
end
-- Safe access to cfg.effect
local effectName = cfg.effect and cfg.effect.name or ""
local effectName = ""
if cfg.effect and cfg.effect.name then
effectName = cfg.effect.name
end
if result and Config.Effects[effectName] and Config.Effects[effectName].process then
CreateThread(function()
if ProcessingEffect and not Config.Effects[effectName].canOverlap then return end
@ -96,6 +118,7 @@ function ConsumeItem(name)
end)
end
-- Check if ItemData exists
if not ItemData then
PerformingAction = nil
return
@ -108,11 +131,17 @@ function ConsumeItem(name)
-- Re-fetch config to ensure it's current
local cfg = Config.Items[name]
if cfg and cfg.animation then
if cfg and cfg.animation and cfg.animation.time then
SendNUIMessage({
type = "displayApp",
data = { quantity = uses, time = cfg.animation.time }
})
else
-- Fallback if config is missing
SendNUIMessage({
type = "displayApp",
data = { quantity = uses, time = 2000 }
})
end
PerformingAction = nil
end)
@ -123,6 +152,7 @@ function ConsumeItem(name)
end
function RemoveItem()
local ped = PlayerPedId()
SendNUIMessage({