mIRC Homepage
Posted By: Exuviax Giveaway script help - 03/07/14 09:51 AM
So basically I want to create a giveaway script that writes to a file.

So, when I do !giveaway the bot will say

"A Giveaway has been opened on # say !enter to join"

This will then allow all the people in the IRC chat to do !enter and their $nick will be written to a file.

Then I do !winner, and the bot will say

"And the winner is (RANDOM USERNAME FROM LIST)"

Then I will do !clear and it will clear the file it was writing it to?

Any help would be super awesome, I will update this as people help hopefully creating a full script eventually.

Thank you,
Exuviax
Posted By: Tehpolecat Re: Giveaway script help - 03/07/14 03:32 PM
Ok, here's how i would do it:
Code:
On *:text:!giveaway:#:{
  if ($nick == YOURNAMEHERE) { msg $chan Giveaway started on #, type !enter to enter $+
    write -c Raffle.txt
  set %rafflestatus ON }
}
on *:text:!enter:#:{
  var %f = f. $+ $ticks
  .fopen %f Raffle.txt
  while ($fread(%f)) {
    if ($nick == $v1) { .fclose %f
    return } 
  }
  write Raffle.txt $nick
  .fclose %f
}
on *:text:!winner:#:{
  if ($nick == YOURNAMEHERE) {
    if (%rafflestatus) { msg $chan $read(Raffle.txt) is the winner $+
      unset %rafflestatus }
  }
}


Maybe someone can improve this.
Posted By: Loki12583 Re: Giveaway script help - 03/07/14 05:58 PM
Please use line breaks correctly with your braces:

Code:
On *:text:!giveaway:#:{
  if ($nick == YOURNAMEHERE) {
    msg $chan Giveaway started on #, type !enter to enter
    write -c Raffle.txt
    set %rafflestatus ON
  }
}
on *:text:!enter:#:{
  if ($read(Raffle.txt,w,$nick)) return
  write Raffle.txt $nick
}
on *:text:!winner:#:{
  if ($nick == YOURNAMEHERE) {
    if (%rafflestatus) {
      msg $chan $read(Raffle.txt) is the winner
      unset %rafflestatus
    }
  }
}
Posted By: Tehpolecat Re: Giveaway script help - 03/07/14 06:46 PM
Yeah my formatting sucks, cheers
Posted By: Exuviax Re: Giveaway script help - 04/07/14 06:10 AM
What would I use to delete the Reffle Text after you do !winner so it resets
Posted By: Tehpolecat Re: Giveaway script help - 04/07/14 05:27 PM
You won't need to.
Code:
write -c Raffle.txt

Will clear it for you every time you start a new giveaway.
© mIRC Discussion Forums