Script Timer?

so i have script that i can people can sell items. but i want make it so u can sell it once every 5minutes. sorry for my english.

thats part where u sell items from client.lua
function OpenSellMenu()
ESX.UI.Menu.CloseAll()

ESX.UI.Menu.Open(
    'default', GetCurrentResourceName(), 'a_sell_menu',
    {
        title    = 'Sell',
        elements = {
            {label = 'Gold Bar', value = 'gold_bar'},
            {label = 'Diamonds', value = 'dia_box'},
        }
    },
    function(data, menu)
        if data.current.value == 'gold_bar' then
			TriggerServerEvent('aSell:sellgold_bar')
        elseif data.current.value == 'dia_box' then
			TriggerServerEvent('aSell:selldia_box')
        end
    end,
    function(data, menu)
        menu.close()
    end
)

end

Just save the current time GetGameTimer() everytime someone sells something, then when someone tries to sell something again check if the current time, and the last time is longer than 5 minutes

how i can do that?

1 Like

and set the sellling var to true, when ur actually setting it, also add a check to see wheter someone is actually selling based upon whatever ur going to use for checking if a person to sell :+1:

Citizen.CreateThread(function()
  while true do
    Citizen.Wait(5000)
    -- run code here
  end
end)
1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.