mIRC Home    About    Download    Register    News    Help

Print Thread
#246799 03/07/14 09:51 AM
Joined: Mar 2014
Posts: 65
E
Exuviax Offline OP
Babel fish
OP Offline
Babel fish
E
Joined: Mar 2014
Posts: 65
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


I do things with stuff that makes other things do stuff.
Joined: Mar 2014
Posts: 11
T
Pikka bird
Offline
Pikka bird
T
Joined: Mar 2014
Posts: 11
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.

Joined: Jan 2004
Posts: 1,358
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,358
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
    }
  }
}

Joined: Mar 2014
Posts: 11
T
Pikka bird
Offline
Pikka bird
T
Joined: Mar 2014
Posts: 11
Yeah my formatting sucks, cheers

Joined: Mar 2014
Posts: 65
E
Exuviax Offline OP
Babel fish
OP Offline
Babel fish
E
Joined: Mar 2014
Posts: 65
What would I use to delete the Reffle Text after you do !winner so it resets


I do things with stuff that makes other things do stuff.
Joined: Mar 2014
Posts: 11
T
Pikka bird
Offline
Pikka bird
T
Joined: Mar 2014
Posts: 11
You won't need to.
Code:
write -c Raffle.txt

Will clear it for you every time you start a new giveaway.


Link Copied to Clipboard