mIRC Homepage
Posted By: Majeye Help with a script [TWITCH] - 27/03/15 12:23 AM
So this is the script I have (it is fully functional), and my question is, how could I go about adding to it where it'll feed back to a user that they are on cooldown(flood control) and have it tell them how long they have left until they can use the command again?

Code:
on *:text:!pizza:#kreenpananas:{
  if ((%floodkreenpizza) || ($($+(%,floodkreenpizza.,$nick),2))) { return }
  set -u10800 %floodkreenpizza. $+ $nick On
  var %file = kreenpizza.ini, %cmd = $1
  var %sum = $calc($readini(%file,n,$nick,%cmd) + 1)

  writeini %file $nick %cmd %sum
  msg # $upper($nick) has indulged in the Kreenstream's slice of life %sum $iif(%sum > 1,times.,time.) Immortality is at hand! (3-hour cooldown)
}
Posted By: Majeye Re: Help with a script [TWITCH] - 27/03/15 12:49 AM
2nd question unrelated to the first...

How could I get the following command to be channel owner only? and add a stop function?

Code:
on *:TEXT:!raffle:#:{
  if ($nick isop #) {
    set %raffle $rand(1,100)
    msg $chan /me First person to guess the number between 1 and 100 wins!
  }
}


on *:text:*:#: {
  if ($1- == %raffle) {
    msg $chan WE HAVE A WINNER  
    msg $chan /me The Winner is $nick with the number %raffle $+ !!!!!!
    unset %raffle
    .timerraffle 1 10 msg $chan CONGRATULATIONS $nick !
  }
  else { }
}
Posted By: Nillen Re: Help with a script [TWITCH] - 27/03/15 12:50 AM
Code:
if ((%floodkreenpizza) || ($($+(%,floodkreenpizza.,$nick),2))) { return }
  set -u10800 %floodkreenpizza. $+ $nick On
Those lines deal with the flood control. The second line sets a variable, the first line checks if the variable is set. If it is set, it's going to return (do nothing).
I don't think there's a way to say how long it's left using -uN, but if you change the second line to use set -z %variable 10800 you can simply use $v1 in the first line to refer to the seconds left. $duration($v1) will give you minutes/hours
Posted By: Nillen Re: Help with a script [TWITCH] - 27/03/15 12:53 AM
There is no such thing as a "channel owner" on twitch. The channel owner you're referring to is the person who has the same nickname as the channel. if ($nick == $mid(#,2)) { do stuff }

Code:
on *:TEXT:!raffle &:#:{
  if ($nick isop #) {
    if (($2 == on) && (%!raffle)) { 
      set %raffle $rand(1,100)
      msg $chan /me First person to guess the number between 1 and 100 wins!
    }
    elseif (($2 == off) && (%raffle)) {
      unset %raffle 
      msg $chan it's off 
    }
  }
}


Just curious, if you knew how to script this yourself, and you obviously knew how to use the unset function in the second text event, couldn't you have figured out an on/off feature yourself?
Posted By: Majeye Re: Help with a script [TWITCH] - 27/03/15 12:54 AM
Thank you, Nillen! You're a boss!

also, i'm sure i could figure out the on/off function myself if i sat at it for a while.. which i just might do. was just looking for guidance in the right direction.

I never look for someone to write codes for me, just for a push in the right direction is all.
Posted By: Majeye Re: Help with a script [TWITCH] - 27/03/15 01:00 AM
Originally Posted By: Nillen
Code:
if ((%floodkreenpizza) || ($($+(%,floodkreenpizza.,$nick),2))) { return }
  set -u10800 %floodkreenpizza. $+ $nick On
Those lines deal with the floot control. The second line sets a variable, the first line checks if the variable is set. If it is set, it's going to return (do nothing).
I don't think there's a way to say how long it's left using -uN, but if you change the second line to use set -z %variable 10800 you can simply use $v1 in the first line to refer to the seconds left. $duration($v1) will give you minutes/hours


Could you show me an example of this? (you don't have to use my code if you don't want, just trying to better understand what you mean)
Posted By: Belhifet Re: Help with a script [TWITCH] - 27/03/15 01:21 AM
Code:
if ((%floodkreenpizza) || ($($+(%,floodkreenpizza.,$nick),2))) { return }


If the variable %floodkreenpizza exists OR the variable %floodkreenpizza.$nick exists then do this { Return }

if we didn't return, continue


set a variable named %floodkreenpizza.$nick for 10800 seconds.


This means that this variable will be set. If the command is used again in the next 10800 seconds, we will return when we check if the variable exists.
Posted By: Majeye Re: Help with a script [TWITCH] - 27/03/15 06:04 AM
Originally Posted By: Belhifet
Code:
if ((%floodkreenpizza) || ($($+(%,floodkreenpizza.,$nick),2))) { return }


If the variable %floodkreenpizza exists OR the variable %floodkreenpizza.$nick exists then do this { Return }

if we didn't return, continue


set a variable named %floodkreenpizza.$nick for 10800 seconds.


This means that this variable will be set. If the command is used again in the next 10800 seconds, we will return when we check if the variable exists.


I thought I understood until this was posted. haha..

i hate being a noob at this sometimes.
© mIRC Discussion Forums