Lottery Script

Platform:  mIRC
Published  Jun 18, 2011
Updated  Jun 26, 2011
So I've been trying to make a script like this, and I finally did. It worked out! To start it up, your bot will need to type /start. Here are the commands

!lottoregister
Registers your nick so you can play. You start with 5 points.

!lottostart
Starts a game

!lottobuy
Buys a ticket with 1 point.

!lottoscore
Gives your score.

!lottomemb
Gives the players in the lottery.

!poweruser <nick>
Adds a nick as a poweruser. Only you can add people as powerusers. Powerusers have some commands that only they can use.

Poweruser exclusive commands:

!lottoend
Ends the lottery game.

!points <nick> <inc or dec> <amount>
Changes a certain user's amount of points.

Enjoy! alias start {
set %chan $$?="What channel will the lottery game be played in?"
set %master $$?="Who will run the lottery game? (The user, not the bot. This user will be the only one who can add powerusers.)
}
on *:text:!lottoregister:%chan: {
if (!%points [ $+ [ $nick ] ]) {
set %points [ $+ [ $nick ] ] 5
notice $nick You have registered successfully! You will start with 5 points. Type 4!lottostart to start a lottery drawing!
}
elseif (%points [ $+ [ $nick ] ]) {
notice $nick You are already registered in the lottery.
}
}
on *:text:!lottostart:%chan: {
if (%points [ $+ [ $nick ] ] && %lottery != on) {
msg # A lottery drawing has started! A ticket costs 1 point! To buy a ticket, 4!lottobuy.
set %lottery on
set %amount 5
}
}
on *:text:!lottobuy:%chan: {
if (%amount > 0 && %points [ $+ [ $nick ] ] > 0 && %lottery == on && $nick !isin %people) {
dec %points $+ $nick
notice $nick You have successfully bought a ticket! You have %points [ $+ [ $nick ] ] points left!
set %people %people $nick
dec %amount
msg # $nick has joined the lottery! There are %amount spot(s) open!
}
elseif ($nick isin %people) {
notice $nick You are already in the lottery
}
elseif (%points [ $+ [ $nick ] ] == 0) {
msg # $nick is bankrupt! Contact a poweruser if you are bankrupt.
}
if (%amount == 0) {
draw
}
elseif (%points [ $+ [ $nick ] ] < 1) {
notice $nick You don't have enough points to join the lottery. You might be bankrupt, or you have haven't registered. To register, type 4!lottoregister. If you are bankrupt, contact a poweruser.
}
}
alias draw {
unset %lottery
set %winner $gettok(%people,$r(1,5),32)
msg # Drumroll please...
timer 1 5 msg # %winner has won the lottery! They will get 5 points.
inc %points [ $+ [ %winner ] ] 5
unset %amount
unset %people
unset %lottery
unset %winner
}
on *:text:!lottoscore:%chan: {
notice $nick You have %points [ $+ [ $nick ] ] points!
}
on *:text:!lottomemb:%chan: {
if (%people) {
msg # Users in the current lottery: %people $+ .
}
elseif (!%people) {
msg # Users in the current lottery: None.
}
}
on *:text:!lottoend:%chan: {
if ($nick isin %poweruser && %lottery == on) {
tokenize 32 %people
if ($1 != $null) {
inc %points [ $+ [ $1 ] ]
}
if ($2 != $null) {
inc %points [ $+ [ $2 ] ]
}
if ($3 != $null) {
inc %points [ $+ [ $3 ] ]
}
if ($4 != $null) {
inc %points [ $+ [ $4 ] ]
}
if ($5 != $null) {
inc %points [ $+ [ $5 ] ]
}
unset %amount
unset %people
unset %lottery
msg # the lottery was ended by $nick $+ !
}
}
on *:text:!poweruser*:%chan: {
if ($nick == %master && $2 !isin %poweruser) {
set %poweruser %poweruser $2
msg # $2 was added as a poweruser!
}
}
on *:text:!points*:%chan: {
if ($nick isin %poweruser) {
msg # $$3 $+ reased $$2 $+ 's points by $$4 $+ !
$$3 %points [ $+ [ $$2 ] ] $$4
}
elseif ($nick !isin %poweruser) {
msg # You can't use that command
}
}

Comments

Sign in to comment.
Annaiidziithaa   -  Mar 21, 2012
@blackvenomm666 , in each section you could use the "unset" on one line to shorten the code.
example: unset %amount %people %lottery %winner ...
 Respond  
Warriorii   -  Mar 18, 2012
Hmmmm I must have done something wrong, i couldn't get it to work at all for me
 Respond  
blackvenomm666   -  Jun 19, 2011
Code
 

^^^^this version will strip colors so people dont have to turn them off. And also groups your on text events
 Respond  
Jethro   -  Jun 18, 2011
There's one section of your code that you can shorten a lot more using:
Code
 
 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.