• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Global Cooldown

strutZ

Australian OT Member {AKA Beastn}
Joined
Nov 16, 2014
Messages
1,393
Solutions
7
Reaction score
552
Hey otland,

I'm currently working on a scriptfor tfs 1.2 that will allow players to start raids. My question is, Is there a command i can use to give it a global cooldown?

Basically you use a stone and a window pops up, You select the raid you want and then it starts. I then want to give it a cooldown so once a raid has been triggered you must wait 30 mins before you can start another. meaning once a player starts a raid EVERYONE must wait.
 
so i'm guessing i would use them in conjunction with ostime?
Yes, that's correct. You can also use os.mtime (returns current timestamp in milliseconds) if you want the exhaustion to be more accurate.
 
Yes, that's correct. You can also use os.mtime (returns current timestamp in milliseconds) if you want the exhaustion to be more accurate.
Code:
local raids = {
  [1] = {raid = 'Arachir the Ancient One'},
     [2] = {raid = 'Diblis The Fair'},
     [3] = {raid = 'Ferumbras'},
     [4] = {raid = 'Ghazbaran'},
     [5] = {raid = 'Horned Fox'},
     [6] = {raid = 'Morgaroth'},   
     [7] = {raid = 'Necropharus'},
     [8] = {raid = 'Orshabaal'},
     [9] = {raid = 'Sir Valorcrest'},
     [10] = {raid = 'The Old Widow'},
     [11] = {raid = 'Zevelon Duskbringer'},
     [12] = {raid = 'Zulazza the Corruptor'},
     [13] = {raid = 'Apocalypse'},
     
}
   
function onModalWindow(player, modalWindowId, buttonId, choiceId)
  player:unregisterEvent("modalRAID_Bosses")

  if modalWindowId == 1003 then
  if buttonId == 100 then
       if Game.getStorageValue(12345) == os.time() then
         player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You must wait 30 mins before you can start another raid.")
       return false
       end
  if choiceId == 0 then
  return false
  end
       Game.setStorageValue(12345, os.time() + 60)
       Game.startRaid(raids[choiceId].raid)
  player:getPosition():sendMagicEffect(CONST_ME_FIREWORK_YELLOW)
  end
  end
end

This is what i got so far.. when i add in the storage value breaks script.. no error.
 
Last edited:
You are a god among us mear peasents. Thanks man ;) btw, Is there a way to make the "please wait' more accurate meaning instead of saying "Please wait 30" it gives you the exact time? Its something i have been trying to figure out but i dont think its possible..
You will release this script?
 
You are a god among us mear peasents. Thanks man ;) btw, Is there a way to make the "please wait' more accurate meaning instead of saying "Please wait 30" it gives you the exact time? Its something i have been trying to figure out but i dont think its possible..
Yep, it's actually quite easy to get the time left.

Search results:
https://otland.net/threads/timestring-timediff-23-hours-30-minutes-and-10-seconds.24751/
https://otland.net/threads/function-time-formatting-x-days-1-minute-and-x-seconds-left.213896/
 

Similar threads

Back
Top