Shy353

A command cooldown system without db

Oct 10th, 2020 (edited)
297
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.50 KB | None | 0 0
  1. /* Cool down system by πŸ†‚πŸ…·πŸ†ˆ */
  2. cooldown <- {};
  3. TimeLeft <- {};
  4.  
  5. function SetCooldown(p, taime) {
  6. cooldown.rawget(p.Name).rawset("Time", time() + taime);
  7.  }
  8.  
  9. onPlayerJoin:
  10.         cooldown.rawset(player.Name, {} );
  11.     if ( TimeLeft.rawin(player.UniqueID) )
  12.     {
  13.         local R = TimeLeft.rawget(player.UniqueID);
  14.         local S = time() + R;
  15.         cooldown.rawget(player.Name).rawset("Time", S);
  16.                 TimeLeft.rawdelete(player.UniqueID);
  17.     }
  18.  
  19. onPlayerPart:
  20. if ( cooldown.rawget(player.Name).rawin("Time") && cooldown.rawget(player.Name) ["Time"] > 0 )
  21.     {
  22.         local remainingtime = cooldown.rawget(player.Name) ["Time"] - time();
  23.         TimeLeft.rawset(player.UniqueID, remainingtime);
  24.     }
  25.  
  26. onPlayerCommand:
  27.     if ( cooldown.rawget(player.Name).rawin("Time") && cooldown.rawget(player.Name) ["Time"] > time() ) return MessagePlayer(format("Kindly wait %i seconds.", cooldown.rawget(player.Name) ["Time"] - time()), player);
  28.  
  29. At the end of onPlayerCommand function end or below the last command ending:
  30.     SetCooldown(player, 20); // It'll set 20 seconds as default time, use this function to set cooldowns.
  31.  
  32. /*
  33. πŸ…΄πŸ†‡πŸ…°πŸ…ΌπŸ…ΏπŸ…»πŸ…΄:
  34.  
  35. SetCooldown(player, 10); //set the instance(player)'s cooldown to 10 seconds. Remember: don't use time in milliseconds or it'll goto hours lol or you can edit it to milliseconds on your own..
  36.  
  37. SetCooldown(player, 120); //2 minute cooldown
  38.  
  39. SetCooldown(plr, 180); //3 minute cooldown for other instance plr. */
  40.  
  41. /* Any bugs, feel free to report on discord: Shy#3344 :) */
Add Comment
Please, Sign In to add comment