[HELP] Need a hand

Why is this not working? I wanted to make a 5 cooldown in between depositing/withdrawing an item from the apartment(esx_property).

Here’s the function code from client.lua.

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

just add a
Citizen.Wait(5000)
before
xPlayer.remove...

I will try this, will get back to you later. :slight_smile:

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.

local busy = false
	
	if type == 'item_standard' then

		local playerItemCount = xPlayer.getInventoryItem(item).count

		if playerItemCount >= count and count > 0 and busy == false then
			busy = true
			TriggerEvent('esx_addoninventory:getInventory', 'property', xPlayerOwner.identifier, function(inventory)
				xPlayer.removeInventoryItem(item, count)
				inventory.addItem(item, count)
				TriggerClientEvent('esx:showNotification', _source, _U('have_deposited', count, inventory.getItem(item).name))
			end)
			Citizen.Wait(5000)
			busy = false
		else
			TriggerClientEvent('esx:showNotification', _source, _U('invalid_quantity'))
		end

This will let people put items and wait 5 sec… (didn’t test it)

This still made me deposit items without a cooldown. But thank you though. <3

cooldown after you put item

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.