mIRC Home    About    Download    Register    News    Help

Print Thread
Giveaway script help #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.
Re: Giveaway script help [Re: Exuviax] #246802 03/07/14 03:32 PM
Joined: Mar 2014
Posts: 11
T
Tehpolecat Offline
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.

Re: Giveaway script help [Re: Tehpolecat] #246804 03/07/14 05:58 PM
Joined: Jan 2004
Posts: 1,319
L
Loki12583 Online
Hoopy frood
Online
Hoopy frood
L
Joined: Jan 2004
Posts: 1,319
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
    }
  }
}

Re: Giveaway script help [Re: Loki12583] #246805 03/07/14 06:46 PM
Joined: Mar 2014
Posts: 11
T
Tehpolecat Offline
Pikka bird
Offline
Pikka bird
T
Joined: Mar 2014
Posts: 11
Yeah my formatting sucks, cheers

Re: Giveaway script help [Re: Tehpolecat] #246819 04/07/14 06:10 AM
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.
Re: Giveaway script help [Re: Exuviax] #246831 04/07/14 05:27 PM
Joined: Mar 2014
Posts: 11
T
Tehpolecat Offline
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.