Author Topic: Set a command cooldown on a per user basis  (Read 6595 times)

0 Members and 1 Guest are viewing this topic.

Hypertoken77

  • Youngling
  • *
  • Posts: 2
  • Karma: +1/-0
    • View Profile
  • Twitch Name: Hypertoken77
Set a command cooldown on a per user basis
« on: February 09, 2016, 01:44:32 PM »
I was working on a betting game, and wanted to have each user have his/her own cooldown, so they couldn't abuse the system.

If you wan't to use this for your command, change !test to the command name of your choice, or don't. Up to you! :P

Then replace the phrase "You've ran the test command successfully!" with the !command you want to run! That simple!

!test
Code: [Select]
@if@[@readfile@[Cooldown/@user@.txt]||||!testpass||!testmath](elevated)

!testmath
Code: [Select]
@if@[>=||@calc@[-|@unixtime@|@readfile@[Cooldown/@user@.txt]]||@readfile@[Cooldown/limit.txt]||!testpass||!testfail @calc@[-|@unixtime@|@readfile@[Cooldown/@user@.txt]]](elevated)

!testpass
Code: [Select]
You've ran the test command successfully! @savefile@[Cooldown/@user@.txt,@unixtime@]
(elevated)

!testfail
Code: [Select]
I'm sorry @user@ but that command can only be ran every @readfile@[Cooldown/limit.txt] seconds. You have @calc@[-|@readfile@[Cooldown/limit.txt]|@target@] seconds left.
(elevated)

!setcooldown
Code: [Select]
@if@[@target@||||You must provide a number of seconds ie: !setcooldown 60||@savefile@[Cooldown/limit.txt,@target@]]
(elevated, MOD only)

http://pastebin.com/VCsDV4Aa

TheRealAlixe

  • Knight
  • ***
  • Posts: 106
  • Karma: +5/-2
    • View Profile
    • Ninetales.us
  • Twitch Name: TheRealAlixe
Re: Set a command cooldown on a per user basis
« Reply #1 on: February 11, 2016, 12:17:29 AM »
Here is a bit more Advance version of the !setcooldown command

Code: [Select]
@if@[@target@||||You must provide a number of seconds ie: !setcooldown <folder> 60||@savefile@[@target@[1]/limit.txt,@target@[2]] you have set the cooldown for @target@[1] to @target@[2] seconds!]
Twitter: @TheRealAlixe | Web: Ninetales.us | Twitch: @TheRealAlixe | Discord: join

Ryswick

  • Youngling
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
  • Twitch Name: Ryswick
Re: Set a command cooldown on a per user basis
« Reply #2 on: March 03, 2016, 09:59:18 PM »
You guys are gods, keep up the great job. I'm dabbling in creating a RPG within my chat, and this helps greatly.

Was going to have multiple areas for viewers to grind, each with a cooldown. But giving them all personal cooldowns is so much better.

Roar_SA

  • Youngling
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
  • Twitch Name: roar_sa
Re: Set a command cooldown on a per user basis
« Reply #3 on: April 30, 2016, 06:54:30 AM »
Is there a way to set this up to have the end result of !chat be something along the lines of @tts@[@target@] with a sixty-second cooldown? I'd like to have text-to-speech but not have it spammed like gang busters, but the current setup doesn't seem to carry over a @target@ modifier.

Dropaduski

  • Youngling
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
  • Twitch Name: Dropaduski
Re: Set a command cooldown on a per user basis
« Reply #4 on: May 11, 2017, 12:35:29 AM »
Question, I am trying to use this for a song request cooldown per user.  The Cooldown itself is working fine but I cant seem to get @target@ to pass down to !testpass when the user has the ability to get to that command.  is there a way to pass @target@ down to test pass? 

Thanks