Jump to content

what timer function do I need


cuteboy

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 post

Hello, you can store a var like canEnter = true then when the player leaves the gui you turn it to false and start a timer that will turn it to true after 3mins.

setTimer(function() canEnter=true end, 180000,1)

Link to post

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 post

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...