remaked Posted September 6, 2020 Share Posted September 6, 2020 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 Link to comment
Spakye Posted September 6, 2020 Share Posted September 6, 2020 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 comment
AfuSensi Posted September 9, 2020 Share Posted September 9, 2020 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
Moderators IIYAMA Posted September 9, 2020 Moderators Share Posted September 9, 2020 You can also use this useful function: https://wiki.multitheftauto.com/wiki/CheckPassiveTimer Which does more or less the same as AfuSensi his example, after adding the source code. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now