* I noticed where you incorrectly used the number One instead of a small L.
mIRC tends to ignore undefined switches for most identifiers, so this would behave like no switch were used. In case you haven't done it already, the /file menu of the script editor lets you change the font for the script editor independent from channel fonts. Especially if you're using a proportional font, you should probably switch to a fixed font. Especially one which makes it easier to see the difference between numbers 017 and letters OlI.
Your events all use :#: which means they react in all channels you happen to be in. You can change it to be :#channel: or :#channel1,#channel2: to restrict them further.
this triggers for any string beginning with !gamble including "!gamblers's anonymous". To make it respond only when !gamble is followed by a space or the end of line, change to:
on $*:TEXT:/^!gamble( |$)/i:#:{
* If someone wants to burn their entire bankroll, change from:
var %wager = $floor($2)
var %randgamble = $rand(1,100)
var %BankBalance $calc($readini(Points.ini,$+(#,.,$nick),Points))
modify to:
var %BankBalance $calc($readini(Points.ini,$+(#,.,$nick),Points))
if ($1 == all) var %wager %BankBalance | else var %wager $floor($2)
var %randgamble = $rand(1,100)
* to have top3 listing, this trigger responds to "!top3", and includes a changeable 30 seconds countdown before it will show the list again. It's a little simpler to use hash tables than global variables, because you can avoid using the square braces to access dynamic variables, using $hget(table,item $+ $nick) instead of %var. [ $+ [ $nick ] ] where it gets complicated when your dynamic variable needs to nest $nick and $chan and possibly other things.
on *:text:!top3:#: {
if (!$istok(nick1 nick2,$nick,32)) return
if ( !$hget(flood,topN $+ #) ) topN 3
else echo $chan !top3 available in $hget(flood,topN $+ #) seconds
hadd -mz flood topN $+ # 30
}
For the topN alias, you can add color formatting, as it now has none. "topN 3" gives the top 3, "topN 10" gives the top 10.
%min can change from 1 to another number to indicate the lowest number possible that could appear on the top list, so if you give people 50 points to start out with, changing %min to 51 keeps the non gamblers and the losers from being on the list. I didn't add code to handle a super long list of tied nicks causing the list to be longer than a valid channel message length or too long for the length of a variable, but that's unlikely without dozens of people tied for the same score. As long as you don't issue a lot of people the same number of points at the same time, this shouldn't be a problem. Another way is to change "%DontShow 0" to the default gift, so the top10 list could still show people with less than the default amount without showing anyone who either has not gambled or has a net zero profit.
Even if there are too-few nicks in the list, or if most people run out of points, it won't list anyone at zero points. If there's a tie for any position in the top list, it lists all the nicks at that score, even if that causes more than 10 nicks to list. i.e. if there's a tie for 1st place, it lists both as 1st place, and the next person lists at 3rd place. If there's a 3-way tie for 9th place, it lists all 3, and won't list the next person since they're really in 12th place.
Your gamble is basically a coin flip. You can have another method of gambling like a lotto.
!lotto A B
... which lets someone gamble A amount with 1/B odds of getting B-to-1 payout.
After you set bounds on how large B can be, and a minimum of B no less than 2, winner would be if $rand(1,B) is B (you could instead check if it's 1). If winner, Balance=Balance + A*B. If loser, Balance=Balance - A.
alias topN {
hfree -w topN | hmake topN
var %offset $len(#) + 2 , %LastPlace 0 , %min 1 , %DontShow 0 , %standings $iif($1 isnum 1-10,$int($1),10) , %TopN $str($calc(%min) $chr(32),%standings)
var %i $ini(points.ini,0) , %full_list | while (%i) {
var %section $ini(points.ini,%i) , %points $readini(points.ini,%section,points)
if (# $+ .* iswm %section) {
var %nick $mid(%section,%offset)
if ((%Points > 0) && (%Points != %DontShow) && (%Points >= %LastPlace)) {
hadd TopN %nick %Points
var %TopN $gettok($sorttok($addtok(%TopN,%Points,32),32,rn),1- $+ %standings,32) , %LastPlace $gettok(%TopN,$numtok(%TopN,32),32)
}
}
dec %i
}
if (%TopN != $null) {
var %place 1 , %place2 1 | while (%place isnum 1- $+ %standings) {
var %i 1 , %list , %i2
while ($hfind(TopN,$gettok(%TopN,%place,32),%i).data) {
var %list %list $v1 $hget(TopN,$v1) | inc %i2 | hdel TopN $v1
}
if (%list != $null) { var %full_list %full_list $ord(%place2) Place: %list | inc %place2 %i2 }
inc %place | if (%place2 > %standings) break | var %list
}
msg # %full_list
}
hfree -w TopN
}