forked from Simnation/Main
Update client.lua
This commit is contained in:
parent
28b4007be3
commit
330458a574
1 changed files with 33 additions and 3 deletions
|
@ -64,6 +64,7 @@ function ConsumeItem(name)
|
||||||
type = "holdInteract",
|
type = "holdInteract",
|
||||||
bool = true
|
bool = true
|
||||||
})
|
})
|
||||||
|
|
||||||
while PerformingAction == "consume" and timeLeft > 0 do
|
while PerformingAction == "consume" and timeLeft > 0 do
|
||||||
if anim.time - timeLeft > 100 and not IsEntityPlayingAnim(ped, anim.dict, anim.anim, 13) then
|
if anim.time - timeLeft > 100 and not IsEntityPlayingAnim(ped, anim.dict, anim.anim, 13) then
|
||||||
timeLeft = timeLeft - 100
|
timeLeft = timeLeft - 100
|
||||||
|
@ -79,14 +80,35 @@ function ConsumeItem(name)
|
||||||
type = "holdInteract",
|
type = "holdInteract",
|
||||||
bool = false
|
bool = false
|
||||||
})
|
})
|
||||||
|
|
||||||
ClearPedTasks(ped)
|
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()
|
OptionsMenu()
|
||||||
PerformingAction = nil
|
PerformingAction = nil
|
||||||
elseif timeLeft <= 0 then
|
elseif timeLeft <= 0 then
|
||||||
lib.callback("pickle_consumables:useItem", "", function(result, uses)
|
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
|
-- 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
|
if result and Config.Effects[effectName] and Config.Effects[effectName].process then
|
||||||
CreateThread(function()
|
CreateThread(function()
|
||||||
if ProcessingEffect and not Config.Effects[effectName].canOverlap then return end
|
if ProcessingEffect and not Config.Effects[effectName].canOverlap then return end
|
||||||
|
@ -96,6 +118,7 @@ function ConsumeItem(name)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Check if ItemData exists
|
||||||
if not ItemData then
|
if not ItemData then
|
||||||
PerformingAction = nil
|
PerformingAction = nil
|
||||||
return
|
return
|
||||||
|
@ -108,11 +131,17 @@ function ConsumeItem(name)
|
||||||
|
|
||||||
-- Re-fetch config to ensure it's current
|
-- Re-fetch config to ensure it's current
|
||||||
local cfg = Config.Items[name]
|
local cfg = Config.Items[name]
|
||||||
if cfg and cfg.animation then
|
if cfg and cfg.animation and cfg.animation.time then
|
||||||
SendNUIMessage({
|
SendNUIMessage({
|
||||||
type = "displayApp",
|
type = "displayApp",
|
||||||
data = { quantity = uses, time = cfg.animation.time }
|
data = { quantity = uses, time = cfg.animation.time }
|
||||||
})
|
})
|
||||||
|
else
|
||||||
|
-- Fallback if config is missing
|
||||||
|
SendNUIMessage({
|
||||||
|
type = "displayApp",
|
||||||
|
data = { quantity = uses, time = 2000 }
|
||||||
|
})
|
||||||
end
|
end
|
||||||
PerformingAction = nil
|
PerformingAction = nil
|
||||||
end)
|
end)
|
||||||
|
@ -123,6 +152,7 @@ function ConsumeItem(name)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function RemoveItem()
|
function RemoveItem()
|
||||||
local ped = PlayerPedId()
|
local ped = PlayerPedId()
|
||||||
SendNUIMessage({
|
SendNUIMessage({
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue