Jump to content

what timer function do I need


remaked

Recommended Posts

so I have a marker which is connected to an "onClientMarkerHit" event, I want to make it so if a player enters the marker(which opens a GUI) he will have to wait for example 3 minutes so he can get that GUI again by entering the same marker

 

i hope you got my point :D 

Link to comment

If you just want a cooldown you dont really need a timer for this. You can use getTickCount to keep track of time. (which does not create unnecessary timers)

For example:

local cooldownTime = 3 * 60 * 1000 -- Cooldown time in ms
local lastHit -- Last time we hit the marker while out of cooldown

function markerHitHandler()
  local currentTick = getTickCount()
  -- Check if the time between the current and last tick is smaller than our cooldown
  if lastHit and currentTick - lastHit <= cooldownTime then
    -- We are still on a cooldown so we stop the function execution
    outputChatBox("Still on cooldown")
    return
  else
    -- If we are not in cooldown, assign the current tick so that we can compare it in the future.
    lastHit = currentTick
  end
  
  openGUI()                                            
end
addEventHandler("onClientMarkerHit", marker, markerHitHandler)

 

 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...