mirror of
https://github.com/jimathy/jim-consumables.git
synced 2026-08-18 23:16:03 +01:00
lock inventory until done or cancelled
This commit is contained in:
@@ -174,6 +174,7 @@ local consuming = false
|
|||||||
local cancelled = false
|
local cancelled = false
|
||||||
|
|
||||||
RegisterNetEvent('jim-consumables:Consume', function(itemName)
|
RegisterNetEvent('jim-consumables:Consume', function(itemName)
|
||||||
|
LocalPlayer.state:set("inv_busy", true, true)
|
||||||
local time = math.random(5000, 6000) -- How long it takes to consume something
|
local time = math.random(5000, 6000) -- How long it takes to consume something
|
||||||
local Player = PlayerPedId()
|
local Player = PlayerPedId()
|
||||||
local emote = Config.Emotes[Config.Consumables[itemName].emote]
|
local emote = Config.Emotes[Config.Consumables[itemName].emote]
|
||||||
@@ -196,6 +197,7 @@ RegisterNetEvent('jim-consumables:Consume', function(itemName)
|
|||||||
|
|
||||||
if consuming then
|
if consuming then
|
||||||
cancelled = true
|
cancelled = true
|
||||||
|
LocalPlayer.state:set("inv_busy", false, true)
|
||||||
TriggerEvent("QBCore:Notify", "Stopped "..string, "error")
|
TriggerEvent("QBCore:Notify", "Stopped "..string, "error")
|
||||||
consuming = not consuming
|
consuming = not consuming
|
||||||
return
|
return
|
||||||
@@ -235,6 +237,7 @@ RegisterNetEvent('jim-consumables:Consume', function(itemName)
|
|||||||
if IsControlJustPressed(0, 21) then
|
if IsControlJustPressed(0, 21) then
|
||||||
consuming = false
|
consuming = false
|
||||||
cancelled = true
|
cancelled = true
|
||||||
|
LocalPlayer.state:set("inv_busy", false, true)
|
||||||
end
|
end
|
||||||
Wait(10)
|
Wait(10)
|
||||||
time = time - 10
|
time = time - 10
|
||||||
@@ -326,6 +329,7 @@ RegisterNetEvent('jim-consumables:Consume', function(itemName)
|
|||||||
DeleteEntity(v)
|
DeleteEntity(v)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
LocalPlayer.state:set("inv_busy", false, true)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
CreateThread(function()
|
CreateThread(function()
|
||||||
|
|||||||
Reference in New Issue
Block a user