function handleCooldown()
local initialCooldownSeconds = 5
local cooldownSecondsRemaining = 0
cooldownSecondsRemaining = initialCooldownSeconds
Citizen.CreateThread(function()
while cooldownSecondsRemaining > 0 do
Citizen.Wait(1000)
cooldownSecondsRemaining = cooldownSecondsRemaining - 1
end
end)
end
Edit: I put the “Citizen.Wait(5000)” before xPlayer.remove… but it still deposited the item after 5 seconds right after depositing. I want to stop players from depositing during that 5 seconds.
I used the code and it still made me deposit items without a cooldown.
Can’t we use os.time()? Like this?
RegisterServerEvent(‘esx_property:putItem’)
AddEventHandler(‘esx_property:putItem’, function(owner, type, item, count, interval) – added “interval” in the function
local _source = source
local xPlayer = ESX.GetPlayerFromId(_source)
local xPlayerOwner = ESX.GetPlayerFromIdentifier(owner)
local busy = Busy[interval]
if (os.time() - busy.lastdeposit) < 5 and busy.lastdeposit ~= 0 then
TriggerClientEvent(‘esx:showNotification’, source, _U(‘already_deposited’) … – added source again here, can we add 2 source?
(5 - (os.time() - busy.lastdeposit)) … _U(‘seconds’))
return
end
Or what about the ESX.SetTimeout in client.lua? I tried setting it to 5000 and the menu still shows up instantly even after putting a 5 second cooldown.