Guest User

Untitled

a guest
Oct 20th, 2017
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 94.65 KB | None | 0 0
  1. Demo Bot EGO v.1
  2. =========
  3.  
  4. on *:load: {
  5.   set %1 ace
  6.   set %2 2
  7.   set %3 3
  8.   set %4 4
  9.   set %5 5
  10.   set %6 6
  11.   set %7 7
  12.   set %8 8
  13.   set %9 9
  14.   set %10 10
  15.   set %11 jack
  16.   set %12 queen
  17.   set %13 king
  18.   set %chan $?="enter #channel name"
  19.   set %game on
  20.   writeini bj.ini bj player1 none
  21.   writeini bj.ini bj player2 none
  22.   writeini bj.ini bj player3 none
  23.   writeini bj.ini bj player4 none
  24.   writeini bj.ini bj player5 Start game
  25.   echo -a 3,4Thank you for using GigaOptic's Bot Script for mIRC!
  26.   echo -a 1,4Please be wary, I need Master Access in this room for me to use certain commands. Type !Masteronlycommands for more information on this subject
  27.   set %password $$?="Enter the Bot's Password. This will be used for special commands dealing with the password."
  28.   set %Master $$?="Enter the Nick that owns this bot"
  29.   /auser Master %Master
  30.  
  31. }
  32.  
  33. #KICKTHATASSBAN
  34.  
  35. on @*:BAN:#: { if ($nick == $me) { .auser nounban $banmask } }
  36. on @*:UNban:#: { if ($nick == $me) { .ruser nounban $banmask | return } | if ($level($banmask) == nounban) && ($nick != $me) { raw -q mode # +b-k $banmask Secured.Ban } }
  37. on *:EXIT: { .rlevel -r nounban }
  38.  
  39. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Just type /massinvite #target #where
  40. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Example: /massinvite #Chan1 #chan2 will mass invite #chan1 to #chan2.
  41.  
  42. alias massinvite {
  43.   var %x $nick($1,0)
  44.   while (%x) {
  45.     invite $nick($1,%x) $2
  46.     dec %x
  47.   }
  48. }
  49.  
  50. #Alerts
  51. ON *:TEXT:*!ns*:#: { msg $chan $chan isn't a place for spamming. 0,4Stop now. }
  52. ON *:TEXT:*!nd*:#: { msg $chan You do not disrespect Ops, or any staff. 0,4Stop now. }
  53. ON *:TEXT:*!nt*:#: { msg $chan You do not Troll in here. Lol, just joking. Actually don't troll! 0,4Stop now. }
  54.  
  55.  
  56. on *:TEXT:*:#: {
  57.   if ($1 == !usercmds) { !invte USERNAME (Invite to Channel) !txhelp (help for game taxes holden) }
  58.   if ($1 == !invite) { invite $2 $chan }
  59. }
  60.  
  61. on %Master:TEXT:*:#: {
  62.   Tokenize 32 $Strip($1-)
  63.   if ($1- == Who owns you $me) { timer 1 1 msg $chan You own me %Master | timer 1 2 describe $chan I LOVE YOU %Master ! | timer 1 3 describe $chan Hugz %Master }
  64.   if ($1 == !adduser) { timer 1 1 auser User $address($2,3) | timer 1 2 notice $nick $2 3,4is now ON the USER List! | timer 1 3 notice $2 you are now a BOT USER On $me ! |
  65.  
  66. timer 1 4 descibe $chan has a cup of coffee with $2 }
  67.   if ($1 == !Mastercmds) { msg $nick Master Commands Are: !ban, !unban, !deMastertemp, !optemp, !deoptemp, !BotOff, !BotOn, !l, !kb, !accessa, !accessr, !invite, !restartbot, !
  68.  
  69. Mastertemp, !hop, !info, !adduser, !deluser, !Mastercmds, !moderate, !demoderate, !devoice, !voice, !deMastertemp, !hop, !info, and !notice. }
  70.   if ($1 == !ban) { cs ban $chan $2 3 }
  71.   if ($1 == !unban) { cs unban $chan $2 3 }
  72.   if ($1 == !deMastertemp $+) { mode $chan -q $2 }
  73.   if ($1 == !optemp $+) { mode $chan +o $2 }
  74.   if ($1 == !deoptemp $+) { mode $chan -o $2 }
  75.   if ($1 == !BotOff $+) { amsg 1,5 The Bot as been shut off by $nick Operations on this bot will not work if it is below the #BotScript Paremeter. | timer 1 2msg /disable
  76.  
  77. #BotScript }
  78.   if ($1 == !BotOn $+) { amsg 1,5The Bot has been re-enabled by $nick All Operations on this bot are now working below the #BotScript Parameter | timer 1 2 msg /enable
  79.  
  80. #BotScript }
  81.   if ($1 == !k) { kick $chan $2 $3- }
  82.   if ($1 == !kb) { cs ban $chan $2 3 | kick $chan $2 $3- }
  83.   if ($1 == !accessa $+) { if ($nick isop $chan) cs access $chan add $2 $3 | notice $2 Access level for $2 changed to $3 | notice $2 You can now press /ns update to update your
  84.  
  85. access. }
  86.   if ($1 == !accessr $+) { if ($nick isop $chan) cs access $chan del $2 | notice $2 Access level for $2 changed to $3. You have been removed from the access list. | notice $2
  87.  
  88. You can now press /ns update to update your access. }
  89.   if ($1 == !devoice) { mode $chan -v $2 }
  90.   if ($1 == !notice) { notice $2 $3 }
  91.   if ($1- == I am sorry $me) { timer 1 1 msg $chan It's ok. | timer 1 2 describe $chan Hugs %Master }
  92.   if ($1 == !voice) { mode $chan +v $2 }
  93.   if ($1 == !moderate) { mode $chan +m }
  94.   if ($1 == !demoderate) { mode $chan -m }
  95.   if ($1 == !invite) { invite $2 $chan }
  96.   if ($1 == !restartbot) { timer 1 1 /amsg Restarting Bot | timer 1 2 describe $chan leaves | timer -o 1 3 server %server | timer 1 4 describe $chan is fully booted up! }
  97.   if ($1- == I hate you iAdam) { timer 1 1 msg $chan Cries and Rolls on floor. What did I ever do to you?! | timer 1 2 hop $chan | timer 1 3 msg $chan I hate you too son of a
  98.  
  99. bitch! | timer 1 4 hop $chan | timer 1 5 describe $chan wait's for an apology. }
  100.   if ($1 == !Mastertemp $+) { mode $chan +q $2 }
  101.   if ($1 == !hop $+) { hop $chan }
  102.   if ($1 == !info $+) { timer 1 1 msg $chan Information for $me : I am a BOT. I run mIRC $version. My nick is $me . I am developed by EGO and cooler than service bots. I am very
  103.  
  104. mad that I can't continue developing myself. I am proud to have $Master as an Master! | timer 1 2 describe $chan Hugs $Master. | timer 1 3 describe $chan I LOVE YOU $Master! }  
  105. }
  106.  
  107. on *:TEXT:!guestbook:#: {
  108.   .timer1 1 1 notice $nick Guestbook v1.2 by ShAmPi
  109.   .timer2 1 2 notice $nick 12-----------------------------------------------------------
  110.   .timer3 1 3 notice $nick 7With this you can leave a message into the guestbook
  111.   .timer4 1 4 notice $nick 7Do NOT abuse this script!
  112.   .timer5 1 5 notice $nick 7The triggers should be typed in the channel the bot is in.
  113.   .timer6 1 6 notice $nick 7The triggers are shown below. Have fun
  114.   .timer7 1 7 notice $nick 12-----------------------------------------------------------
  115.   .timer8 1 8 notice $nick 7The commands are:
  116.   .timer9 1 9 notice $nick 4!writegb <message> - To leave a message in the guestbook
  117.   .timer10 1 9 notice $nick 4!viewgb - to view the guestbook messages
  118.   .timer11 1 11 notice $nick 12-----------------------------------------------------------
  119. }
  120.  
  121. on *:text:!viewgb:#:{
  122.   set %guestbook.c 1
  123.   /filter -c " $+ $mircdirguest.txt $+ " c:\lines.txt * $+ *
  124.   set %guestbook.total $filtered
  125.   while (%guestbook.c <= %guestbook.total) {
  126.     set %guestbook.msg $read($mircdirguest.txt, %guestbook.c)
  127.     set %gb.nick $gettok(%guestbook.msg,2,32)
  128.     set %gb.time $gettok(%guestbook.msg,1,32)
  129.     set %gb.hour $asctime(%gb.time , HH:nn:ss)
  130.     set %gb.date $asctime(%gb.time , dd/mm/yyyy)
  131.     set %gb.msg $gettok(%guestbook.msg,3-,32)
  132.     .timermsgguestbooknick $+ %guestbook.c $+ $nick 1 $calc( %guestbook.c * 2) .msg $nick 7[ $+ %gb.nick $+ 7]-[ $+ %gb.hour %gb.date $+ ]-7[ $+ %gb.msg $+ 7]
  133.     inc %guestbook.c
  134.   }
  135. }
  136.  
  137. on *:text:!writegb*:#:{
  138.   if ($2- != $null) {
  139.     /write -a " $+ $mircdirguest.txt $+ " $ctime $nick $2-
  140.     .notice $nick Your message ( $+ $2- $+ )
  141.     .notice $nick is succesfully submitted into the list!
  142.   }
  143.   else {
  144.     .notice $nick Please Fill in Your Message!
  145.   }
  146. }
  147.  
  148.  
  149. menu MenuBar {
  150.   -
  151.   Black Jack
  152.   .On:set %game on
  153.   ..Off:set %game off
  154.   ...Set Channel: set %chan $$?="Enter #channel name where you'd like to play
  155.   Black Jack, EG: #BlackJack"
  156. }
  157.  
  158. on *:text:!start:%chan: {
  159.   if %game == on {
  160.     msg $nick Please type 4!bet in main to add yourself into the next round
  161.     writeini bj.ini money $nick 100
  162.   }
  163.   else msg %chan 4Sorry no game in progress...
  164. }
  165.  
  166. on *:text:!bet:%chan: {
  167.   if %game == on {
  168.     entergame $nick
  169.   }
  170.   else msg %chan 4Sorry no game in progress...
  171. }
  172.  
  173. alias entergame {
  174.   if $readini(bj.ini , Bj , player1) == none {
  175.     if $readini(bj.ini,money, $nick) > 0 ) {
  176.       writeini bj.ini bj player1 $1
  177.       writeini bj.ini bj player1m $readini(bj.ini, money, $1 )
  178.       msg %chan 4 $+ $1 6added to this round4 3 6more player required!
  179.       writeini bj.ini money $nick $calc( $readini(bj.ini,money, $nick) - 1 )
  180.       msg $nick 6You have 4R $+ $readini(bj.ini,money, $nick) 6left
  181.       halt
  182.     }
  183.     else msg $nick 6Sorry but you have no more money left please type 4!start64 to reset your account!!!
  184.   }
  185.   elseif $readini(bj.ini , Bj , player2) == none {
  186.     if $readini(bj.ini,money, $nick) > 0 ) {
  187.       writeini bj.ini bj player2 $1
  188.       writeini bj.ini bj player2m $readini(bj.ini, money, $1 )
  189.       msg %chan 4 $+ $1 6added to this round4 2 6more player required!
  190.       halt
  191.     }
  192.     else msg $nick 6Sorry but you have no more money left please type 4!start6 to reset your account!!!
  193.   }
  194.   elseif $readini(bj.ini , Bj , player3) == none {
  195.     if $readini(bj.ini,money, $nick) > 0 ) {
  196.       writeini bj.ini bj player3 $1
  197.       writeini bj.ini bj player3m $readini(bj.ini, money, $1 )
  198.       msg %chan 4 $+ $1 6added to this round4 1 6more player required!
  199.       halt
  200.     }
  201.     else msg $nick 6Sorry but you have no more money left please type 4!start6 to reset your account!!!
  202.   }
  203.   elseif $readini(bj.ini , Bj , player4) == none {
  204.     if $readini(bj.ini,money, $nick) > 0 ) {
  205.       writeini bj.ini bj player4 $1
  206.       writeini bj.ini bj player4m $readini(bj.ini, money, $1 )
  207.       msg %chan 13Game full.. Game now starting.
  208.       deal
  209.       halt
  210.     }
  211.     else msg $nick 6Sorry but you have no more money left please type 4!start6 to reset your account!!!
  212.   }
  213.   else msg $1 4Sorry game is full!! please wait to enter the next game
  214. }
  215.  
  216. alias deal {
  217.   writeini bj.ini bj player1c1 % $+ $rand(1,13)
  218.   writeini bj.ini bj player1c2 % $+ $rand(1,13)
  219.   writeini bj.ini bj player2c1 % $+ $rand(1,13)
  220.   writeini bj.ini bj player2c2 % $+ $rand(1,13)
  221.   writeini bj.ini bj player3c1 % $+ $rand(1,13)
  222.   writeini bj.ini bj player3c2 % $+ $rand(1,13)
  223.   writeini bj.ini bj player4c1 % $+ $rand(1,13)
  224.   writeini bj.ini bj player4c2 % $+ $rand(1,13)
  225.   calc_hands
  226.   show_hands
  227. }
  228.  
  229. alias calc_hands {
  230.   if $readini(bj.ini , bj , player1c1) == 1 {
  231.     set %card1 1
  232.   }
  233.   if $readini(bj.ini, bj, player1c1) == 2 {
  234.     set %card1 2
  235.   }
  236.   if $readini(bj.ini, bj, player1c1) == 3 {
  237.     set %card1 3
  238.   }
  239.   if $readini(bj.ini, bj, player1c1) == 4 {
  240.     set %card1 4
  241.   }
  242.   if $readini(bj.ini, bj, player1c1) == 5 {
  243.     set %card1 5
  244.   }
  245.   if $readini(bj.ini, bj, player1c1) == 6 {
  246.     set %card1 6
  247.   }
  248.   if $readini(bj.ini, bj, player1c1) == 7 {
  249.     set %card1 7
  250.   }
  251.   if $readini(bj.ini, bj, player1c1) == 8 {
  252.     set %card1 8
  253.   }
  254.   if $readini(bj.ini, bj, player1c1) == 9 {
  255.     set %card1 9
  256.   }
  257.   if $readini(bj.ini, bj, player1c1) == 10 {
  258.     set %card1 10
  259.   }
  260.   if $readini(bj.ini, bj, player1c1) == 11 {
  261.     set %card1 10
  262.   }
  263.   if $readini(bj.ini, bj, player1c1) == 12 {
  264.     set %card1 10
  265.   }
  266.   if $readini(bj.ini, bj, player1c1) == 13 {
  267.     set %card1 10
  268.   }
  269.   if $readini(bj.ini, bj, player1c2) == 1 {
  270.     set %card2 1
  271.   }
  272.   if $readini(bj.ini, bj, player1c2) == 2 {
  273.     set %card2 2
  274.   }
  275.   if $readini(bj.ini, bj, player1c2) == 3 {
  276.     set %card2 3
  277.   }
  278.   if $readini(bj.ini, bj, player1c2) == 4 {
  279.     set %card2 4
  280.   }
  281.   if $readini(bj.ini, bj, player1c2) == 5 {
  282.     set %card2 5
  283.   }
  284.   if $readini(bj.ini, bj, player1c2) == 6 {
  285.     set %card2 6
  286.   }
  287.   if $readini(bj.ini, bj, player1c2) == 7 {
  288.     set %card2 7
  289.   }
  290.   if $readini(bj.ini, bj, player1c2) == 8 {
  291.     set %card2 8
  292.   }
  293.   if $readini(bj.ini, bj, player1c2) == 9 {
  294.     set %card2 9
  295.   }
  296.   if $readini(bj.ini, bj, player1c2) == 10 {
  297.     set %card2 10
  298.   }
  299.   if $readini(bj.ini, bj, player1c2) == 11 {
  300.     set %card2 10
  301.   }
  302.   if $readini(bj.ini, bj, player1c2) == 12 {
  303.     set %card2 10
  304.   }
  305.   if $readini(bj.ini, bj, player1c2) == 13 {
  306.     set %card2 10
  307.   }
  308.   if $readini(bj.ini, bj, player2c1) == 1 {
  309.     set %card3 1
  310.   }
  311.   if $readini(bj.ini, bj, player2c1) == 2 {
  312.     set %card3 2
  313.   }
  314.   if $readini(bj.ini, bj, player2c1) == 3 {
  315.     set %card3 3
  316.   }
  317.   if $readini(bj.ini, bj, player2c1) == 4 {
  318.     set %card3 4
  319.   }
  320.   if $readini(bj.ini, bj, player2c1) == 5 {
  321.     set %card3 5
  322.   }
  323.   if $readini(bj.ini, bj, player2c1) == 6 {
  324.     set %card3 6
  325.   }
  326.   if $readini(bj.ini, bj, player2c1) == 7 {
  327.     set %card3 7
  328.   }
  329.   if $readini(bj.ini, bj, player2c1) == 8 {
  330.     set %card3 8
  331.   }
  332.   if $readini(bj.ini, bj, player2c1) == 9 {
  333.     set %card3 9
  334.   }
  335.   if $readini(bj.ini, bj, player2c1) == 10 {
  336.     set %card3 10
  337.   }
  338.   if $readini(bj.ini, bj, player2c1) == 11 {
  339.     set %card3 10
  340.   }
  341.   if $readini(bj.ini, bj, player2c1) == 12 {
  342.     set %card3 10
  343.   }
  344.   if $readini(bj.ini, bj, player2c1) == 13 {
  345.     set %card3 10
  346.   }
  347.   if $readini(bj.ini, bj, player2c2) == 1 {
  348.     set %card4 1
  349.   }
  350.   if $readini(bj.ini, bj, player2c2) == 2 {
  351.     set %card4 2
  352.   }
  353.   if $readini(bj.ini, bj, player2c2) == 3 {
  354.     set %card4 3
  355.   }
  356.   if $readini(bj.ini, bj, player2c2) == 4 {
  357.     set %card4 4
  358.   }
  359.   if $readini(bj.ini, bj, player2c2) == 5 {
  360.     set %card4 5
  361.   }
  362.   if $readini(bj.ini, bj, player2c2) == 6 {
  363.     set %card4 6
  364.   }
  365.   if $readini(bj.ini, bj, player2c2) == 7 {
  366.     set %card4 7
  367.   }
  368.   if $readini(bj.ini, bj, player2c2) == 8 {
  369.     set %card4 8
  370.   }
  371.   if $readini(bj.ini, bj, player2c2) == 9 {
  372.     set %card4 9
  373.   }
  374.   if $readini(bj.ini, bj, player2c2) == 10 {
  375.     set %card4 10
  376.   }
  377.   if $readini(bj.ini, bj, player2c2) == 11 {
  378.     set %card4 10
  379.   }
  380.   if $readini(bj.ini, bj, player2c2) == 12 {
  381.     set %card4 10
  382.   }
  383.   if $readini(bj.ini, bj, player2c2) == 13 {
  384.     set %card4 10
  385.   }
  386.   if $readini(bj.ini, bj, player3c1) == 1 {
  387.     set %card5 1
  388.   }
  389.   if $readini(bj.ini, bj, player3c1) == 2 {
  390.     set %card5 2
  391.   }
  392.   if $readini(bj.ini, bj, player3c1) == 3 {
  393.     set %card5 3
  394.   }
  395.   if $readini(bj.ini, bj, player3c1) == 4 {
  396.     set %card5 4
  397.   }
  398.   if $readini(bj.ini, bj, player3c1) == 5 {
  399.     set %card5 5
  400.   }
  401.   if $readini(bj.ini, bj, player3c1) == 6 {
  402.     set %card5 6
  403.   }
  404.   if $readini(bj.ini, bj, player3c1) == 7 {
  405.     set %card5 7
  406.   }
  407.   if $readini(bj.ini, bj, player3c1) == 8 {
  408.     set %card5 8
  409.   }
  410.   if $readini(bj.ini, bj, player3c1) == 9 {
  411.     set %card5 9
  412.   }
  413.   if $readini(bj.ini, bj, player3c1) == 10 {
  414.     set %card5 10
  415.   }
  416.   if $readini(bj.ini, bj, player3c1) == 11 {
  417.     set %card5 10
  418.   }
  419.   if $readini(bj.ini, bj, player3c1) == 12 {
  420.     set %card5 10
  421.   }
  422.   if $readini(bj.ini, bj, player3c1) == 13 {
  423.     set %card5 10
  424.   }
  425.   if $readini(bj.ini, bj, player3c2) == 1 {
  426.     set %card6 1
  427.   }
  428.   if $readini(bj.ini, bj, player3c2) == 2 {
  429.     set %card6 2
  430.   }
  431.   if $readini(bj.ini, bj, player3c2) == 3 {
  432.     set %card6 3
  433.   }
  434.   if $readini(bj.ini, bj, player3c2) == 4 {
  435.     set %card6 4
  436.   }
  437.   if $readini(bj.ini, bj, player3c2) == 5 {
  438.     set %card6 5
  439.   }
  440.   if $readini(bj.ini, bj, player3c2) == 6 {
  441.     set %card6 6
  442.   }
  443.   if $readini(bj.ini, bj, player3c2) == 7 {
  444.     set %card6 7
  445.   }
  446.   if $readini(bj.ini, bj, player3c2) == 8 {
  447.     set %card6 8
  448.   }
  449.   if $readini(bj.ini, bj, player3c2) == 9 {
  450.     set %card6 9
  451.   }
  452.   if $readini(bj.ini, bj, player3c2) == 10 {
  453.     set %card6 10
  454.   }
  455.   if $readini(bj.ini, bj, player3c2) == 11 {
  456.     set %card6 10
  457.   }
  458.   if $readini(bj.ini, bj, player3c2) == 12 {
  459.     set %card6 10
  460.   }
  461.   if $readini(bj.ini, bj, player3c2) == 13 {
  462.     set %card6 10
  463.   }
  464.   if $readini(bj.ini, bj, player4c1) == 1 {
  465.     set %card7 1
  466.   }
  467.   if $readini(bj.ini, bj, player4c1) == 2 {
  468.     set %card7 2
  469.   }
  470.   if $readini(bj.ini, bj, player4c1) == 3 {
  471.     set %card7 3
  472.   }
  473.   if $readini(bj.ini, bj, player4c1) == 4 {
  474.     set %card7 4
  475.   }
  476.   if $readini(bj.ini, bj, player4c1) == 5 {
  477.     set %card7 5
  478.   }
  479.   if $readini(bj.ini, bj, player4c1) == 6 {
  480.     set %card7 6
  481.   }
  482.   if $readini(bj.ini, bj, player4c1) == 7 {
  483.     set %card7 7
  484.   }
  485.   if $readini(bj.ini, bj, player4c1) == 8 {
  486.     set %card7 8
  487.   }
  488.   if $readini(bj.ini, bj, player4c1) == 9 {
  489.     set %card7 9
  490.   }
  491.   if $readini(bj.ini, bj, player4c1) == 10 {
  492.     set %card7 10
  493.   }
  494.   if $readini(bj.ini, bj, player4c1) == 11 {
  495.     set %card7 10
  496.   }
  497.   if $readini(bj.ini, bj, player4c1) == 12 {
  498.     set %card7 10
  499.   }
  500.   if $readini(bj.ini, bj, player4c1) == 13 {
  501.     set %card7 10
  502.   }
  503.   if $readini(bj.ini, bj, player4c2) == 1 {
  504.     set %card8 1
  505.   }
  506.   if $readini(bj.ini, bj, player4c2) == 2 {
  507.     set %card8 2
  508.   }
  509.   if $readini(bj.ini, bj, player4c2) == 3 {
  510.     set %card8 3
  511.   }
  512.   if $readini(bj.ini, bj, player4c2) == 4 {
  513.     set %card8 4
  514.   }
  515.   if $readini(bj.ini, bj, player4c2) == 5 {
  516.     set %card8 5
  517.   }
  518.   if $readini(bj.ini, bj, player4c2) == 6 {
  519.     set %card8 6
  520.   }
  521.   if $readini(bj.ini, bj, player4c2) == 7 {
  522.     set %card8 7
  523.   }
  524.   if $readini(bj.ini, bj, player4c2) == 8 {
  525.     set %card8 8
  526.   }
  527.   if $readini(bj.ini, bj, player4c2) == 9 {
  528.     set %card8 9
  529.   }
  530.   if $readini(bj.ini, bj, player4c2) == 10 {
  531.     set %card8 10
  532.   }
  533.   if $readini(bj.ini, bj, player4c2) == 11 {
  534.     set %card8 10
  535.   }
  536.   if $readini(bj.ini, bj, player4c2) == 12 {
  537.     set %card8 10
  538.   }
  539.   if $readini(bj.ini, bj, player4c2) == 13 {
  540.     set %card8 10
  541.   }
  542.   set %player1 $calc( %card1 + %card2 )
  543.   set %player2 $calc( %card3 + %card4 )
  544.   set %player3 $calc( %card5 + %card6 )
  545.   set %player4 $calc( %card7 + %card8 )
  546. }
  547.  
  548. alias show_hands {
  549.   describe %chan Draws a(n)7 $readini(bj.ini,bj,player1c1) and places it   infront of9 $readini(bj.ini, bj,player1)
  550.   describe %chan Draws a(n)7 $readini(bj.ini,bj,player2c1) and places it  infront of9 $readini(bj.ini, bj,player2)
  551.   describe %chan Draws a(n)7 $readini(bj.ini,bj,player3c1) and places it  infront of9 $readini(bj.ini, bj,player3)
  552.   describe %chan Draws a(n)7 $readini(bj.ini,bj,player4c1) and places it  infront of9 $readini(bj.ini, bj,player4)
  553.   describe %chan Draws a(n)7 $readini(bj.ini,bj,player1c2) and places it  infront of9 $readini(bj.ini, bj,player1)
  554.   describe %chan Draws a(n)7 $readini(bj.ini,bj,player2c2) and places it  infront of9 $readini(bj.ini, bj,player2)
  555.   describe %chan Draws a(n)7 $readini(bj.ini,bj,player3c2) and places it   infront of9 $readini(bj.ini, bj,player3)
  556.   describe %chan Draws a(n)7 $readini(bj.ini,bj,player4c2) and places it   infront of9 $readini(bj.ini, bj,player4)
  557.   describe %chan Draws 2 cards for himself!!
  558.   msg %chan 4 $readini(bj.ini, bj,player1) has4 %player1
  559.   msg %chan 4 $readini(bj.ini, bj,player2) has4 %player2
  560.   msg %chan 4 $readini(bj.ini, bj,player3) has4 %player3
  561.   msg %chan 4 $readini(bj.ini, bj,player4) has4 %player4
  562.   writeini bj.ini BJ player1t %player1
  563.   writeini bj.ini BJ player2t %player2
  564.   writeini bj.ini BJ player3t %player3
  565.   writeini bj.ini BJ player4t %player4
  566.   set %dealer $rand(16,26)
  567.   set %bj 1
  568.   play_game
  569. }
  570.  
  571. alias play_game {
  572.   msg %chan 9 $readini(bj.ini , Bj , player $+ %bj ) It's your turn! Would  you like to 4hit or4 stand?
  573.   set %player $readini(bj.ini , Bj , player $+ %bj )
  574. }
  575.  
  576. on *:text:hit:%chan: {
  577.   if $nick == %player {
  578.     writeini bj.ini bj cardhit % $+ $rand(1,13)
  579.     describe %chan draws a(n)4 $readini(bj.ini, bj , cardhit)
  580.     if $readini(bj.ini , bj , cardhit) == %1 {
  581.       writeini BJ.ini BJ player $+ %bj $+ t $calc( $readini(BJ.ini, BJ, player $+ %bj $+ t ) + 1 )
  582.     }
  583.     if $readini(bj.ini , bj , cardhit) == %2 {
  584.       writeini BJ.ini BJ player $+ %bj $+ t $calc( $readini(BJ.ini , BJ, player $+ %bj $+ t ) + 2 )
  585.     }
  586.     if $readini(bj.ini , bj , cardhit) == %3 {
  587.       writeini BJ.ini BJ player $+ %bj $+ t $calc( $readini(BJ.ini , BJ, player $+ %bj $+ t ) + 3 )
  588.     }
  589.     if $readini(bj.ini , bj , cardhit) == %4 {
  590.       writeini BJ.ini BJ player $+ %bj $+ t $calc( $readini(BJ.ini , BJ, player $+ %bj $+ t ) + 4 )
  591.     }
  592.     if $readini(bj.ini , bj , cardhit) == %5 {
  593.       writeini BJ.ini BJ player $+ %bj $+ t $calc( $readini(BJ.ini , BJ, player $+ %bj $+ t ) + 5 )
  594.     }
  595.     if $readini(bj.ini , bj , cardhit) == %6 {
  596.       writeini BJ.ini BJ player $+ %bj $+ t $calc( $readini(BJ.ini , BJ, player $+ %bj $+ t ) + 6 )
  597.     }
  598.     if $readini(bj.ini , bj , cardhit) == %7 {
  599.       writeini BJ.ini BJ player $+ %bj $+ t $calc( $readini(BJ.ini , BJ, player $+ %bj $+ t ) + 7 )
  600.     }
  601.     if $readini(bj.ini , bj , cardhit) == %8 {
  602.       writeini BJ.ini BJ player $+ %bj $+ t $calc( $readini(BJ.ini , BJ, player $+ %bj $+ t ) + 8 )
  603.     }
  604.     if $readini(bj.ini , bj , cardhit) == %9 {
  605.       writeini BJ.ini BJ player $+ %bj $+ t $calc( $readini(BJ.ini , BJ, player $+ %bj $+ t ) + 9 )
  606.     }
  607.     if $readini(bj.ini , bj , cardhit) == %10 {
  608.       writeini BJ.ini BJ player $+ %bj $+ t $calc( $readini(BJ.ini , BJ, player $+ %bj $+ t ) + 10 )
  609.     }
  610.     if $readini(bj.ini , bj , cardhit) == %11 {
  611.       writeini BJ.ini BJ player $+ %bj $+ t $calc( $readini(BJ.ini , BJ, player $+ %bj $+ t ) + 10 )
  612.     }
  613.     if $readini(bj.ini , bj , cardhit) == %12 {
  614.       writeini BJ.ini BJ player $+ %bj $+ t $calc( $readini(BJ.ini , BJ, player $+ %bj $+ t ) + 10 )
  615.     }
  616.     if $readini(bj.ini , bj , cardhit) == %13 {
  617.       writeini BJ.ini BJ player $+ %bj $+ t $calc( $readini(BJ.ini , BJ, player $+ %bj $+ t ) + 10 )
  618.     }
  619.     msg %chan 6You now have4 $readini(BJ.ini, BJ, player $+ %bj $+ t )
  620.     if $readini(BJ.ini, BJ, player $+ %bj $+ t ) > 21 {
  621.       msg %chan 4sorry you've busted!!!
  622.       inc %bj
  623.       set %player $readini(bj.ini , bj , player $+ %bj )
  624.       if %player == $readini(bj.ini , bj , player1 ) {
  625.         msg %chan 6It is now9 $readini(bj.ini , Bj , player $+ %bj ) $+ 's 6turn..
  626.       }
  627.       if %player == $readini(bj.ini , bj , player2 ) {
  628.         msg %chan 6It is now9 $readini(bj.ini , Bj , player $+ %bj ) $+ 's 6turn..
  629.       }
  630.       if %player == $readini(bj.ini , bj , player3 ) {
  631.         msg %chan 6It is now9 $readini(bj.ini , Bj , player $+ %bj ) $+ 's 6turn..
  632.       }
  633.       if %player == $readini(bj.ini , bj , player4 ) {
  634.         msg %chan 6It is now9 $readini(bj.ini , Bj , player $+ %bj ) $+ 's 6turn..
  635.       }
  636.       elseif %player == $readini(bj.ini, bj, player5 ) {
  637.         end_game
  638.       }
  639.     }
  640.   }
  641. }
  642.  
  643. on *:text:stand:%chan: {
  644.   if $nick == %player {
  645.     msg %chan 6You have chosen to stand on4 $readini(bj.ini, BJ, player $+ %bj $+ t )
  646.     inc %bj
  647.     set %player $readini(bj.ini , bj , player $+ %bj )
  648.     if %player == $readini(bj.ini , bj , player1 ) {
  649.       msg %chan 6It is now9 $readini(bj.ini , Bj , player $+ %bj ) $+ 's 6turn..
  650.     }
  651.     if %player == $readini(bj.ini , bj , player2 ) {
  652.       msg %chan 6It is now9 $readini(bj.ini , Bj , player $+ %bj ) $+ 's 6turn..
  653.     }
  654.     if %player == $readini(bj.ini , bj , player3 ) {
  655.       msg %chan 6It is now9 $readini(bj.ini , Bj , player $+ %bj ) $+ 's 6turn..
  656.     }
  657.     if %player == $readini(bj.ini , bj , player4 ) {
  658.       msg %chan 6It is now9 $readini(bj.ini , Bj , player $+ %bj ) $+ 's 6turn..
  659.     }
  660.     elseif %player == $readini(bj.ini, bj, player5 ) {
  661.       end_game
  662.     }
  663.   }
  664. }
  665.  
  666. alias end_game {
  667.   describe %chan 6Turns over his cards and reveals4 %dealer
  668.   if %dealer > 21 {
  669.     msg %chan 4BUSTED
  670.     if ( ( $readini(bj.ini, BJ, player1t ) < 22 ) ) {
  671.       msg %chan $readini(bj.ini, bj, player1) wins
  672.       writeini bj.ini money $readini(bj.ini, bj, player1) $calc(
  673.       $readini(bj.ini, money, $readini(bj.ini, bj, player1)) + 3 )
  674.       msg $readini(bj.ini, bj, player1) 6You have now have $readini(bj.ini , money, $readini(bj.ini, bj, player1)
  675.     }
  676.     if ( ( $readini(bj.ini, BJ, player2t ) < 22 ) ) {
  677.       msg %chan $readini(bj.ini, bj, player2) wins
  678.       writeini bj.ini money $readini(bj.ini, bj, player2) $calc(
  679.       $readini(bj.ini, money, $readini(bj.ini, bj, player2)) + 3 )
  680.       msg $readini(bj.ini, bj, player2) 6You have now have $readini(bj.ini , money, $readini(bj.ini, bj, player2)
  681.     }
  682.     if ( ( $readini(bj.ini, BJ, player3t ) < 22 ) ) {
  683.       msg %chan $readini(bj.ini, bj, player3) wins
  684.       writeini bj.ini money $readini(bj.ini, bj, player3) $calc(
  685.       $readini(bj.ini, money, $readini(bj.ini, bj, player3)) + 3 )
  686.       msg $readini(bj.ini, bj, player3) 6You have now have $readini(bj.ini , money, $readini(bj.ini, bj, player3)
  687.     }
  688.     if ( ( $readini(bj.ini, BJ, player4t ) < 22 ) ) {
  689.       msg %chan $readini(bj.ini, bj, player4) wins
  690.       writeini bj.ini money $readini(bj.ini, bj, player4) $calc(
  691.       $readini(bj.ini, money, $readini(bj.ini, bj, player4)) + 3 )
  692.       msg $readini(bj.ini, bj, player4) 6You have now have $readini(bj.ini , money, $readini(bj.ini, bj, player4)
  693.     }
  694.   }
  695.   else {
  696.     msg %chan $readini(bj.ini, bj, player1) had $readini(bj.ini, BJ, player1t )
  697.     msg %chan $readini(bj.ini, bj, player2) had $readini(bj.ini, BJ, player2t )
  698.     msg %chan $readini(bj.ini, bj, player3) had $readini(bj.ini, BJ, player3t )
  699.     msg %chan $readini(bj.ini, bj, player4) had $readini(bj.ini, BJ, player4t )
  700.     if (( $readini(bj.ini, BJ, player1t ) > %dealer )) && (( $readini(bj.ini, BJ, player1t ) < 22 )) {
  701.       msg %chan $readini(bj.ini, bj, player1) wins
  702.       writeini bj.ini money $readini(bj.ini, bj, player1) $calc($readini(bj.ini, money, $readini(bj.ini, bj, player1)) + 3 )
  703.       msg $readini(bj.ini, bj, player1) 6You have now have $readini(bj.ini , money, $readini(bj.ini, bj, player1))
  704.     }
  705.     if (( $readini(bj.ini, BJ, player2t ) > %dealer )) && (($readini(bj.ini, BJ, player2t ) < 22 )) {
  706.       msg %chan $readini(bj.ini, bj, player2) wins
  707.       writeini bj.ini money $readini(bj.ini, bj, player2) $calc($readini(bj.ini, money, $readini(bj.ini, bj, player2)) + 3 )
  708.       msg $readini(bj.ini, bj, player2) 6You have now have $readini(bj.ini , money, $readini(bj.ini, bj, player2))
  709.     }
  710.     if (( $readini(bj.ini, BJ, player3t ) > %dealer )) && (($readini(bj.ini, BJ, player3t ) < 22 )) {
  711.       msg %chan $readini(bj.ini, bj, player3) wins
  712.       writeini bj.ini money $readini(bj.ini, bj, player3) $calc($readini(bj.ini, money, $readini(bj.ini, bj, player3)) + 3 )
  713.       msg $readini(bj.ini, bj, player3) 6You have now have $readini(bj.ini , money, $readini(bj.ini, bj, player3))
  714.     }
  715.     if (( $readini(bj.ini, BJ, player4t ) > %dealer )) && (($readini(bj.ini, BJ, player4t ) < 22 )) {
  716.       msg %chan $readini(bj.ini, bj, player4) wins
  717.       writeini bj.ini money $readini(bj.ini, bj, player4) $calc($readini(bj.ini, money, $readini(bj.ini, bj, player4)) + 3 )
  718.       msg $readini(bj.ini, bj, player4) 6You have now have $readini(bj.ini , money, $readini(bj.ini, bj, player4))
  719.     }
  720.   }
  721.   writeini bj.ini bj player1 none
  722.   writeini bj.ini bj player2 none
  723.   writeini bj.ini bj player3 none
  724.   writeini bj.ini bj player4 none
  725. }
  726.  
  727. on *:text:`reset:?: {
  728.   writeini bj.ini bj player1 none
  729.   writeini bj.ini bj player2 none
  730.   writeini bj.ini bj player3 none
  731.   writeini bj.ini bj player4 none
  732. }
  733.  
  734.  
  735.  
  736.  
  737. on *:TEXT:!txhelp:#:{
  738.    notice $nick ==============================
  739.    notice $nick script commends are:
  740.    notice $nick ==============================
  741.    notice $nick nlhe start - start script
  742.    notice $nick nlhe stop - stop script
  743.    notice $nick beggin - start the game
  744.    notice $nick add
  745.    notice $nick remove
  746.    notice $nick ===============================
  747.    notice $nick Other commends are:
  748.    notice $nick ===============================
  749.    notice $nick call
  750.    notice $nick raise
  751.    notice $nick bet
  752.    notice $nick fold
  753.    notice $nick check
  754.    notice $nick all in or allin
  755.    notice $nick sit out
  756.    notice $nick sit in
  757. }
  758.  
  759.  
  760.  
  761.  
  762.  
  763. on *:EXIT:{
  764.   unset %nlhe.#*
  765. }
  766.  
  767. alias nlhe.msg {
  768.   if (($me !ison $1) || (!$2)) return
  769.   var %delay = $iif(%nlhe.msgdelay != $null,%nlhe.msgdelay,1000)
  770.   inc %nlhe. [ $+ [ $1 ] $+ .msgtime ] %delay
  771.   .timer -do $+ $iif(%delay < 300,h,m) 1 [ %nlhe. [ $+ [ $1 ] $+ .msgtime ] ] dec % $+ nlhe. $+ $1 $+ .msgtime %delay $chr(124) msg $1 $iif(c isincs $gettok($chan
  772.  
  773. ($1).mode,1,32),$!strip( $2- ),$2-)
  774. }
  775. alias nlhe.notice {
  776.   if (($2 !ison $1) || (!$3)) return
  777.   var %delay = $iif(%nlhe.msgdelay != $null,%nlhe.msgdelay,1000)
  778.   inc %nlhe. [ $+ [ $1 ] $+ .msgtime ] %delay
  779.   .timer -do $+ $iif(%delay < 300,h,m) 1 [ %nlhe. [ $+ [ $1 ] $+ .msgtime ] ] dec % $+ nlhe. $+ $1 $+ .msgtime %delay $chr(124) $iif($2 == $me,echo -act notice,.notice $2) $1 >
  780.  
  781. $3-
  782. }
  783.  
  784. menu channel {
  785.   NLHE
  786.   .$iif($nlhe.menutest($chan),$iif([ %nlhe. [ $+ [ $chan ] $+ .regging ] ] || [ %nlhe. [ $+ [ $chan ] $+ .running ] ],re) $+ start NLHE game registration in $chan):{ nlhe.start
  787.  
  788. $chan }
  789.   .$iif([ %nlhe. [ $+ [ $chan ] $+ .regging ] ],commence NLHE game in $chan):{ nlhe.begin $chan }
  790.   .$iif([ %nlhe. [ $+ [ $chan ] $+ .regging ] ] || [ %nlhe. [ $+ [ $chan ] $+ .running ] ],stop NLHE game in $chan):{ nlhe.stop $chan }
  791.   .-
  792.   .$submenu($nlhe.setdefaults($1))
  793. }
  794. alias nlhe.menutest {
  795.   if (([ %nlhe. [ $+ [ $1 ] $+ .regging ] ]) || ([ %nlhe. [ $+ [ $1 ] $+ .running ] ])) {
  796.     if ([ %nlhe. [ $+ [ $1 ] $+ .cid ] ] == $cid) {
  797.       return 1
  798.     }
  799.   }
  800.   if (([ %nlhe. [ $+ [ $1 ] $+ .regging ] ] == $null) && ([ %nlhe. [ $+ [ $1 ] $+ .running ] ] == $null)) {
  801.     return 1
  802.   }
  803. }
  804. alias nlhe.setdefaults {
  805.   if ((!%nlhe.startblind) || (%nlhe.startblind < 2) || (2 \\ %nlhe.startblind)) { set %nlhe.startblind 50 }
  806.   if ((!%nlhe.startmoney) || (%nlhe.startmoney < 2) || (1 \\ %nlhe.startmoney)) { set %nlhe.startmoney 10000 }
  807.   if ((!%nlhe.timeblinds) || (%nlhe.timeblinds < 1) || (1 \\ %nlhe.timeblinds)) { set %nlhe.timeblinds 5 }
  808.   if ((!%nlhe.timetoact) || (%nlhe.timetoact < 15) || (1 \\ %nlhe.timetoact)) { set %nlhe.timetoact 60 }
  809.   if ((%nlhe.msgdelay == $null) || (%nlhe.msgdelay < 0) || (%nlhe.msgdelay > 3000) || (1 \\ %nlhe.msgdelay)) { set %nlhe.msgdelay 1000 }
  810.   var %p1 = starting money = %nlhe.startmoney
  811.   var %p2 = starting big blind = %nlhe.startblind
  812.   var %p3 = interval of raising the blinds = %nlhe.timeblinds mins
  813.   var %p4 = players' time to act = %nlhe.timetoact secs
  814.   var %p5 = message delay = %nlhe.msgdelay $+ ms
  815.   if ($1 == begin) return %p1 :{ nlhe.setdefaults sm }
  816.   if ($1 == 1) return %p2 :{ nlhe.setdefaults sb }
  817.   if ($1 == 2) return %p3 :{ nlhe.setdefaults tb }
  818.   if ($1 == 3) return %p4 :{ nlhe.setdefaults ta }
  819.   if ($1 == 4) return %p5 :{ nlhe.setdefaults md }
  820.   if ($1 == 5) return -
  821.   if ($1 == end) return $style(2) v1.02 created by Dav, 2007:{ }
  822.   if ($1 == sm) {
  823.     var %q = $input($chr(32),eo,Enter the starting money,%nlhe.startmoney)
  824.     if ((%q > 1) && (1 // %q)) set %nlhe.startmoney $calc(%q)
  825.   }
  826.   if ($1 == sb) {
  827.     var %q = $input(Enter an even number:,eo,Enter the starting big blind,%nlhe.startblind)
  828.     if ((%q > 1) && (2 // %q)) set %nlhe.startblind $calc(%q)
  829.   }
  830.   if ($1 == tb) {
  831.     var %q = $input(Enter the number of minutes between 1 and 120:,eo,Enter the time between raising of the blinds,%nlhe.timeblinds)
  832.     if ((%q > 0) && (1 // %q) && (%q <= 120)) {
  833.       set %nlhe.timeblinds $calc(%q)
  834.       var %tname = nlhe. $+ $active $+ .blinds
  835.       if (($timer(%tname).type == offline) && ([ %nlhe. [ $+ [ $active ] $+ .cid ] ] == $cid)) {
  836.         .timer $+ %tname off
  837.         .timer $+ %tname -o 0 $calc(%nlhe.timeblinds * 60) nlhe.raiseblinds $active
  838.       }
  839.     }
  840.   }
  841.   if ($1 == ta) {
  842.     var %q = $input(Enter the number of seconds between 15 and 300:,eo,Enter the time players have to act before they will automatically be sat out,%nlhe.timetoact)
  843.     if ((%q > 14) && (1 // %q) && (%q <= 300)) set %nlhe.timetoact $calc(%q)
  844.   }
  845.   if ($1 == md) {
  846.     var %q = $remove($input(Enter a number between 0 and 3000:,eo,Enter the message delay in ms,%nlhe.msgdelay $+ ms),ms,$chr(32))
  847.     if ((%q >= 0) && (1 // %q) && (%q <= 3000)) set %nlhe.msgdelay $calc(%q)
  848.   }
  849. }
  850.  
  851. on *:INPUT:#:{
  852.   if (([ %nlhe. [ $+ [ $chan ] $+ .regging ] ]) && ([ %nlhe. [ $+ [ $chan ] $+ .cid ] ] == $cid)) {
  853.     if (($1 == add) && (!$2)) {
  854.       nlhe.add $chan $nick
  855.     }
  856.     if ($1 == remove) {
  857.       if (!$2) {
  858.         nlhe.remove $chan $nick
  859.       }
  860.     }
  861.   }
  862.   if (([ %nlhe. [ $+ [ $chan ] $+ .running ] ]) && ([ %nlhe. [ $+ [ $chan ] $+ .turn ] ] == $nick) && ([ %nlhe. [ $+ [ $chan ] $+ .cid ] ] == $cid)) {
  863.     if ([ %nlhe. [ $+ [ $chan ] $+ . $+ [ $nick ] $+ .sitout ] ]) { nlhe.sitout $chan $nick in }
  864.     if (($1 == call) && (!$2)) {
  865.       nlhe.action $chan $nick call
  866.     }
  867.     if (($1 == raise) && ($2)) {
  868.       if (($iif($2 == to,$3,$2) < 1) || (1 \\ $iif($2 == to,$3,$2))) {
  869.         nlhe.notice $chan $nick Illegal raise. Use whole numbers only.
  870.         return
  871.       }
  872.       nlhe.action $chan $nick raise $2-
  873.     }
  874.     if (($1 == bet) && ($2)) {
  875.       if (($2 < 1) || (1 \\ $2)) {
  876.         nlhe.notice $chan $nick Illegal bet. Use whole numbers only.
  877.         return
  878.       }
  879.       nlhe.action $chan $nick bet $2
  880.     }
  881.     if (($1 == fold) && (!$2)) {
  882.       nlhe.action $chan $nick fold
  883.     }
  884.     if (($1 == check) && (!$2)) {
  885.       nlhe.action $chan $nick check
  886.     }
  887.     if (($1- == allin) || ($1- == all in)) {
  888.       nlhe.allin $chan $nick
  889.     }
  890.   }
  891.   if (([ %nlhe. [ $+ [ $chan ] $+ .running ] ]) && ([ %nlhe. [ $+ [ $chan ] $+ .cid ] ] == $cid)) {
  892.     if (($1 == remove) && ($2)) {
  893.       nlhe.removequitter $chan $2
  894.     }
  895.     if (($1 == add) && ($3)) {
  896.       nlhe.addnew $chan $2 $3
  897.     }
  898.     if (($1-2 == sit out) && (!$3)) {
  899.       nlhe.sitout $chan $nick out
  900.     }
  901.     if (($1-2 == sit in) && (!$3)) {
  902.       nlhe.sitout $chan $nick in
  903.     }
  904.     if (($1 == back) && (!$2)) {
  905.       nlhe.sitout $chan $nick in
  906.     }
  907.   }
  908. }
  909. on *:TEXT:add:#:{
  910.   if (([ %nlhe. [ $+ [ $chan ] $+ .regging ] ]) && ([ %nlhe. [ $+ [ $chan ] $+ .cid ] ] == $cid)) {
  911.     nlhe.add $chan $nick
  912.   }
  913. }
  914. on *:TEXT:remove*:#:{
  915.   if ([ %nlhe. [ $+ [ $chan ] $+ .cid ] ] == $cid) {
  916.     if ([ %nlhe. [ $+ [ $chan ] $+ .regging ] ]) {
  917.       nlhe.remove $chan $nick
  918.     }
  919.     elseif ($2) {
  920.       if ($2 !ison $chan) {
  921.         nlhe.removequitter $chan $2
  922.       }
  923.     }
  924.   }
  925. }
  926. on *:TEXT:nlhe start:#:{
  927.   if (([ %nlhe. [ $+ [ $chan ] $+ .regging ] ] == $null) && ([ %nlhe. [ $+ [ $chan ] $+ .running ] ] == $null)) {
  928.     nlhe.start $chan $nick
  929.   }
  930. }
  931. on *:TEXT:nlhe stop:#:{
  932.   if (([ %nlhe. [ $+ [ $chan ] $+ .regging ] ]) && ([ %nlhe. [ $+ [ $chan ] $+ .regging ] ] == $nick)) {
  933.     nlhe.stop $chan
  934.   }
  935. }
  936. on *:TEXT:begin:#:{
  937.   if (([ %nlhe. [ $+ [ $chan ] $+ .regging ] ]) && ([ %nlhe. [ $+ [ $chan ] $+ .regging ] ] != 1) && ($istok([ %nlhe. [ $+ [ $chan ] $+ .players ] ],$nick,32)) && (!$istok([
  938.  
  939. %nlhe. [ $+ [ $chan ] $+ .regging.begin ] ],$nick,32)) && ($numtok([ %nlhe. [ $+ [ $chan ] $+ .players ] ],32) > 1)) {
  940.     set %nlhe. [ $+ [ $chan ] $+ .regging.begin ] $addtok([ %nlhe. [ $+ [ $chan ] $+ .regging.begin ] ],$nick,32)
  941.     var %nump = $numtok([ %nlhe. [ $+ [ $chan ] $+ .players ] ],32)
  942.     var %numb = $numtok([ %nlhe. [ $+ [ $chan ] $+ .regging.begin ] ],32)
  943.     if ($calc(%numb / %nump) > 0.5) {
  944.       nlhe.begin $chan
  945.     }
  946.     else {
  947.       nlhe.msg $chan The game will begin when more than half of the players agree to begin.
  948.     }
  949.   }
  950. }
  951. on *:TEXT:call:#:{
  952.   if (([ %nlhe. [ $+ [ $chan ] $+ .running ] ]) && ([ %nlhe. [ $+ [ $chan ] $+ .turn ] ] == $nick) && ([ %nlhe. [ $+ [ $chan ] $+ .cid ] ] == $cid)) {
  953.     if ([ %nlhe. [ $+ [ $chan ] $+ . $+ [ $nick ] $+ .sitout ] ]) { unset %nlhe. [ $+ [ $chan ] $+ . $+ [ $nick ] $+ .sitout ] }
  954.     nlhe.action $chan $nick call
  955.   }
  956. }
  957. on *:TEXT:raise *:#:{
  958.   if (([ %nlhe. [ $+ [ $chan ] $+ .running ] ]) && ([ %nlhe. [ $+ [ $chan ] $+ .turn ] ] == $nick) && ([ %nlhe. [ $+ [ $chan ] $+ .cid ] ] == $cid)) {
  959.     if (($iif($2 == to,$3,$2) < 1) || (1 \\ $iif($2 == to,$3,$2))) {
  960.       nlhe.notice $chan $nick Illegal raise. Use whole numbers only.
  961.       return
  962.     }
  963.     if ([ %nlhe. [ $+ [ $chan ] $+ . $+ [ $nick ] $+ .sitout ] ]) { unset %nlhe. [ $+ [ $chan ] $+ . $+ [ $nick ] $+ .sitout ] }
  964.     nlhe.action $chan $nick raise $2-
  965.   }
  966. }
  967. on *:TEXT:bet *:#:{
  968.   if (([ %nlhe. [ $+ [ $chan ] $+ .running ] ]) && ([ %nlhe. [ $+ [ $chan ] $+ .turn ] ] == $nick) && ([ %nlhe. [ $+ [ $chan ] $+ .cid ] ] == $cid)) {
  969.     if (($2 < 1) || (1 \\ $2)) {
  970.       nlhe.notice $chan $nick Illegal bet. Use whole numbers only.
  971.       return
  972.     }
  973.     if ([ %nlhe. [ $+ [ $chan ] $+ . $+ [ $nick ] $+ .sitout ] ]) { unset %nlhe. [ $+ [ $chan ] $+ . $+ [ $nick ] $+ .sitout ] }
  974.     nlhe.action $chan $nick bet $2
  975.   }
  976. }
  977.  
  978. on *:TEXT:fold:#:{
  979.   if (([ %nlhe. [ $+ [ $chan ] $+ .running ] ]) && ([ %nlhe. [ $+ [ $chan ] $+ .turn ] ] == $nick) && ([ %nlhe. [ $+ [ $chan ] $+ .cid ] ] == $cid)) {
  980.     if ([ %nlhe. [ $+ [ $chan ] $+ . $+ [ $nick ] $+ .sitout ] ]) { unset %nlhe. [ $+ [ $chan ] $+ . $+ [ $nick ] $+ .sitout ] }
  981.     nlhe.action $chan $nick fold
  982.   }
  983. }
  984.  
  985. on *:TEXT:check:#:{
  986.   if (([ %nlhe. [ $+ [ $chan ] $+ .running ] ]) && ([ %nlhe. [ $+ [ $chan ] $+ .turn ] ] == $nick) && ([ %nlhe. [ $+ [ $chan ] $+ .cid ] ] == $cid)) {
  987.     if ([ %nlhe. [ $+ [ $chan ] $+ . $+ [ $nick ] $+ .sitout ] ]) { unset %nlhe. [ $+ [ $chan ] $+ . $+ [ $nick ] $+ .sitout ] }
  988.     nlhe.action $chan $nick check
  989.   }
  990. }
  991.  
  992. on *:TEXT:all in:#:{
  993.   if (([ %nlhe. [ $+ [ $chan ] $+ .running ] ]) && ([ %nlhe. [ $+ [ $chan ] $+ .turn ] ] == $nick) && ([ %nlhe. [ $+ [ $chan ] $+ .cid ] ] == $cid)) {
  994.     if ([ %nlhe. [ $+ [ $chan ] $+ . $+ [ $nick ] $+ .sitout ] ]) { unset %nlhe. [ $+ [ $chan ] $+ . $+ [ $nick ] $+ .sitout ] }
  995.     nlhe.allin $chan $nick
  996.   }
  997. }
  998.  
  999. on *:TEXT:allin:#:{
  1000.   if (([ %nlhe. [ $+ [ $chan ] $+ .running ] ]) && ([ %nlhe. [ $+ [ $chan ] $+ .turn ] ] == $nick) && ([ %nlhe. [ $+ [ $chan ] $+ .cid ] ] == $cid)) {
  1001.     if ([ %nlhe. [ $+ [ $chan ] $+ . $+ [ $nick ] $+ .sitout ] ]) { unset %nlhe. [ $+ [ $chan ] $+ . $+ [ $nick ] $+ .sitout ] }
  1002.     nlhe.allin $chan $nick
  1003.   }
  1004. }
  1005.  
  1006. on *:TEXT:sit out:#:{
  1007.   if (([ %nlhe. [ $+ [ $chan ] $+ .running ] ]) && ([ %nlhe. [ $+ [ $chan ] $+ .cid ] ] == $cid)) {
  1008.     nlhe.sitout $chan $nick out
  1009.   }
  1010. }
  1011.  
  1012. on *:TEXT:sit in:#:{
  1013.   if (([ %nlhe. [ $+ [ $chan ] $+ .running ] ]) && ([ %nlhe. [ $+ [ $chan ] $+ .cid ] ] == $cid)) {
  1014.     nlhe.sitout $chan $nick in
  1015.   }
  1016. }
  1017.  
  1018. on *:TEXT:back:#:{
  1019.   if (([ %nlhe. [ $+ [ $chan ] $+ .running ] ]) && ([ %nlhe. [ $+ [ $chan ] $+ .cid ] ] == $cid)) {
  1020.     nlhe.sitout $chan $nick in
  1021.   }
  1022. }
  1023.  
  1024. alias nlhe.start {
  1025.   if (($me ison $1) && (%nlhe.startmoney > 1) && (%nlhe.startblind > 1) && (1 // %nlhe.startmoney) && (2 // %nlhe.startblind)) {
  1026.     var %msgt = [ %nlhe. [ $+ [ $1 ] $+ .msgtime ] ]
  1027.     unset %nlhe. [ $+ [ $1 ] $+ .* ]
  1028.     hfree -w nlhe. $+ $1
  1029.     .timernlhe. $+ $1 $+ .blinds off
  1030.     .timernlhe. $+ $1 $+ .turn* off
  1031.     if (%msgt) { set %nlhe. [ $+ [ $1 ] $+ .msgtime ] %msgt }
  1032.     set %nlhe. [ $+ [ $1 ] $+ .regging ] $iif($2,$2,1)
  1033.     unset %nlhe. [ $+ [ $1 ] $+ .regging.begin ]
  1034.     set %nlhe. [ $+ [ $1 ] $+ .cid ] $cid
  1035.     nlhe.msg $chan A No Limit Hold'em poker game has been started in this chan. Type 'add' or 'remove' to register.
  1036.   }
  1037. }
  1038. alias nlhe.stop {
  1039.   if (($me ison $1) && (([ %nlhe. [ $+ [ $1 ] $+ .regging ] ]) || ([ %nlhe. [ $+ [ $1 ] $+ .running ] ]))) {
  1040.     var %msgt = [ %nlhe. [ $+ [ $1 ] $+ .msgtime ] ]
  1041.     unset %nlhe. [ $+ [ $1 ] $+ .* ]
  1042.     hfree -w nlhe. $+ $1
  1043.     .timernlhe. $+ $1 $+ .blinds off
  1044.     .timernlhe. $+ $1 $+ .turn* off
  1045.     if (%msgt) { set %nlhe. [ $+ [ $1 ] $+ .msgtime ] %msgt }
  1046.     nlhe.msg $chan The No Limit Hold'em poker game has been stopped.
  1047.   }
  1048. }
  1049. alias nlhe.begin {
  1050.   if (($me ison $1) && ([ %nlhe. [ $+ [ $1 ] $+ .cid ] ] == $cid) && ([ %nlhe. [ $+ [ $1 ] $+ .regging ] ]) && ($numtok([ %nlhe. [ $+ [ $1 ] $+ .players ] ],32) > 1)) {
  1051.     unset %nlhe. [ $+ [ $1 ] $+ .regging ]
  1052.     unset %nlhe. [ $+ [ $1 ] $+ .regging.begin ]
  1053.     set %nlhe. [ $+ [ $1 ] $+ .running ] 1
  1054.     set %nlhe. [ $+ [ $1 ] $+ .blind ] %nlhe.startblind
  1055.     var %i = 1
  1056.     while ($gettok([ %nlhe. [ $+ [ $1 ] $+ .players ] ],%i,32)) {
  1057.       set %nlhe. [ $+ [ $1 ] $+ . $+ [ $ifmatch ] ] %nlhe.startmoney
  1058.       inc %i
  1059.     }
  1060.     .timernlhe. $+ $1 $+ .blinds -o 0 $calc($iif(1 // %nlhe.timeblinds && %nlhe.timeblinds > 0,%nlhe.timeblinds,10) * 60) nlhe.raiseblinds $1
  1061.     nlhe.msg $chan The No Limit Hold'em poker game has commenced.
  1062.     set %nlhe. [ $+ [ $1 ] $+ .button ] $gettok([ %nlhe. [ $+ [ $1 ] $+ .players ] ],-1,32)
  1063.     nlhe.nextround $1
  1064.   }
  1065. }
  1066. alias nlhe.add {
  1067.   if (($2 ison $1) && (!$istok([ %nlhe. [ $+ [ $1 ] $+ .players ] ],$2,32)) && ([ %nlhe. [ $+ [ $1 ] $+ .regging ] ])) {
  1068.     if (($2 == blind) || ($2 == nextblind) || (allin*pot* iswm $2) || (playerspot* iswm $2) || (betpot* iswm $2) || ($2 == bb) || ($2 == allallin) || ($2 == cid) || ($2 == deck)
  1069.  
  1070. || ($2 == msgtime) || ($2 == sb) || ($2 == raiser) || ($2 == bet) || ($2 == players) || ($2 == running) || ($2 == regging) || ($2 == stage) || ($2 == turn) || ($2 == button)) {
  1071.       nlhe.msg $1  $+ $2 $+ : illegal nickname.
  1072.     }
  1073.     elseif ($numtok([ %nlhe. [ $+ [ $1 ] $+ .players ] ],32) > 9) {
  1074.       nlhe.notice $1 $2 Player limit has already been reached
  1075.     }
  1076.     else {
  1077.       set %nlhe. [ $+ [ $1 ] $+ .players ] [ %nlhe. [ $+ [ $1 ] $+ .players ] ] $2
  1078.       nlhe.notice $1 $2 Added. $iif([ %nlhe. [ $+ [ $1 ] $+ .regging ] ] != 1,Wait for other players to join and if you want to start the game type: 'begin'.)
  1079.       nlhe.msg $1 Current players:  $+ [ %nlhe. [ $+ [ $1 ] $+ .players ] ] $+ .
  1080.     }
  1081.   }
  1082. }
  1083. alias nlhe.addnew {
  1084.   if (($2 ison $1) && (1 // $3) && ($3 > 1) && (!$istok([ %nlhe. [ $+ [ $1 ] $+ .players ] ],$2,32)) && ([ %nlhe. [ $+ [ $1 ] $+ .running ] ])) {
  1085.     if (($2 == blind) || ($2 == nextblind) || (allin*pot* iswm $2) || (playerspot* iswm $2) || (betpot* iswm $2) || ($2 == bb) || ($2 == allallin) || ($2 == cid) || ($2 == deck)
  1086.  
  1087. || ($2 == msgtime) || ($2 == sb) || ($2 == raiser) || ($2 == bet) || ($2 == players) || ($2 == running) || ($2 == regging) || ($2 == stage) || ($2 == turn) || ($2 == button)) {
  1088.       return
  1089.     }
  1090.     elseif ($numtok([ %nlhe. [ $+ [ $1 ] $+ .players ] ],32) > 9) {
  1091.       return
  1092.     }
  1093.     else {
  1094.       set %nlhe. [ $+ [ $1 ] $+ .players ] [ %nlhe. [ $+ [ $1 ] $+ .players ] ] $2
  1095.       set %nlhe. [ $+ [ $1 ] $+ . $+ [ $2 ] ] $3
  1096.       nlhe.notice $1 $2 Added you with $ $+ $3 $+ .
  1097.       nlhe.msg $1  $+ $2 $+  has been manually added to the game by the host with $ $+ $3 $+ .
  1098.     }
  1099.   }
  1100. }
  1101. alias nlhe.remove {
  1102.   if (($2 ison $1) && ($istok([ %nlhe. [ $+ [ $1 ] $+ .players ] ],$2,32)) && ([ %nlhe. [ $+ [ $1 ] $+ .regging ] ])) {
  1103.     set %nlhe. [ $+ [ $1 ] $+ .players ] $remtok([ %nlhe. [ $+ [ $1 ] $+ .players ] ],$2,1,32)
  1104.     nlhe.notice $1 $2 Removed.
  1105.     nlhe.msg $1 Current players:  $+ $iif([ %nlhe. [ $+ [ $1 ] $+ .players ] ],[ %nlhe. [ $+ [ $1 ] $+ .players ] ],(none)) $+ .
  1106.   }
  1107. }
  1108. alias nlhe.removequitter {
  1109.   if (($istok([ %nlhe. [ $+ [ $1 ] $+ .players ] ],$2,32)) && ([ %nlhe. [ $+ [ $1 ] $+ .running ] ])) {
  1110.     if ([ %nlhe. [ $+ [ $1 ] $+ .turn ] ] != $2) {
  1111.       var %i = ""
  1112.       while ((%i < 10) || (!%i)) {
  1113.         var %cp = [ %nlhe. [ $+ [ $1 ] $+ .playerspot $+ [ %i ] ] ]
  1114.         if (%cp) {
  1115.           set %nlhe. [ $+ [ $1 ] $+ .playerspot $+ [ %i ] ] $remtok(%cp,$2,1,32)
  1116.         }
  1117.         inc %i
  1118.       }
  1119.       unset %nlhe. [ $+ [ $1 ] $+ . $+ [ $2 ] $+ .action ]
  1120.       set %nlhe. [ $+ [ $1 ] $+ . $+ [ $2 ] ] 0
  1121.       nlhe.msg $1  $+ $2 $+  has been forcibly removed from the game.
  1122.     }
  1123.   }
  1124. }
  1125. alias nlhe.sitout {
  1126.   if ($3) {
  1127.     if (($istok([ %nlhe. [ $+ [ $1 ] $+ .players ] ],$2,32)) && ([ %nlhe. [ $+ [ $1 ] $+ .running ] ])) {
  1128.       var %curr = [ %nlhe. [ $+ [ $1 ] $+ . $+ [ $2 ] $+ .sitout ] ]
  1129.       if (($3 == out) && (!%curr)) {
  1130.         set %nlhe. [ $+ [ $1 ] $+ . $+ [ $2 ] $+ .sitout ] 1
  1131.         if ([ %nlhe. [ $+ [ $1 ] $+ .turn ] ] == $2) {
  1132.           nlhe.action $1 $2 fold
  1133.         }
  1134.         nlhe.msg $1  $+ $2 is sitting out. $+ 
  1135.         nlhe.notice $1 $2 04You are sitting out. Type 'back' if you have returned.
  1136.       }
  1137.       if (($3 == in) && (%curr)) {
  1138.         nlhe.msg $1  $+ $2 is back in the game. $+ 
  1139.         nlhe.notice $1 $2 04You are back in the game.
  1140.         unset %nlhe. [ $+ [ $1 ] $+ . $+ [ $2 ] $+ .sitout ]
  1141.       }
  1142.     }
  1143.   }
  1144. }
  1145. alias nlhe.nxtblind {
  1146.   if ($1 isnum 2-) {
  1147.     var %o = $1, %osb = $round($calc(%o / 2),0), %n
  1148.     if (%o >= 1000) {
  1149.       var %div = 1 $+ $str(0,$calc($len(%o) - 3))
  1150.       %o = %o / %div
  1151.       %osb = %osb / %div
  1152.     }
  1153.     if (%o isnum 2-8) {
  1154.       %n = $round($calc((%o + %osb) / 2),0)
  1155.     }
  1156.     elseif (%o isnum 10-108) {
  1157.       %n = $calc($round($calc((%o + %osb) / 10),0) * 5)
  1158.     }
  1159.     elseif (%o isnum 110-282) {
  1160.       %n = $calc($round($calc((%o + %osb) / 50),0) * 25)
  1161.     }
  1162.     elseif (%o isnum 284-) {
  1163.       %n = $calc($round($calc((%o + %osb) / 200),0) * 100)
  1164.     }
  1165.     if (%div) {
  1166.       %n = %n * %div
  1167.     }
  1168.     if (%n) {
  1169.       var %nbb = %n * 2
  1170.     }
  1171.     return %nbb
  1172.   }
  1173. }
  1174. alias nlhe.raiseblinds {
  1175.   if ($1) {
  1176.     if (([ %nlhe. [ $+ [ $1 ] $+ .running ] ]) && ($me ison $1)) {
  1177.       var %cb = [ %nlhe. [ $+ [ $1 ] $+ .blind ] ]
  1178.       set %nlhe. [ $+ [ $1 ] $+ .nextblind ] $nlhe.nxtblind(%cb)
  1179.     }
  1180.     else {
  1181.       .timernlhe. $+ $1 $+ .blinds off
  1182.     }
  1183.   }
  1184. }
  1185. alias nlhe.nextp {
  1186.   if ($3) {
  1187.     var %allplist = [ %nlhe. [ $+ [ $1 ] $+ .players ] ], %plist = [ %nlhe. [ $+ [ $1 ] $+ .players $+ [ $2 ] ] ], %nump = $numtok(%allplist,32), %i = $findtok(%allplist,
  1188.  
  1189. $3,1,32)
  1190.     if ((%nump < 2) || (!%i)) { return $3 }
  1191.     inc %i
  1192.     if (%i > %nump) { %i = 1 }
  1193.     while (%i != $findtok(%allplist,$3,1,32)) {
  1194.       var %c = $gettok(%allplist,%i,32)
  1195.       if (([ %nlhe. [ $+ [ $1 ] $+ . $+ [ %c ] ] ] <= 0) || (!$findtok(%plist,%c,1,32))) {
  1196.         goto inc
  1197.       }
  1198.       return %c
  1199.       :inc
  1200.       inc %i
  1201.       if (%i > %nump) { %i = 1 }
  1202.     }
  1203.     return $3
  1204.   }
  1205. }
  1206. alias nlhe.prevp {
  1207.   if ($3) {
  1208.     var %allplist = [ %nlhe. [ $+ [ $1 ] $+ .players ] ], %plist = [ %nlhe. [ $+ [ $1 ] $+ .players $+ [ $2 ] ] ], %nump = $numtok(%allplist,32), %i = $findtok(%allplist,
  1209.  
  1210. $3,1,32)
  1211.     if ((%nump < 2) || (!%i)) { return $3 }
  1212.     dec %i
  1213.     if (%i < 1) { %i = %nump }
  1214.     while (%i != $findtok(%allplist,$3,1,32)) {
  1215.       var %c = $gettok(%allplist,%i,32)
  1216.       if (([ %nlhe. [ $+ [ $1 ] $+ . $+ [ %c ] ] ] <= 0) || (!$findtok(%plist,%c,1,32))) {
  1217.         goto dec
  1218.       }
  1219.       return %c
  1220.       :dec
  1221.       dec %i
  1222.       if (%i < 1) { %i = %nump }
  1223.     }
  1224.     return $3
  1225.   }
  1226. }
  1227. alias nlhe.cindex {
  1228.   return $mid(23456789TJQKA,$1,1)
  1229. }
  1230. alias nlhe.rcindex {
  1231.   return $pos(23456789TJQKA,$left($1,1),1)
  1232. }
  1233. alias nlhe.wordindex {
  1234.   var %c = $left($1,1)
  1235.   if (($len($1) > 1) && ($left($1,1) == $right($1,1))) { var %plur = 1 }
  1236.   if (%c == 2) { return Deuce $+ $iif(%plur,s) }
  1237.   if (%c == 3) { return Three $+ $iif(%plur,s) }
  1238.   if (%c == 4) { return Four $+ $iif(%plur,s) }
  1239.   if (%c == 5) { return Five $+ $iif(%plur,s) }
  1240.   if (%c == 6) { return Six $+ $iif(%plur,es) }
  1241.   if (%c == 7) { return Seven $+ $iif(%plur,s) }
  1242.   if (%c == 8) { return Eight $+ $iif(%plur,s) }
  1243.   if (%c == 9) { return Nine $+ $iif(%plur,s) }
  1244.   if (%c == T) { return Ten $+ $iif(%plur,s) }
  1245.   if (%c == J) { return Jack $+ $iif(%plur,s) }
  1246.   if (%c == Q) { return Queen $+ $iif(%plur,s) }
  1247.   if (%c == K) { return King $+ $iif(%plur,s) }
  1248.   if (%c == A) { return Ace $+ $iif(%plur,s) }
  1249. }
  1250. alias nlhe.sortrank {
  1251.   tokenize 32 $1-
  1252.   var %k = 13, %1 = $left($1,1), %2 = $left($2,1), %3 = $left($3,1), %4 = $left($4,1), %5 = $left($5,1), %6 = $left($6,1), %7 = $left($7,1), %cards = %1 %2 %3 %4 %5 %6 %7,
  1253.  
  1254. %remaining = %cards, %count = 1
  1255.   while (%k > 0) {
  1256.     if ($matchtok(%remaining,$nlhe.cindex(%k),0,32)) {
  1257.       var %result = %result $gettok($1-,$findtok(%cards,$nlhe.cindex(%k),%count,32),32)
  1258.       %remaining = $remtok(%remaining,$nlhe.cindex(%k),1,32)
  1259.       if ($prop == single) dec %k
  1260.       else inc %count
  1261.     }
  1262.     else {
  1263.       dec %k
  1264.       var %count = 1
  1265.     }
  1266.   }
  1267.   return %result
  1268. }
  1269.  
  1270. alias nlhe.ranking {
  1271.   tokenize 32 $1-
  1272.   var %1 = $left($1,1), %2 = $left($2,1), %3 = $left($3,1), %4 = $left($4,1), %5 = $left($5,1), %6 = $left($6,1), %7 = $left($7,1)
  1273.   var %suits = $right($1,1) $+ $right($2,1) $+ $right($3,1) $+ $right($4,1) $+ $right($5,1) $+ $right($6,1) $+ $right($7,1)
  1274.   var %cards = %1 %2 %3 %4 %5 %6 %7, %hand
  1275.   ;
  1276.   ; STRAIGHT FLUSH
  1277.   ;
  1278.   var %sorted = $nlhe.sortrank($1-)
  1279.   if ($count(%suits,c) >= 5) { var %flushsuit = c }
  1280.   if ($count(%suits,d) >= 5) { var %flushsuit = d }
  1281.   if ($count(%suits,h) >= 5) { var %flushsuit = h }
  1282.   if ($count(%suits,s) >= 5) { var %flushsuit = s }
  1283.   if (%flushsuit) {
  1284.     var %flushcards
  1285.     if ($right($gettok(%sorted,1,32),1) = %flushsuit) { %flushcards = %flushcards $left($gettok(%sorted,1,32),1) }
  1286.     if ($right($gettok(%sorted,2,32),1) = %flushsuit) { %flushcards = %flushcards $left($gettok(%sorted,2,32),1) }
  1287.     if ($right($gettok(%sorted,3,32),1) = %flushsuit) { %flushcards = %flushcards $left($gettok(%sorted,3,32),1) }
  1288.     if ($right($gettok(%sorted,4,32),1) = %flushsuit) { %flushcards = %flushcards $left($gettok(%sorted,4,32),1) }
  1289.     if ($right($gettok(%sorted,5,32),1) = %flushsuit) { %flushcards = %flushcards $left($gettok(%sorted,5,32),1) }
  1290.     if ($right($gettok(%sorted,6,32),1) = %flushsuit) { %flushcards = %flushcards $left($gettok(%sorted,6,32),1) }
  1291.     if ($right($gettok(%sorted,7,32),1) = %flushsuit) { %flushcards = %flushcards $left($gettok(%sorted,7,32),1) }
  1292.     %sorted = $nlhe.sortrank(%flushcards).single
  1293.     if ((A K Q J T isin %sorted) || (K Q J T 9 isin %sorted) || (Q J T 9 8 isin %sorted) || (J T 9 8 7 isin %sorted) || (T 9 8 7 6 isin %sorted) || (9 8 7 6 5 isin %sorted) ||
  1294.  
  1295. (8 7 6 5 4 isin %sorted) || (7 6 5 4 3 isin %sorted) || (6 5 4 3 2 isin %sorted) || ((A isin %sorted) && (5 4 3 2 isin %sorted))) {
  1296.       var %hand.strenght = 9, %kicker = $left($ifmatch,1)
  1297.       goto vl
  1298.     }
  1299.     else {
  1300.       %flushcards = ""
  1301.     }
  1302.   }
  1303.   %sorted = ""
  1304.   ;
  1305.   ; QUADS
  1306.   ;
  1307.   var %i = 0
  1308.   while (%i <= 13) {
  1309.     inc %i
  1310.     if ($matchtok(%cards,$nlhe.cindex(%i),0,32) == 4) {
  1311.       var %hand = $str($nlhe.cindex(%i),4), %hand.strenght = 8, %remaining = $1-
  1312.       if (%1 = $nlhe.cindex(%i)) { %remaining = $remtok(%remaining,$1,1,32) }
  1313.       if (%2 = $nlhe.cindex(%i)) { %remaining = $remtok(%remaining,$2,1,32) }
  1314.       if (%3 = $nlhe.cindex(%i)) { %remaining = $remtok(%remaining,$3,1,32) }
  1315.       if (%4 = $nlhe.cindex(%i)) { %remaining = $remtok(%remaining,$4,1,32) }
  1316.       if (%5 = $nlhe.cindex(%i)) { %remaining = $remtok(%remaining,$5,1,32) }
  1317.       if (%6 = $nlhe.cindex(%i)) { %remaining = $remtok(%remaining,$6,1,32) }
  1318.       if (%7 = $nlhe.cindex(%i)) { %remaining = $remtok(%remaining,$7,1,32) }
  1319.       var %j = 13
  1320.       while (%j > 0) {
  1321.         if ($matchtok(%remaining,$nlhe.cindex(%j),0,32)) {
  1322.           var %kicker = $nlhe.cindex(%j)
  1323.           goto vl
  1324.         }
  1325.         dec %j
  1326.       }
  1327.     }
  1328.   }
  1329.   ;
  1330.   ; FULL HOUSE
  1331.   ;
  1332.   var %sorted = $nlhe.sortrank(%cards), %i = 13
  1333.   while (%i > 0) {
  1334.     if ($matchtok(%sorted,$nlhe.cindex(%i),0,32) == 3) {
  1335.       var %hand = $str($nlhe.cindex(%i),3), %remaining = %sorted
  1336.       while ($findtok(%remaining,$nlhe.cindex(%i),0,32)) { %remaining = $remtok(%remaining,$nlhe.cindex(%i),1,32) }
  1337.       var %j = 13
  1338.       while (%j > 0) {
  1339.         if ($matchtok(%remaining,$nlhe.cindex(%j),0,32) >= 2) {
  1340.           var %kicker = $str($nlhe.cindex(%j),2), %hand.strenght = 7
  1341.           goto vl
  1342.         }
  1343.         dec %j
  1344.       }
  1345.       if (!%hand.strenght) {
  1346.         var %sorted = "", %hand = ""
  1347.       }
  1348.     }
  1349.     dec %i
  1350.   }
  1351.   ;
  1352.   ; FLUSH
  1353.   ;
  1354.   if ($count(%suits,c) >= 5) { var %flushsuit = c }
  1355.   if ($count(%suits,d) >= 5) { var %flushsuit = d }
  1356.   if ($count(%suits,h) >= 5) { var %flushsuit = h }
  1357.   if ($count(%suits,s) >= 5) { var %flushsuit = s }
  1358.   if (%flushsuit) {
  1359.     var %hand.strenght = 6, %flushcards
  1360.     if ($right($1,1) = %flushsuit) { %flushcards = %flushcards %1 }
  1361.     if ($right($2,1) = %flushsuit) { %flushcards = %flushcards %2 }
  1362.     if ($right($3,1) = %flushsuit) { %flushcards = %flushcards %3 }
  1363.     if ($right($4,1) = %flushsuit) { %flushcards = %flushcards %4 }
  1364.     if ($right($5,1) = %flushsuit) { %flushcards = %flushcards %5 }
  1365.     if ($right($6,1) = %flushsuit) { %flushcards = %flushcards %6 }
  1366.     if ($right($7,1) = %flushsuit) { %flushcards = %flushcards %7 }
  1367.     %hand = $remove($gettok($nlhe.sortrank(%flushcards),1-5,32),$chr(32))
  1368.     goto vl
  1369.   }
  1370.   ;
  1371.   ; STRAIGHT
  1372.   ;
  1373.   var %sorted = $nlhe.sortrank(%cards).single
  1374.   if ((A K Q J T isin %sorted) || (K Q J T 9 isin %sorted) || (Q J T 9 8 isin %sorted) || (J T 9 8 7 isin %sorted) || (T 9 8 7 6 isin %sorted) || (9 8 7 6 5 isin %sorted) || (8
  1375.  
  1376. 7 6 5 4 isin %sorted) || (7 6 5 4 3 isin %sorted) || (6 5 4 3 2 isin %sorted) || ((A isin %sorted) && (5 4 3 2 isin %sorted))) {
  1377.     var %hand.strenght = 5, %kicker = $left($ifmatch,1)
  1378.     goto vl
  1379.   }
  1380.   ;
  1381.   ; TRIPS
  1382.   ;
  1383.   var %sorted = $nlhe.sortrank(%cards), %i = 13
  1384.   while (%i > 0) {
  1385.     if ($matchtok(%sorted,$nlhe.cindex(%i),0,32) == 3) {
  1386.       var %hand = $str($nlhe.cindex(%i),3), %hand.strenght = 4, %remaining = %sorted
  1387.       while ($findtok(%remaining,$nlhe.cindex(%i),0,32)) { %remaining = $remtok(%remaining,$nlhe.cindex(%i),1,32) }
  1388.       var %kicker = $gettok(%remaining,1,32) $+ $gettok(%remaining,2,32)
  1389.       goto vl
  1390.     }
  1391.     dec %i
  1392.   }
  1393.   ;
  1394.   ; TWO PAIR
  1395.   ;
  1396.   var %i = 13, %remaining = %sorted
  1397.   while (%i > 0) {
  1398.     if ($matchtok(%sorted,$nlhe.cindex(%i),0,32) == 2) {
  1399.       var %hand = $str($nlhe.cindex(%i),2)
  1400.       while ($findtok(%remaining,$nlhe.cindex(%i),0,32)) { %remaining = $remtok(%remaining,$nlhe.cindex(%i),1,32) }
  1401.       var %j = 13
  1402.       while (%j > 0) {
  1403.         if ($matchtok(%remaining,$nlhe.cindex(%j),0,32) == 2) {
  1404.           var %hand = %hand $+ $str($nlhe.cindex(%j),2), %hand.strenght = 3
  1405.           while ($findtok(%remaining,$nlhe.cindex(%j),0,32)) { %remaining = $remtok(%remaining,$nlhe.cindex(%j),1,32) }
  1406.           var %kicker = $gettok(%remaining,1,32)
  1407.           goto vl
  1408.         }
  1409.         dec %j
  1410.       }
  1411.       ;
  1412.       ; PAIR
  1413.       ;
  1414.       var %hand.strenght = 2, %kicker = $gettok(%remaining,1,32) $+ $gettok(%remaining,2,32) $+ $gettok(%remaining,3,32)
  1415.       goto vl
  1416.     }
  1417.     dec %i
  1418.   }
  1419.   ;
  1420.   ; HIGH CARD
  1421.   ;
  1422.   var %hand.strenght = 1, %kicker = $remove($gettok(%sorted,1-5,32),$chr(32))
  1423.   :vl
  1424.   var %ret = %hand.strenght
  1425.   if (%hand) { %ret = $instok(%ret,%hand,2,46) }
  1426.   if (%kicker) { %ret = $instok(%ret,%kicker,3,46) }
  1427.   return %ret
  1428. }
  1429.  
  1430. alias nlhe.showdown {
  1431.   tokenize 32 $1-
  1432.   var %i = 0, %winner
  1433.   while (%i < $0) {
  1434.     inc %i
  1435.     var %p [ $+ [ %i ] ] [ $ $+ [ %i ] ]
  1436.     var %pp [ $+ [ %i ] ] 0
  1437.   }
  1438.   var %j = 10, %k = 9
  1439.   while (%j > 0) {
  1440.     if (%p [ $+ [ %j ] ]) {
  1441.       while (%k > 0) {
  1442.         if ($nlhe.value(%p [ $+ [ %j ] ],%p [ $+ [ %k ] ]) == 1) dec %pp [ $+ [ %k ] ]
  1443.         elseif ($nlhe.value(%p [ $+ [ %j ] ],%p [ $+ [ %k ] ]) == 2) dec %pp [ $+ [ %j ] ]
  1444.         dec %k
  1445.       }
  1446.     }
  1447.     dec %j
  1448.     %k = %j - 1
  1449.   }
  1450.   var %j = 10
  1451.   while (%j > 0) {
  1452.     if (%pp [ $+ [ %j ] ] == 0) {
  1453.       %winner = %j %winner
  1454.     }
  1455.     dec %j
  1456.   }
  1457.   return %winner
  1458. }
  1459.  
  1460. alias nlhe.value {
  1461.   var %1.rank = $gettok($1,1,46), %2.rank = $gettok($2,1,46), %1.hand = $gettok($1,2,46), %2.hand = $gettok($2,2,46), %1.kicker = $gettok($1,$iif($gettok($1,3,46),3,2),46),
  1462.  
  1463. %2.kicker = $gettok($2,$iif($gettok($2,3,46),3,2),46)
  1464.   if (%1.rank > %2.rank) return 1
  1465.   elseif (%1.rank == %2.rank) {
  1466.     if (%1.rank == 9) {
  1467.       if ($nlhe.rcindex(%1.kicker) > $nlhe.rcindex(%2.kicker)) return 1
  1468.       elseif ($nlhe.rcindex(%1.kicker) == $nlhe.rcindex(%2.kicker)) return 3
  1469.       else return 2
  1470.     }
  1471.     if ((%1.rank == 8) || (%1.rank == 7)) {
  1472.       if ($nlhe.rcindex(%1.hand) > $nlhe.rcindex(%2.hand)) return 1
  1473.       elseif ($nlhe.rcindex(%1.hand) == $nlhe.rcindex(%2.hand)) {
  1474.         if ($nlhe.rcindex(%1.kicker) > $nlhe.rcindex(%2.kicker)) return 1
  1475.         elseif ($nlhe.rcindex(%1.kicker) == $nlhe.rcindex(%2.kicker)) return 3
  1476.         else return 2
  1477.       }
  1478.       else return 2
  1479.     }
  1480.     if ((%1.rank == 6) || (%1.rank == 1)) {
  1481.       if ($nlhe.rcindex($mid(%1.hand,1,1)) == $nlhe.rcindex($mid(%2.hand,1,1))) {
  1482.         if ($nlhe.rcindex($mid(%1.hand,2,1)) == $nlhe.rcindex($mid(%2.hand,2,1))) {
  1483.           if ($nlhe.rcindex($mid(%1.hand,3,1)) == $nlhe.rcindex($mid(%2.hand,3,1))) {
  1484.             if ($nlhe.rcindex($mid(%1.hand,4,1)) == $nlhe.rcindex($mid(%2.hand,4,1))) {
  1485.               if ($nlhe.rcindex($mid(%1.hand,5,1)) == $nlhe.rcindex($mid(%2.hand,5,1))) {
  1486.                 return 3
  1487.               }
  1488.               elseif ($nlhe.rcindex($mid(%1.hand,5,1)) > $nlhe.rcindex($mid(%2.hand,5,1))) return 1
  1489.               else return 2
  1490.             }
  1491.             elseif ($nlhe.rcindex($mid(%1.hand,4,1)) > $nlhe.rcindex($mid(%2.hand,4,1))) return 1
  1492.             else return 2
  1493.           }
  1494.           elseif ($nlhe.rcindex($mid(%1.hand,3,1)) > $nlhe.rcindex($mid(%2.hand,3,1))) return 1
  1495.           else return 2
  1496.         }
  1497.         elseif ($nlhe.rcindex($mid(%1.hand,2,1)) > $nlhe.rcindex($mid(%2.hand,2,1))) return 1
  1498.         else return 2
  1499.       }
  1500.       elseif ($nlhe.rcindex($mid(%1.hand,1,1)) > $nlhe.rcindex($mid(%2.hand,1,1))) return 1
  1501.       else return 2
  1502.     }
  1503.     if (%1.rank == 5) {
  1504.       if ($nlhe.rcindex(%1.kicker) > $nlhe.rcindex(%2.kicker)) return 1
  1505.       elseif ($nlhe.rcindex(%1.kicker) == $nlhe.rcindex(%2.kicker)) return 3
  1506.       else return 2
  1507.     }
  1508.     if (%1.rank == 4) {
  1509.       if ($nlhe.rcindex(%1.hand) > $nlhe.rcindex(%2.hand)) return 1
  1510.       elseif ($nlhe.rcindex(%1.hand) == $nlhe.rcindex(%2.hand)) {
  1511.         if ($nlhe.rcindex(%1.kicker) > $nlhe.rcindex(%2.kicker)) return 1
  1512.         elseif ($nlhe.rcindex(%1.kicker) == $nlhe.rcindex(%2.kicker)) {
  1513.           if ($nlhe.rcindex($mid(%1.kicker,2,1)) > $nlhe.rcindex($mid(%2.kicker,2,1))) return 1
  1514.           elseif ($nlhe.rcindex($mid(%1.kicker,2,1)) == $nlhe.rcindex($mid(%2.kicker,2,1))) {
  1515.             return 3
  1516.           }
  1517.           else return 2
  1518.         }
  1519.         else return 2
  1520.       }
  1521.       else return 2
  1522.     }
  1523.     if (%1.rank == 3) {
  1524.       if ($nlhe.rcindex(%1.hand) > $nlhe.rcindex(%2.hand)) return 1
  1525.       elseif ($nlhe.rcindex(%1.hand) == $nlhe.rcindex(%2.hand)) {
  1526.         if ($nlhe.rcindex($mid(%1.hand,3,1)) > $nlhe.rcindex($mid(%2.hand,3,1))) return 1
  1527.         elseif ($nlhe.rcindex($mid(%1.hand,3,1)) == $nlhe.rcindex($mid(%2.hand,3,1))) {
  1528.           if ($nlhe.rcindex(%1.kicker) > $nlhe.rcindex(%2.kicker)) return 1
  1529.           elseif ($nlhe.rcindex(%1.kicker) == $nlhe.rcindex(%2.kicker)) {
  1530.             return 3
  1531.           }
  1532.           else return 2
  1533.         }
  1534.         else return 2
  1535.       }
  1536.       else return 2
  1537.     }
  1538.     if (%1.rank == 2) {
  1539.       if ($nlhe.rcindex(%1.hand) > $nlhe.rcindex(%2.hand)) return 1
  1540.       elseif ($nlhe.rcindex(%1.hand) == $nlhe.rcindex(%2.hand)) {
  1541.         if ($nlhe.rcindex(%1.kicker) > $nlhe.rcindex(%2.kicker)) return 1
  1542.         elseif ($nlhe.rcindex(%1.kicker) == $nlhe.rcindex(%2.kicker)) {
  1543.           if ($nlhe.rcindex($mid(%1.kicker,2,1)) > $nlhe.rcindex($mid(%2.kicker,2,1))) return 1
  1544.           elseif ($nlhe.rcindex($mid(%1.kicker,2,1)) == $nlhe.rcindex($mid(%2.kicker,2,1))) {
  1545.             if ($nlhe.rcindex($mid(%1.kicker,3,1)) > $nlhe.rcindex($mid(%2.kicker,3,1))) return 1
  1546.             elseif ($nlhe.rcindex($mid(%1.kicker,3,1)) == $nlhe.rcindex($mid(%2.kicker,3,1))) {
  1547.               return 3
  1548.             }
  1549.             else return 2
  1550.           }
  1551.           else return 2
  1552.         }
  1553.         else return 2
  1554.       }
  1555.       else return 2
  1556.     }
  1557.   }
  1558.   else return 2
  1559. }
  1560. alias nlhe.valuewords {
  1561.   var %rank = $gettok($1,1,46), %hand = $gettok($1,2,46), %kicker = $gettok($1,$iif($gettok($1,3,46),3,2),46), %line
  1562.   if (!%hand) return
  1563.   if ((%rank == 9) || (%rank == 5)) {
  1564.     %line = Straight $+ $iif(%rank == 9,$chr(32) $+ Flush) $+ $chr(44)
  1565.     var %to = $nlhe.wordindex(%kicker)
  1566.     if (%kicker == 5) {
  1567.       var %from = Ace
  1568.     }
  1569.     else {
  1570.       var %from = $nlhe.wordindex($nlhe.cindex($calc($nlhe.rcindex(%kicker) - 4)))
  1571.     }
  1572.     if ((%rank == 9) && (%kicker == A)) {
  1573.       return Royal Flush
  1574.     }
  1575.     return %line %from to %to
  1576.   }
  1577.   if (%rank == 8) {
  1578.     return Four Of A Kind $+ $chr(44) $nlhe.wordindex(%hand) + %kicker kicker
  1579.   }
  1580.   if (%rank == 7) {
  1581.     return Full House $+ $chr(44) $nlhe.wordindex(%hand) full of $nlhe.wordindex(%kicker)
  1582.   }
  1583.   if (%rank == 6) {
  1584.     return Flush $+ $chr(44) $nlhe.wordindex($left(%kicker,1)) high ( $+ %kicker $+ )
  1585.   }
  1586.   if (%rank == 4) {
  1587.     return Three Of A Kind $+ $chr(44) $nlhe.wordindex(%hand) + %kicker kickers
  1588.   }
  1589.   if (%rank == 3) {
  1590.     return Two Pair $+ $chr(44) $nlhe.wordindex($left(%hand,2)) over $nlhe.wordindex($right(%hand,2)) + %kicker kicker
  1591.   }
  1592.   if (%rank == 2) {
  1593.     return Pair of $nlhe.wordindex(%hand) $+  + %kicker kickers
  1594.   }
  1595.   if (%rank == 1) {
  1596.     return  $+ $nlhe.wordindex($left(%kicker,1)) High ( $+ %kicker $+ )
  1597.   }
  1598. }
  1599. alias nlhe.action {
  1600.   if ([ %nlhe. [ $+ [ $1 ] $+ .running ] ]) {
  1601.     var %amount, %currentmoney = [ %nlhe. [ $+ [ $1 ] $+ . $+ [ $2 ] ] ]
  1602.  
  1603.     if (([ %nlhe. [ $+ [ $1 ] $+ .allinpot ] ]) && ([ %nlhe. [ $+ [ $1 ] $+ . $+ [ $2 ] $+ .investedpot ] ] >= [ %nlhe. [ $+ [ $1 ] $+ .allinamountpot ] ])) {
  1604.       var %i = 0
  1605.       while (%i < 10) {
  1606.         inc %i
  1607.         var %cinvv = [ %nlhe. [ $+ [ $1 ] $+ . $+ [ $2 ] $+ .investedpot $+ [ %i ] ] ]
  1608.         var %cbett = $iif([ %nlhe. [ $+ [ $1 ] $+ .allinpot $+ [ %i ] ] ],[ %nlhe. [ $+ [ $1 ] $+ .allinamountpot $+ [ %i ] ] ],[ %nlhe. [ $+ [ $1 ] $+ .betpot $+ [ %i ] ] ])
  1609.         if (%cinvv < %cbett) {
  1610.           var %currentpot = pot $+ %i
  1611.           goto foundpot
  1612.         }
  1613.         elseif ((!%cbett) && (!%currentpot)) {
  1614.           var %currentpot = pot $+ %i
  1615.           goto foundpot
  1616.         }
  1617.         elseif ((%cinvv == %cbett) && (%cbett) && ([ %nlhe. [ $+ [ $1 ] $+ .allinpot $+ [ %i ] ] ] == $null)) {
  1618.           var %currentpot = pot $+ %i
  1619.         }
  1620.       }
  1621.     }
  1622.  
  1623.     if (!%currentpot) { var %currentpot = pot }
  1624.  
  1625.     :foundpot
  1626.  
  1627.     var %i = $iif($remove(%currentpot,pot),$remove(%currentpot,pot),0)
  1628.     while (%i < 10) {
  1629.       inc %i
  1630.       if ([ %nlhe. [ $+ [ $1 ] $+ .playerspot $+ [ %i ] ] ] == $null) {
  1631.         var %nextpot = pot $+ %i
  1632.         goto foundnextpot
  1633.       }
  1634.     }
  1635.     :foundnextpot
  1636.  
  1637.     if ($3 == sb) {
  1638.       %amount = [ %nlhe. [ $+ [ $1 ] $+ .blind ] ]
  1639.       %amount = $round($calc(%amount / 2),0)
  1640.       if (%currentmoney < %amount) {
  1641.         var %tp = %currentmoney
  1642.       }
  1643.       else {
  1644.         var %tp = %amount
  1645.       }
  1646.       set %nlhe. [ $+ [ $1 ] $+ .pot ] %tp
  1647.       set %nlhe. [ $+ [ $1 ] $+ . $+ [ $2 ] $+ .investedpot ] %tp
  1648.       dec %nlhe. [ $+ [ $1 ] $+ . $+ [ $2 ] ] %tp
  1649.  
  1650.       .timer -m 1 1 nlhe.action $1 [ %nlhe. [ $+ [ $1 ] $+ .bb ] ] bb
  1651.  
  1652.       if (%tp == %currentmoney) {
  1653.         set %nlhe. [ $+ [ $1 ] $+ .betpot ] %tp
  1654.         set %nlhe. [ $+ [ $1 ] $+ . $+ [ $2 ] $+ .action ] raise
  1655.         set %nlhe. [ $+ [ $1 ] $+ .raiser ] $2
  1656.  
  1657.         set %nlhe. [ $+ [ $1 ] $+ .allinamountpot ] %tp
  1658.         set %nlhe. [ $+ [ $1 ] $+ .allinpot ] $2
  1659.  
  1660.         nlhe.msg $1  $+ $2 $+  goes all in in the small blind for $ $+ %tp $+ .
  1661.         return
  1662.       }
  1663.       else {
  1664.         nlhe.msg $1  $+ $2 $+  posts the small blind of $ $+ %tp $+ .
  1665.       }
  1666.     }
  1667.     if ($3 == bb) {
  1668.       if ([ %nlhe. [ $+ [ $1 ] $+ .allinamountpot ] ]) {
  1669.         var %sbamount = $ifmatch, %amount = [ %nlhe. [ $+ [ $1 ] $+ .blind ] ], %tp = $calc(%amount - %sbamount)
  1670.         if (%tp) {
  1671.           set %nlhe. [ $+ [ $1 ] $+ .betpot1 ] %tp
  1672.         }
  1673.         if (%currentmoney < %amount) {
  1674.           nlhe.msg $1  $+ $2 $+  posts $ $+ %currentmoney $+  of the big blind.
  1675.         }
  1676.         else {
  1677.           nlhe.msg $1  $+ $2 $+  posts the big blind of $ $+ %amount $+ .
  1678.         }
  1679.         .timer -m 1 1 nlhe.action $1 $2 call silent
  1680.         return
  1681.       }
  1682.       %amount = [ %nlhe. [ $+ [ $1 ] $+ .blind ] ]
  1683.       if (%currentmoney < %amount) {
  1684.         var %tp = %currentmoney
  1685.       }
  1686.       else {
  1687.         var %tp = %amount
  1688.       }
  1689.  
  1690.       if (%tp == %currentmoney) {
  1691.         var %mpot = [ %nlhe. [ $+ [ $1 ] $+ .pot ] ], %sblind = [ %nlhe. [ $+ [ $1 ] $+ .sb ] ]
  1692.         if ((%mpot > %tp) && ($nlhe.nextp($1,pot,%sblind) != %sblind)) {
  1693.           set %nlhe. [ $+ [ $1 ] $+ .pot ] $calc(%tp * 2)
  1694.           set %nlhe. [ $+ [ $1 ] $+ .pot1 ] $calc(%mpot - %tp)
  1695.           set %nlhe. [ $+ [ $1 ] $+ . $+ [ $2 ] $+ .investedpot ] %tp
  1696.           set %nlhe. [ $+ [ $1 ] $+ . $+ [ %sblind ] $+ .investedpot ] %tp
  1697.           set %nlhe. [ $+ [ $1 ] $+ . $+ [ %sblind ] $+ .investedpot1 ] $calc(%mpot - %tp)
  1698.           set %nlhe. [ $+ [ $1 ] $+ .playerspot1 ] [ %nlhe. [ $+ [ $1 ] $+ .sb ] ]
  1699.           dec %nlhe. [ $+ [ $1 ] $+ . $+ [ $2 ] ] %tp
  1700.         }
  1701.         else {
  1702.           inc %nlhe. [ $+ [ $1 ] $+ .pot ] %tp
  1703.           set %nlhe. [ $+ [ $1 ] $+ . $+ [ $2 ] $+ .investedpot ] %tp
  1704.           dec %nlhe. [ $+ [ $1 ] $+ . $+ [ $2 ] ] %tp
  1705.         }
  1706.         set %nlhe. [ $+ [ $1 ] $+ .betpot ] %tp
  1707.         if ($nlhe.nextp($1,pot,%sblind) != %sblind) {
  1708.           var %betnewpot = $calc(%nlhe. [ $+ [ $1 ] $+ .blind ] - %tp)
  1709.           if (%betnewpot) { set %nlhe. [ $+ [ $1 ] $+ .betpot1 ] %betnewpot }
  1710.         }
  1711.         set %nlhe. [ $+ [ $1 ] $+ . $+ [ $2 ] $+ .action ] raise
  1712.         set %nlhe. [ $+ [ $1 ] $+ .raiser ] $2
  1713.  
  1714.         set %nlhe. [ $+ [ $1 ] $+ .allinamountpot ] %tp
  1715.         set %nlhe. [ $+ [ $1 ] $+ .allinpot ] $2
  1716.  
  1717.         nlhe.msg $1  $+ $2 $+  goes all in in the big blind for $ $+ %tp $+ .
  1718.         .timer -m 1 1 nlhe.nextturn $1
  1719.         return
  1720.       }
  1721.       else {
  1722.         inc %nlhe. [ $+ [ $1 ] $+ .pot ] %tp
  1723.         set %nlhe. [ $+ [ $1 ] $+ . $+ [ $2 ] $+ .investedpot ] %tp
  1724.         dec %nlhe. [ $+ [ $1 ] $+ . $+ [ $2 ] ] %tp
  1725.         set %nlhe. [ $+ [ $1 ] $+ .betpot ] %amount
  1726.         nlhe.msg $1  $+ $2 $+  posts the big blind of $ $+ %amount $+ .
  1727.         .timer -m 1 1 nlhe.nextturn $1
  1728.       }
  1729.     }
  1730.     if ($3 == call) {
  1731.       if ($5 != $null) {
  1732.         var %currentpot = $4, %tb = [ %nlhe. [ $+ [ $1 ] $+ .bet $+ [ %currentpot ] ] ], %ti = [ %nlhe. [ $+ [ $1 ] $+ . $+ [ $2 ] $+ .invested $+ [ %currentpot ] ] ]
  1733.         %tb = $iif([ %nlhe. [ $+ [ $1 ] $+ .allin $+ [ %currentpot ] ] ],[ %nlhe. [ $+ [ $1 ] $+ .allinamount $+ [ %currentpot ] ] ],[ %nlhe. [ $+ [ $1 ] $+ .bet $+ [
  1734.  
  1735. %currentpot ] ] ])
  1736.         if (%currentmoney < $5) {
  1737.           var %tp = %currentmoney
  1738.         }
  1739.         else {
  1740.           var %tp = $5
  1741.         }
  1742.         var %tx = $calc(%tp + %ti)
  1743.         if (%tp != $5) {
  1744.           ; TO CALL ALL IN
  1745.           var %i = 1, %plist = [ %nlhe. [ $+ [ $1 ] $+ .players $+ [ %currentpot ] ] ], %allinamount = %tx
  1746.           while ($gettok(%plist,%i,32)) {
  1747.             var %c = $ifmatch, %invv = [ %nlhe. [ $+ [ $1 ] $+ . $+ [ %c ] $+ .invested $+ [ %currentpot ] ] ]
  1748.             if ((%c != $2) && (%invv >= %tx)) {
  1749.               var %split = $calc(%split + (%invv - %tx))
  1750.               set %nlhe. [ $+ [ $1 ] $+ . $+ [ %c ] $+ .invested $+ [ %currentpot ] ] %tx
  1751.               if (%c != $2) {
  1752.                 set %nlhe. [ $+ [ $1 ] $+ . $+ [ %c ] $+ .invested $+ [ %nextpot ] ] $calc(%invv - %allinamount)
  1753.                 set %nlhe. [ $+ [ $1 ] $+ .players $+ [ %nextpot ] ] $addtok([ %nlhe. [ $+ [ $1 ] $+ .players $+ [ %nextpot ] ] ],%c,32)
  1754.               }
  1755.             }
  1756.             inc %i
  1757.           }
  1758.           var %cpamount = [ %nlhe. [ $+ [ $1 ] $+ . $+ [ %currentpot ] ] ]
  1759.           set %nlhe. [ $+ [ $1 ] $+ .players $+ [ %currentpot ] ] $addtok([ %nlhe. [ $+ [ $1 ] $+ .players $+ [ %currentpot ] ] ],$2,32)
  1760.           set %nlhe. [ $+ [ $1 ] $+ . $+ [ %currentpot ] ] $calc(%cpamount + %tp - %split)
  1761.           set %nlhe. [ $+ [ $1 ] $+ . $+ [ %nextpot ] ] %split
  1762.           if ([ %nlhe. [ $+ [ $1 ] $+ .allinamount $+ [ %currentpot ] ] ]) {
  1763.             set %nlhe. [ $+ [ $1 ] $+ .allinamount $+ [ %nextpot ] ] $calc(%tb - %tx)
  1764.           }
  1765.           if ([ %nlhe. [ $+ [ $1 ] $+ .allin $+ [ %currentpot ] ] ]) {
  1766.             set %nlhe. [ $+ [ $1 ] $+ .allin $+ [ %nextpot ] ] $ifmatch
  1767.           }
  1768.           set %nlhe. [ $+ [ $1 ] $+ .allinamount $+ [ %currentpot ] ] %tx
  1769.           set %nlhe. [ $+ [ $1 ] $+ .bet $+ [ %currentpot ] ] %tx
  1770.           set %nlhe. [ $+ [ $1 ] $+ .bet $+ [ %nextpot ] ] $calc(%tb - %tx)
  1771.         }
  1772.         else {
  1773.           set %nlhe. [ $+ [ $1 ] $+ .players $+ [ %currentpot ] ] $addtok([ %nlhe. [ $+ [ $1 ] $+ .players $+ [ %currentpot ] ] ],$2,32)
  1774.           inc %nlhe. [ $+ [ $1 ] $+ . $+ [ %currentpot ] ] %tp
  1775.         }
  1776.  
  1777.         inc %nlhe. [ $+ [ $1 ] $+ . $+ [ $2 ] $+ .invested $+ [ %currentpot ] ] %tp
  1778.         dec %nlhe. [ $+ [ $1 ] $+ . $+ [ $2 ] ] %tp
  1779.         set %nlhe. [ $+ [ $1 ] $+ . $+ [ $2 ] $+ .action ] call
  1780.         if (([ %nlhe. [ $+ [ $1 ] $+ .raiser ] ] != $2) && ($7 != silent)) {
  1781.           nlhe.msg $1  $+ $2 $+  calls +$ $+ %tp $+  $+ $iif($4 != pot,$chr(32) $+ into side pot $remove($4,pot) $+ .,.)
  1782.         }
  1783.         if ($6) {
  1784.           if ([ %nlhe. [ $+ [ $1 ] $+ .raiser ] ] != $2) {
  1785.             .timer -m 1 1 nlhe.nextturn $1
  1786.           }
  1787.           else {
  1788.             .timer -m 1 1 nlhe.action $1 $2 bet [ %nlhe. [ $+ [ $1 ] $+ . $+ [ $2 ] $+ .raiseamount ] ]
  1789.           }
  1790.         }
  1791.       }
  1792.       else {
  1793.         var %xbet = [ %nlhe. [ $+ [ $1 ] $+ .bet $+ [ %currentpot ] ] ], %xinv = [ %nlhe. [ $+ [ $1 ] $+ . $+ [ $2 ] $+ .invested $+ [ %currentpot ] ] ]
  1794.         if (%xinv == $null) { %xinv = 0 }
  1795.         if ((%xbet != $null) && (%xinv < %xbet)) {
  1796.           var %i = $remove(%currentpot,pot), %amount = 0
  1797.           if (!%i) { %i = "" }
  1798.           while ((%i < 10) || (!%i)) {
  1799.             var %cinvv = [ %nlhe. [ $+ [ $1 ] $+ . $+ [ $2 ] $+ .investedpot $+ [ %i ] ] ]
  1800.             var %cbett = $iif([ %nlhe. [ $+ [ $1 ] $+ .allinpot $+ [ %i ] ] ],[ %nlhe. [ $+ [ $1 ] $+ .allinamountpot $+ [ %i ] ] ],[ %nlhe. [ $+ [ $1 ] $+ .betpot $+ [ %i ] ]
  1801.  
  1802. ])
  1803.             if (%cinvv < %cbett) {
  1804.               var %amount = $calc(%amount + %cbett - %cinvv)
  1805.               var %lastamount = %i
  1806.               if (%amount >= %currentmoney) { %i = 11 }
  1807.             }
  1808.             inc %i
  1809.           }
  1810.           var %i = $remove(%currentpot,pot), %amount = 0
  1811.           if (!%i) { %i = "" }
  1812.           while ((%i < 10) || (!%i)) {
  1813.             var %cinvv = [ %nlhe. [ $+ [ $1 ] $+ . $+ [ $2 ] $+ .investedpot $+ [ %i ] ] ]
  1814.             var %cbett = $iif([ %nlhe. [ $+ [ $1 ] $+ .allinpot $+ [ %i ] ] ],[ %nlhe. [ $+ [ $1 ] $+ .allinamountpot $+ [ %i ] ] ],[ %nlhe. [ $+ [ $1 ] $+ .betpot $+ [ %i ] ]
  1815.  
  1816. ])
  1817.             if (%cinvv < %cbett) {
  1818.               var %amount = $calc(%amount + %cbett - %cinvv)
  1819.               .timer -h 1 $calc(10 * %i + 1) nlhe.action $1 $2 call pot $+ %i $calc(%cbett - %cinvv) $iif(%lastamount = %i,1,0) $iif($4 == silent,silent)
  1820.               if (%amount >= %currentmoney) { %i = 11 }
  1821.             }
  1822.             inc %i
  1823.           }
  1824.           if (!%amount) {
  1825.             var %amount = $calc(%xbet - %xinv)
  1826.             .timer -m 1 1 nlhe.action $1 $2 call %currentpot %amount 1
  1827.           }
  1828.         }
  1829.         elseif ([ %nlhe. [ $+ [ $1 ] $+ .raiser ] ] == $2) {
  1830.           .timer -m 1 1 nlhe.action $1 $2 bet [ %nlhe. [ $+ [ $1 ] $+ . $+ [ $2 ] $+ .raiseamount ] ]
  1831.         }
  1832.         else {
  1833.           nlhe.notice $1 $2 There is nothing to call.
  1834.         }
  1835.       }
  1836.     }
  1837.     if ($3 == bet) {
  1838.       if (([ %nlhe. [ $+ [ $1 ] $+ .bet $+ [ %currentpot ] ] ]) && ([ %nlhe. [ $+ [ $1 ] $+ .raiser ] ] != $2)) {
  1839.         nlhe.notice $1 $2 You can't bet here.
  1840.         return
  1841.       }
  1842.       elseif ([ %nlhe. [ $+ [ $1 ] $+ .raiser ] ] == $null) {
  1843.         if (($4 < [ %nlhe. [ $+ [ $1 ] $+ .blind ] ]) && ($4 < %currentmoney)) {
  1844.           nlhe.notice $1 $2 You must at bet at least the big blind: $ $+ [ %nlhe. [ $+ [ $1 ] $+ .blind ] ] $+ .
  1845.           return
  1846.         }
  1847.       }
  1848.       if (%currentmoney < $4) {
  1849.         var %tp = %currentmoney
  1850.       }
  1851.       else {
  1852.         var %tp = $4
  1853.       }
  1854.       set %nlhe. [ $+ [ $1 ] $+ .players $+ [ %currentpot ] ] $addtok([ %nlhe. [ $+ [ $1 ] $+ .players $+ [ %currentpot ] ] ],$2,32)
  1855.       inc %nlhe. [ $+ [ $1 ] $+ . $+ [ %currentpot ] ] %tp
  1856.       inc %nlhe. [ $+ [ $1 ] $+ .bet $+ [ %currentpot ] ] %tp
  1857.       inc %nlhe. [ $+ [ $1 ] $+ . $+ [ $2 ] $+ .invested $+ [ %currentpot ] ] %tp
  1858.       dec %nlhe. [ $+ [ $1 ] $+ . $+ [ $2 ] ] %tp
  1859.       unset %nlhe. [ $+ [ $1 ] $+ .*.action ]
  1860.       set %nlhe. [ $+ [ $1 ] $+ . $+ [ $2 ] $+ .action ] raise
  1861.  
  1862.       if ([ %nlhe. [ $+ [ $1 ] $+ .raiser ] ] != $2) {
  1863.         nlhe.msg $1  $+ $2 $+  bets $ $+ %tp $+  $+ $iif(%currentpot != pot,$chr(32) $+ into side pot $remove(%currentpot,pot) $+ .,.)
  1864.       }
  1865.       set %nlhe. [ $+ [ $1 ] $+ .raiser ] $2
  1866.       .timer -m 1 1 nlhe.nextturn $1
  1867.     }
  1868.     if ($3 == raise) {
  1869.       var %xbet = [ %nlhe. [ $+ [ $1 ] $+ .bet $+ [ %currentpot ] ] ], %xmoney = [ %nlhe. [ $+ [ $1 ] $+ . $+ [ $2 ] ] ], %xinv = [ %nlhe. [ $+ [ $1 ] $+ . $+ [ $2 ] $+
  1870.  
  1871. .invested $+ [ %currentpot ] ] ]
  1872.       if (%xinv == $null) { %xinv = 0 }
  1873.       var %i = $remove(%currentpot,pot), %amount = 0
  1874.       if (!%i) { %i = "" }
  1875.       while ((%i < 10) || (!%i)) {
  1876.         var %cinvv = [ %nlhe. [ $+ [ $1 ] $+ . $+ [ $2 ] $+ .investedpot $+ [ %i ] ] ]
  1877.         var %cbett = $iif([ %nlhe. [ $+ [ $1 ] $+ .allinpot $+ [ %i ] ] ],[ %nlhe. [ $+ [ $1 ] $+ .allinamountpot $+ [ %i ] ] ],[ %nlhe. [ $+ [ $1 ] $+ .betpot $+ [ %i ] ] ])
  1878.         if (%cinvv < %cbett) {
  1879.           var %totalbet = $calc(%totalbet + %cbett)
  1880.           var %totalinv = $calc(%totalinv + %cinvv)
  1881.           var %amount = $calc(%amount + %cbett - %cinvv)
  1882.           if (%amount >= %currentmoney) { %i = 11 }
  1883.         }
  1884.         inc %i
  1885.       }
  1886.       if (!%amount) {
  1887.         var %amount = $calc(%xbet - %xinv)
  1888.         var %totalbet = %xbet
  1889.         var %totalinv = %xinv
  1890.       }
  1891.       if (!%totalbet) {
  1892.         nlhe.notice $1 $2 You can't raise here.
  1893.         return
  1894.       }
  1895.       var %xraise = $iif($4 == to,$5,$calc($4 + %totalbet))
  1896.       if (%xraise) {
  1897.         if ($calc(%xmoney + %totalinv) < %xraise) {
  1898.           var %xraise = $calc(%xmoney + %totalinv)
  1899.         }
  1900.         var %prevraiser = [ %nlhe. [ $+ [ $1 ] $+ .raiser ] ]
  1901.         if (%prevraiser != $2) {
  1902.           var %prevraise = [ %nlhe. [ $+ [ $1 ] $+ . $+ [ %prevraiser ] $+ .raiseamount ] ]
  1903.         }
  1904.         if (%amount >= %xmoney) {
  1905.           nlhe.notice $1 $2 You don't have enough money to raise.
  1906.           return
  1907.         }
  1908.         if (($calc(%xraise - %totalbet) < $calc($iif(%prevraise,%prevraise,%totalbet))) && ($calc(%xraise - %totalinv) < %xmoney)) {
  1909.           nlhe.notice $1 $2 Illegal raise. You must at least double the bet.
  1910.           return
  1911.         }
  1912.         unset %nlhe. [ $+ [ $1 ] $+ .*.action ]
  1913.         set %nlhe. [ $+ [ $1 ] $+ . $+ [ $2 ] $+ .action ] raise
  1914.         set %nlhe. [ $+ [ $1 ] $+ . $+ [ $2 ] $+ .raiseamount ] $calc(%xraise - %totalbet)
  1915.         set %nlhe. [ $+ [ $1 ] $+ .raiser ] $2
  1916.         nlhe.msg $1  $+ $2 $+  raises $iif(%currentpot != pot,the side pot $remove(%currentpot,pot) bet) from $ $+ %totalbet $+  to $ $+ %xraise $+ .
  1917.         .timer -m 1 1 nlhe.action $1 $2 call
  1918.       }
  1919.     }
  1920.     if ($3 == fold) {
  1921.       var %i = ""
  1922.       while ((%i < 10) || (!%i)) {
  1923.         var %cp = [ %nlhe. [ $+ [ $1 ] $+ .playerspot $+ [ %i ] ] ]
  1924.         if (%cp) {
  1925.           set %nlhe. [ $+ [ $1 ] $+ .playerspot $+ [ %i ] ] $remtok(%cp,$2,1,32)
  1926.         }
  1927.         inc %i
  1928.       }
  1929.       unset %nlhe. [ $+ [ $1 ] $+ . $+ [ $2 ] $+ .action ]
  1930.       nlhe.msg $1  $+ $2 $+  folds.
  1931.       .timer -m 1 1 nlhe.nextturn $1
  1932.     }
  1933.     if ($3 == check) {
  1934.       var %inv = [ %nlhe. [ $+ [ $1 ] $+ . $+ [ $2 ] $+ .invested $+ [ %currentpot ] ] ], %bet = [ %nlhe. [ $+ [ $1 ] $+ .bet $+ [ %currentpot ] ] ]
  1935.       if ((%inv != $null) && (%bet != $null) && (%inv == %bet) && ([ %nlhe. [ $+ [ $1 ] $+ .stage ] ] == preflop) && ([ %nlhe. [ $+ [ $1 ] $+ .bb ] ] == $2)) {
  1936.         nlhe.msg $1  $+ $2 $+  checks.
  1937.         set %nlhe. [ $+ [ $1 ] $+ . $+ [ $2 ] $+ .action ] check
  1938.         .timer -m 1 1 nlhe.nextturn $1
  1939.       }
  1940.       elseif (!%bet) {
  1941.         nlhe.msg $1  $+ $2 $+  checks.
  1942.         set %nlhe. [ $+ [ $1 ] $+ . $+ [ $2 ] $+ .action ] check
  1943.         .timer -m 1 1 nlhe.nextturn $1
  1944.       }
  1945.       else {
  1946.         nlhe.notice $1 $2 You can't check here.
  1947.       }
  1948.     }
  1949.     if ([ %nlhe. [ $+ [ $1 ] $+ . $+ [ $2 ] ] ] <= 0) {
  1950.       if ([ %nlhe. [ $+ [ $1 ] $+ .allinamount $+ [ %currentpot ] ] ] == $null) {
  1951.         set %nlhe. [ $+ [ $1 ] $+ .allinamount $+ [ %currentpot ] ] $iif(%tx,%tx,[ %nlhe. [ $+ [ $1 ] $+ .bet $+ [ %currentpot ] ] ])
  1952.       }
  1953.       set %nlhe. [ $+ [ $1 ] $+ .allin $+ [ %currentpot ] ] $addtok([ %nlhe. [ $+ [ $1 ] $+ .allin $+ [ %currentpot ] ] ],$2,32)
  1954.       nlhe.msg $1  $+ $2 $+  is all in.
  1955.     }
  1956.   }
  1957. }
  1958.  
  1959. alias nlhe.allin {
  1960.   if ([ %nlhe. [ $+ [ $1 ] $+ .running ] ]) {
  1961.     var %amount, %currentmoney = [ %nlhe. [ $+ [ $1 ] $+ . $+ [ $2 ] ] ]
  1962.     if (([ %nlhe. [ $+ [ $1 ] $+ .allinpot ] ]) && ([ %nlhe. [ $+ [ $1 ] $+ . $+ [ $2 ] $+ .investedpot ] ] >= [ %nlhe. [ $+ [ $1 ] $+ .allinamountpot ] ])) {
  1963.       var %i = 0
  1964.       while (%i < 10) {
  1965.         inc %i
  1966.         var %cinvv = [ %nlhe. [ $+ [ $1 ] $+ . $+ [ $2 ] $+ .investedpot $+ [ %i ] ] ]
  1967.         var %cbett = $iif([ %nlhe. [ $+ [ $1 ] $+ .allinpot $+ [ %i ] ] ],[ %nlhe. [ $+ [ $1 ] $+ .allinamountpot $+ [ %i ] ] ],[ %nlhe. [ $+ [ $1 ] $+ .betpot $+ [ %i ] ] ])
  1968.         if (%cinvv < %cbett) {
  1969.           var %currentpot = pot $+ %i
  1970.           goto foundpot
  1971.         }
  1972.         elseif ((!%cbett) && (!%currentpot)) {
  1973.           var %currentpot = pot $+ %i
  1974.           goto foundpot
  1975.         }
  1976.         elseif ((%cinvv == %cbett) && (%cbett) && ([ %nlhe. [ $+ [ $1 ] $+ .allinpot $+ [ %i ] ] ] == $null)) {
  1977.           var %currentpot = pot $+ %i
  1978.         }
  1979.       }
  1980.     }
  1981.     if (!%currentpot) { var %currentpot = pot }
  1982.     :foundpot
  1983.     var %i = $iif($remove(%currentpot,pot),$remove(%currentpot,pot),0)
  1984.     while (%i < 10) {
  1985.       inc %i
  1986.       if ([ %nlhe. [ $+ [ $1 ] $+ .playerspot $+ [ %i ] ] ] == $null) {
  1987.         var %nextpot = pot $+ %i
  1988.         goto foundnextpot
  1989.       }
  1990.     }
  1991.     :foundnextpot
  1992.  
  1993.     if (([ %nlhe. [ $+ [ $1 ] $+ .bet $+ [ %currentpot ] ] ]) && ([ %nlhe. [ $+ [ $1 ] $+ .raiser ] ] != $2)) {
  1994.  
  1995.     }
  1996.     else {
  1997.       nlhe.action $1 $2 bet %currentmoney
  1998.       return
  1999.     }
  2000.  
  2001.     var %xbet = [ %nlhe. [ $+ [ $1 ] $+ .bet $+ [ %currentpot ] ] ], %xmoney = [ %nlhe. [ $+ [ $1 ] $+ . $+ [ $2 ] ] ], %xinv = [ %nlhe. [ $+ [ $1 ] $+ . $+ [ $2 ] $+ .invested
  2002.  
  2003. $+ [ %currentpot ] ] ]
  2004.     if (%xinv == $null) { %xinv = 0 }
  2005.     var %i = $remove(%currentpot,pot), %amount = 0
  2006.     if (!%i) { %i = "" }
  2007.     while ((%i < 10) || (!%i)) {
  2008.       var %cinvv = [ %nlhe. [ $+ [ $1 ] $+ . $+ [ $2 ] $+ .investedpot $+ [ %i ] ] ]
  2009.       var %cbett = $iif([ %nlhe. [ $+ [ $1 ] $+ .allinpot $+ [ %i ] ] ],[ %nlhe. [ $+ [ $1 ] $+ .allinamountpot $+ [ %i ] ] ],[ %nlhe. [ $+ [ $1 ] $+ .betpot $+ [ %i ] ] ])
  2010.       if (%cinvv < %cbett) {
  2011.         var %totalbet = $calc(%totalbet + %cbett)
  2012.         var %totalinv = $calc(%totalinv + %cinvv)
  2013.         var %amount = $calc(%amount + %cbett - %cinvv)
  2014.         if (%amount >= %currentmoney) { %i = 11 }
  2015.       }
  2016.       inc %i
  2017.     }
  2018.     if (!%amount) {
  2019.       var %amount = $calc(%xbet - %xinv)
  2020.       var %totalbet = %xbet
  2021.       var %totalinv = %xinv
  2022.     }
  2023.     if (!%totalbet) {
  2024.       nlhe.action $1 $2 bet %currentmoney
  2025.       return
  2026.     }
  2027.     elseif (%amount >= %currentmoney) {
  2028.       nlhe.action $1 $2 call
  2029.       return
  2030.     }
  2031.     else {
  2032.       nlhe.action $1 $2 raise %currentmoney
  2033.       return
  2034.     }
  2035.     nlhe.action $1 $2 call
  2036.   }
  2037. }
  2038.  
  2039. alias nlhe.takecard {
  2040.   var %deck = $hget(nlhe. $+ $1,deck)
  2041.   if (%deck) {
  2042.     ;    var %r = $rand(1,$numtok(%deck,32))
  2043.     var %r = 1
  2044.     hadd nlhe. $+ $1 deck $deltok(%deck,%r,32)
  2045.     return $gettok(%deck,%r,32)
  2046.   }
  2047. }
  2048.  
  2049. alias nlhe.colorcards {
  2050.   var %j = 1
  2051.   while ($gettok($1-,%j,32)) {
  2052.     var %ccard = $ifmatch, %color
  2053.     if ($right(%ccard,1) == c) { %color = 03 }
  2054.     if ($right(%ccard,1) == d) { %color = 12 }
  2055.     if ($right(%ccard,1) == h) { %color = 04 }
  2056.     if ($right(%ccard,1) == s) { %color = "" }
  2057.  
  2058.     var %output = %output %color $+  $+ $left(%ccard,1) $+  $+ $right(%ccard,1) $+ $iif(%color,)
  2059.     inc %j
  2060.   }
  2061.   return %output
  2062. }
  2063.  
  2064. alias nlhe.nextround {
  2065.   if ([ %nlhe. [ $+ [ $1 ] $+ .running ] ]) {
  2066.     unset %nlhe. [ $+ [ $1 ] $+ .allinpot* ]
  2067.     unset %nlhe. [ $+ [ $1 ] $+ .allinamountpot* ]
  2068.     unset %nlhe. [ $+ [ $1 ] $+ .board ]
  2069.     unset %nlhe. [ $+ [ $1 ] $+ .pot* ]
  2070.     unset %nlhe. [ $+ [ $1 ] $+ .playerspot* ]
  2071.     unset %nlhe. [ $+ [ $1 ] $+ .allallin ]
  2072.     var %cb = [ %nlhe. [ $+ [ $1 ] $+ .blind ] ], %nb = [ %nlhe. [ $+ [ $1 ] $+ .nextblind ] ]
  2073.     if (%nb > %cb) {
  2074.       set %nlhe. [ $+ [ $1 ] $+ .blind ] %nb
  2075.       nlhe.msg $1 The blinds are going up. They are now at:  $+ $round($calc(%nb / 2),0) $+ / $+ %nb $+ .
  2076.       var %allplist = [ %nlhe. [ $+ [ $1 ] $+ .players ] ], %nump = $numtok(%allplist,32), %i = 1, %totalm = 0
  2077.       while ($gettok(%allplist,%i,32)) {
  2078.         var %c = $ifmatch
  2079.         inc %totalm [ %nlhe. [ $+ [ $1 ] $+ . $+ [ %c ] ] ]
  2080.         inc %i
  2081.       }
  2082.       var %avg = $round($calc(%totalm / %nump),0)
  2083.       var %tnb = $nlhe.nxtblind(%nb)
  2084.       if ($calc(%avg / %tnb) < 10) {
  2085.         nlhe.msg $1 The blinds have reached their maximum.
  2086.         .timernlhe. $+ $1 $+ .blinds off
  2087.       }
  2088.       else {
  2089.         %tnb = $nlhe.nxtblind(%tnb)
  2090.         if ($calc(%avg / %tnb) < 10) {
  2091.           var %tname = nlhe. $+ $1 $+ .blinds
  2092.           if ($timer(%tname)) {
  2093.             var %cdelay = $round($calc($timer(%tname).delay / 60),0)
  2094.             var %cstat = $timer(%tname).type
  2095.             if (%cstat == offline) {
  2096.               .timer $+ %tname off
  2097.               .timer $+ %tname 0 $calc(%cdelay * 120) nlhe.raiseblinds $1
  2098.               nlhe.msg $1  $+ $calc(%cdelay * 2) minutes remain until the blinds reach their maximum.
  2099.             }
  2100.             else {
  2101.               nlhe.msg $1 The blinds will be raised once more, because the number of players has decreased.
  2102.               nlhe.msg $1  $+ %cdelay minutes remain until the blinds reach their maximum.
  2103.             }
  2104.           }
  2105.         }
  2106.       }
  2107.     }
  2108.     set %nlhe. [ $+ [ $1 ] $+ .playerspot ] [ %nlhe. [ $+ [ $1 ] $+ .players ] ]
  2109.     set %nlhe. [ $+ [ $1 ] $+ .button ] $nlhe.nextp($1,pot,[ %nlhe. [ $+ [ $1 ] $+ .button ] ])
  2110.     if ($numtok([ %nlhe. [ $+ [ $1 ] $+ .players ] ],32) == 2) {
  2111.       set %nlhe. [ $+ [ $1 ] $+ .sb ] [ %nlhe. [ $+ [ $1 ] $+ .button ] ]
  2112.       set %nlhe. [ $+ [ $1 ] $+ .bb ] $nlhe.nextp($1,pot,[ %nlhe. [ $+ [ $1 ] $+ .sb ] ])
  2113.     }
  2114.     else {
  2115.       set %nlhe. [ $+ [ $1 ] $+ .sb ] $nlhe.nextp($1,pot,[ %nlhe. [ $+ [ $1 ] $+ .button ] ])
  2116.       set %nlhe. [ $+ [ $1 ] $+ .bb ] $nlhe.nextp($1,pot,[ %nlhe. [ $+ [ $1 ] $+ .sb ] ])
  2117.     }
  2118.  
  2119.     var %dck = 2c 3c 4c 5c 6c 7c 8c 9c Tc Jc Qc Kc Ac 2d 3d 4d 5d 6d 7d 8d 9d Td Jd Qd Kd Ad 2h 3h 4h 5h 6h 7h 8h 9h Th Jh Qh Kh Ah 2s 3s 4s 5s 6s 7s 8s 9s Ts Js Qs Ks As
  2120.     while (%dck) {
  2121.       var %rd = $rand(1,$numtok(%dck,32))
  2122.       var %sdck = %sdck $gettok(%dck,%rd,32)
  2123.       var %dck = $deltok(%dck,%rd,32)
  2124.     }
  2125.     hadd -m nlhe. $+ $1 deck %sdck
  2126.  
  2127.     var %oldmsgdelay = %nlhe.msgdelay
  2128.     set %nlhe.msgdelay 5000
  2129.     nlhe.msg $1 Players
  2130.     set %nlhe.msgdelay %oldmsgdelay
  2131.  
  2132.     var %i = 0
  2133.     while (%i < $numtok([ %nlhe. [ $+ [ $1 ] $+ .players ] ],32)) {
  2134.       inc %i
  2135.       var %c = $gettok([ %nlhe. [ $+ [ $1 ] $+ .players ] ],%i,32), %prefix = ___
  2136.       var %clist = %clist [ %nlhe. [ $+ [ $1 ] $+ . $+ [ %c ] ] ]
  2137.       hadd nlhe. $+ $1 %c $nlhe.takecard($1) $nlhe.takecard($1)
  2138.       set %nlhe. [ $+ [ $1 ] $+ . $+ [ %c ] $+ .investedpot ] 0
  2139.       set %nlhe. [ $+ [ $1 ] $+ . $+ [ %c ] $+ .investedpot1 ] 0
  2140.       set %nlhe. [ $+ [ $1 ] $+ . $+ [ %c ] $+ .investedpot2 ] 0
  2141.       set %nlhe. [ $+ [ $1 ] $+ . $+ [ %c ] $+ .investedpot3 ] 0
  2142.       set %nlhe. [ $+ [ $1 ] $+ . $+ [ %c ] $+ .investedpot4 ] 0
  2143.       set %nlhe. [ $+ [ $1 ] $+ . $+ [ %c ] $+ .investedpot5 ] 0
  2144.       set %nlhe. [ $+ [ $1 ] $+ . $+ [ %c ] $+ .investedpot6 ] 0
  2145.       set %nlhe. [ $+ [ $1 ] $+ . $+ [ %c ] $+ .investedpot7 ] 0
  2146.       set %nlhe. [ $+ [ $1 ] $+ . $+ [ %c ] $+ .investedpot8 ] 0
  2147.       set %nlhe. [ $+ [ $1 ] $+ . $+ [ %c ] $+ .investedpot9 ] 0
  2148.       if (%c == [ %nlhe. [ $+ [ $1 ] $+ .sb ] ]) { %prefix = SB: }
  2149.       if (%c == [ %nlhe. [ $+ [ $1 ] $+ .bb ] ]) { %prefix = BB: }
  2150.       if (%c == [ %nlhe. [ $+ [ $1 ] $+ .button ] ]) { %prefix = DB: }
  2151.       nlhe.msg $1  $+ %prefix $chr(36) $+ ! $+ [ %nlhe. [ $+ [ $1 ] $+ . $+ [ %c ] ] ] %c $+ $iif([ %nlhe. [ $+ [ $1 ] $+ . $+ [ %c ] $+ .sitout ] ],$chr(32) $+ - sitting out)
  2152.  
  2153. $+ 
  2154.       nlhe.notice $1 %c Your cards are: $nlhe.colorcards($hget(nlhe. $+ $1,%c))
  2155.     }
  2156.     set %nlhe. [ $+ [ $1 ] $+ .turn ] [ %nlhe. [ $+ [ $1 ] $+ .bb ] ]
  2157.     set %nlhe. [ $+ [ $1 ] $+ .stage ] preflop
  2158.     nlhe.action $1 [ %nlhe. [ $+ [ $1 ] $+ .sb ] ] sb
  2159.   }
  2160. }
  2161.  
  2162. alias nlhe.nextturn {
  2163.   if ([ %nlhe. [ $+ [ $1 ] $+ .running ] ]) {
  2164.     .timernlhe. $+ $1 $+ .turn* off
  2165.     var %current = [ %nlhe. [ $+ [ $1 ] $+ .turn ] ], %next = $nlhe.nextp($1,pot,%current)
  2166.     set %nlhe. [ $+ [ $1 ] $+ .turn ] %next
  2167.     if ($numtok([ %nlhe. [ $+ [ $1 ] $+ .playerspot ] ],32) < 2) {
  2168.       unset %nlhe. [ $+ [ $1 ] $+ .turn ]
  2169.       nlhe.nextstage $1
  2170.       return
  2171.     }
  2172.     if (%current == %next) {
  2173.       unset %nlhe. [ $+ [ $1 ] $+ .turn ]
  2174.       nlhe.nextstage $1
  2175.       return
  2176.     }
  2177.     if ($nlhe.nextp($1,pot,%next) == %next) {
  2178.       var %xbet = [ %nlhe. [ $+ [ $1 ] $+ .betpot ] ], %xmoney = [ %nlhe. [ $+ [ $1 ] $+ . $+ [ %next ] ] ], %xinv = [ %nlhe. [ $+ [ $1 ] $+ . $+ [ %next ] $+ .investedpot ] ]
  2179.       if (%xinv == $null) { %xinv = 0 }
  2180.       var %i = ""
  2181.       while ((%i < 10) || (!%i)) {
  2182.         var %cinvv = [ %nlhe. [ $+ [ $1 ] $+ . $+ [ %next ] $+ .investedpot $+ [ %i ] ] ]
  2183.         var %cbett = $iif([ %nlhe. [ $+ [ $1 ] $+ .allinpot $+ [ %i ] ] ],[ %nlhe. [ $+ [ $1 ] $+ .allinamountpot $+ [ %i ] ] ],[ %nlhe. [ $+ [ $1 ] $+ .betpot $+ [ %i ] ] ])
  2184.         if (%cinvv < %cbett) {
  2185.           var %totalbet = $calc(%totalbet + %cbett)
  2186.           var %totalinv = $calc(%totalinv + %cinvv)
  2187.           var %amount = $calc(%amount + %cbett - %cinvv)
  2188.         }
  2189.         inc %i
  2190.       }
  2191.       if (!%amount) {
  2192.         var %amount = $calc(%xbet - %xinv)
  2193.       }
  2194.       if (!%amount) {
  2195.         unset %nlhe. [ $+ [ $1 ] $+ .turn ]
  2196.         nlhe.nextstage $1
  2197.         return
  2198.       }
  2199.     }
  2200.     if ([ %nlhe. [ $+ [ $1 ] $+ . $+ [ %next ] $+ .action ] ] == raise) {
  2201.       var %loopcheck = $nlhe.nextp($1,pot,%next), %nextst = 1
  2202.       while (%loopcheck != %next) {
  2203.         if ([ %nlhe. [ $+ [ $1 ] $+ . $+ [ %loopcheck ] $+ .action ] ] == call) {
  2204.           var %nextst = 1
  2205.         }
  2206.         else {
  2207.           var %nextst = 0
  2208.           goto loopout
  2209.         }
  2210.         %loopcheck = $nlhe.nextp($1,pot,%loopcheck)
  2211.       }
  2212.       if (%nextst) {
  2213.         unset %nlhe. [ $+ [ $1 ] $+ .turn ]
  2214.         nlhe.nextstage $1
  2215.         return
  2216.       }
  2217.     }
  2218.     if ([ %nlhe. [ $+ [ $1 ] $+ . $+ [ %next ] $+ .action ] ] == call) {
  2219.       var %loopcheck = $nlhe.nextp($1,pot,%next), %nextst = 1
  2220.       while (%loopcheck != %next) {
  2221.         if (([ %nlhe. [ $+ [ $1 ] $+ . $+ [ %loopcheck ] $+ .action ] ] == call) || ([ %nlhe. [ $+ [ $1 ] $+ . $+ [ %loopcheck ] $+ .action ] ] == raise)) {
  2222.           var %nextst = 1
  2223.         }
  2224.         else {
  2225.           var %nextst = 0
  2226.           goto loopout
  2227.         }
  2228.         %loopcheck = $nlhe.nextp($1,pot,%loopcheck)
  2229.       }
  2230.       if (%nextst) {
  2231.         unset %nlhe. [ $+ [ $1 ] $+ .turn ]
  2232.         nlhe.nextstage $1
  2233.         return
  2234.       }
  2235.     }
  2236.     if ([ %nlhe. [ $+ [ $1 ] $+ . $+ [ %next ] $+ .action ] ] == check) {
  2237.       var %loopcheck = $nlhe.nextp($1,pot,%next), %nextst = 1
  2238.       while (%loopcheck != %next) {
  2239.         if ([ %nlhe. [ $+ [ $1 ] $+ . $+ [ %loopcheck ] $+ .action ] ] == check) {
  2240.           var %nextst = 1
  2241.         }
  2242.         else {
  2243.           var %nextst = 0
  2244.           goto loopout
  2245.         }
  2246.         %loopcheck = $nlhe.nextp($1,pot,%loopcheck)
  2247.       }
  2248.       if (%nextst) {
  2249.         unset %nlhe. [ $+ [ $1 ] $+ .turn ]
  2250.         nlhe.nextstage $1
  2251.         return
  2252.       }
  2253.     }
  2254.     :loopout
  2255.     if ([ %nlhe. [ $+ [ $1 ] $+ .stage ] ] == preflop) {
  2256.       if ([ %nlhe. [ $+ [ $1 ] $+ . $+ [ %current ] $+ .action ] ] == check) {
  2257.         unset %nlhe. [ $+ [ $1 ] $+ .turn ]
  2258.         nlhe.nextstage $1
  2259.         return
  2260.       }
  2261.     }
  2262.     var %sitout = [ %nlhe. [ $+ [ $1 ] $+ . $+ [ %next ] $+ .sitout ] ]
  2263.     if (%sitout) {
  2264.       var %allplayers = [ %nlhe. [ $+ [ $1 ] $+ .players ] ], %p = 1, %sit = 0
  2265.       while ($gettok(%allplayers,%p,32)) {
  2266.         var %player = $ifmatch
  2267.         if ([ %nlhe. [ $+ [ $1 ] $+ . $+ [ %player ] $+ .sitout ] ]) { inc %sit }
  2268.         inc %p
  2269.       }
  2270.       if (%sit == $numtok(%allplayers,32)) {
  2271.         nlhe.msg $1 Everyone's sitting out...
  2272.         nlhe.notice $1 %next It's your turn.
  2273.       }
  2274.       else {
  2275.         .timer -dom 1 [ %nlhe. [ $+ [ $1 ] $+ .msgtime ] ] nlhe.action $1 %next fold
  2276.       }
  2277.     }
  2278.     else {
  2279.       var %msgt = [ %nlhe. [ $+ [ $1 ] $+ .msgtime ] ]
  2280.       %msgt = $round($calc(%msgt / 1000),0)
  2281.       var %tta = $calc($iif(1 // %nlhe.timetoact && %nlhe.timetoact > 9,%nlhe.timetoact,60) + %msgt)
  2282.       if (([ %nlhe. [ $+ [ $1 ] $+ . $+ [ $nlhe.nextp($1,pot,%next) ] $+ .sitout ] ]) && ($numtok([ %nlhe. [ $+ [ $1 ] $+ .players ] ],32) == 2)) {
  2283.         nlhe.msg $1 Waiting for $nlhe.nextp($1,pot,%next) to return...
  2284.       }
  2285.       else {
  2286.         .timernlhe. $+ $1 $+ .turn2 -do 1 $calc(%tta -12) nlhe.notice $1 %next 04You have 10 seconds left to act. $chr(124) nlhe.msg $1  $+ %next has 10 seconds left to
  2287.  
  2288. act...
  2289.         .timernlhe. $+ $1 $+ .turn -do 1 %tta nlhe.msg $1  $+ %next took longer than $calc(%tta - %msgt) seconds to act. $chr(124) nlhe.sitout $1 %next out
  2290.         nlhe.notice $1 %next It's your turn.
  2291.       }
  2292.     }
  2293.   }
  2294. }
  2295.  
  2296. alias nlhe.nextstage {
  2297.   unset %nlhe. [ $+ [ $1 ] $+ .raiser ]
  2298.   unset %nlhe. [ $+ [ $1 ] $+ .betpot* ]
  2299.   unset %nlhe. [ $+ [ $1 ] $+ .*.action ]
  2300.   unset %nlhe. [ $+ [ $1 ] $+ .*.raiseamount ]
  2301.   var %i = ""
  2302.   while ((%i < 10) || (!%i)) {
  2303.     var %allplayers = [ %nlhe. [ $+ [ $1 ] $+ .playerspot $+ [ %i ] ] ]
  2304.     if (([ %nlhe. [ $+ [ $1 ] $+ .allinpot $+ [ %i ] ] ] == $null) && (%allplayers)) {
  2305.       var %j = 1
  2306.       while ($gettok(%allplayers,%j,32)) {
  2307.         set %nlhe. [ $+ [ $1 ] $+ . $+ [ $ifmatch ] $+ .investedpot $+ [ %i ] ] 0
  2308.         inc %j
  2309.       }
  2310.     }
  2311.     inc %i
  2312.   }
  2313.   if ($numtok([ %nlhe. [ $+ [ $1 ] $+ .playerspot ] ],32) < 2) {
  2314.     nlhe.distributepots $1
  2315.   }
  2316.   else {
  2317.     set %nlhe. [ $+ [ $1 ] $+ .turn ] $nlhe.prevp($1,pot,$nlhe.nextp($1,pot,[ %nlhe. [ $+ [ $1 ] $+ .button ] ]))
  2318.     var %current = [ %nlhe. [ $+ [ $1 ] $+ .turn ] ], %next = $nlhe.nextp($1,pot,%current)
  2319.     var %cstage = [ %nlhe. [ $+ [ $1 ] $+ .stage ] ]
  2320.     if (%cstage == preflop) {
  2321.       set %nlhe. [ $+ [ $1 ] $+ .stage ] flop
  2322.       set %nlhe. [ $+ [ $1 ] $+ .board ] $nlhe.takecard($1) $nlhe.takecard($1) $nlhe.takecard($1)
  2323.     }
  2324.     if (%cstage == flop) {
  2325.       set %nlhe. [ $+ [ $1 ] $+ .stage ] turn
  2326.       set %nlhe. [ $+ [ $1 ] $+ .board ] [ %nlhe. [ $+ [ $1 ] $+ .board ] ] $nlhe.takecard($1)
  2327.     }
  2328.     if (%cstage == turn) {
  2329.       set %nlhe. [ $+ [ $1 ] $+ .stage ] river
  2330.       set %nlhe. [ $+ [ $1 ] $+ .board ] [ %nlhe. [ $+ [ $1 ] $+ .board ] ] $nlhe.takecard($1)
  2331.     }
  2332.     if (%cstage == river) {
  2333.       nlhe.distributepots $1
  2334.       return
  2335.     }
  2336.     var %ai = [ %nlhe. [ $+ [ $1 ] $+ .allallin ] ]
  2337.     if ((%current == %next) && (!%ai)) {
  2338.       set %nlhe. [ $+ [ $1 ] $+ .allallin ] 1
  2339.       %ai = 1
  2340.       var %allplayers = [ %nlhe. [ $+ [ $1 ] $+ .playerspot ] ], %p = 1
  2341.       while ($gettok(%allplayers,%p,32)) {
  2342.         var %player = $ifmatch, %cards = $hget(nlhe. $+ $1,%player)
  2343.         nlhe.msg $1  $+ %player $+  shows: $nlhe.colorcards(%cards) $+ .
  2344.         inc %p
  2345.       }
  2346.       nlhe.msg $1 Here we go...
  2347.     }
  2348.     if (!%ai) {
  2349.       var %i = ""
  2350.       while ((%i < 10) || (!%i)) {
  2351.         var %pot = pot $+ %i
  2352.         if ([ %nlhe. [ $+ [ $1 ] $+ . $+ [ %pot ] ] ]) {
  2353.           nlhe.msg $1 The $iif(%i,side pot %i,pot) contains: $ $+ [ %nlhe. [ $+ [ $1 ] $+ . $+ [ %pot ] ] ] $+ . Players in the pot:  $+ $sorttok([ %nlhe. [ $+ [ $1 ] $+
  2354.  
  2355. .players $+ [ %pot ] ] ],32) $+ .
  2356.         }
  2357.         inc %i
  2358.       }
  2359.     }
  2360.     else {
  2361.       var %oldmsgdelay = %nlhe.msgdelay
  2362.       set %nlhe.msgdelay 10000
  2363.     }
  2364.     nlhe.msg $1 The board is: $nlhe.colorcards([ %nlhe. [ $+ [ $1 ] $+ .board ] ])
  2365.     if (%oldmsgdelay != $null) {
  2366.       set %nlhe.msgdelay %oldmsgdelay
  2367.     }
  2368.     .timer -m 1 1 nlhe.nextturn $1
  2369.   }
  2370. }
  2371.  
  2372. alias nlhe.distributepots {
  2373.   var %i = "", %board = [ %nlhe. [ $+ [ $1 ] $+ .board ] ], %p = 1
  2374.   var %allplayers = [ %nlhe. [ $+ [ $1 ] $+ .playerspot ] ]
  2375.   if ($numtok(%allplayers,32) == 1) {
  2376.     while ((%i < 10) || (!%i)) {
  2377.       var %pot = pot $+ %i
  2378.       if ([ %nlhe. [ $+ [ $1 ] $+ . $+ [ %pot ] ] ]) {
  2379.         var %cpotamount = $ifmatch
  2380.         nlhe.msg $1  $+ %allplayers $+  wins the $iif($remove(%pot,pot),side pot $remove(%pot,pot),pot) of $ $+ %cpotamount $+ .
  2381.         inc %nlhe. [ $+ [ $1 ] $+ . $+ [ %allplayers ] ] %cpotamount
  2382.       }
  2383.       inc %i
  2384.     }
  2385.   }
  2386.   else {
  2387.     while ($gettok(%allplayers,%p,32)) {
  2388.       var %player = $ifmatch, %cards = $hget(nlhe. $+ $1,%player)
  2389.       var %value. [ $+ [ %player ] ] $nlhe.ranking(%board %cards)
  2390.       if (($gettok([ %value. [ $+ [ %player ] ] ],1,46) > 3) || ($gettok([ %value. [ $+ [ %player ] ] ],1,46) == 2)) {
  2391.         var %fora = 1
  2392.       }
  2393.       else {
  2394.         var %fora = 0
  2395.       }
  2396.       nlhe.msg $1  $+ %player $+  has $nlhe.colorcards(%cards) for $+ $iif(%fora,$chr(32) $+ a) $+ : $nlhe.valuewords([ %value. [ $+ [ %player ] ] ]) $+ .
  2397.       inc %p
  2398.     }
  2399.     while ((%i < 10) || (!%i)) {
  2400.       var %pot = pot $+ %i
  2401.       var %decced = 0
  2402.       if ([ %nlhe. [ $+ [ $1 ] $+ . $+ [ %pot ] ] ]) {
  2403.         var %cpotamount = $ifmatch, %cplayers = [ %nlhe. [ $+ [ $1 ] $+ .players $+ [ %pot ] ] ]
  2404.         var %j = 1
  2405.         while ($gettok(%cplayers,%j,32)) {
  2406.           var %cplayer = $ifmatch
  2407.           var %values = %values [ %value. [ $+ [ %cplayer ] ] ]
  2408.           inc %j
  2409.         }
  2410.         var %winners = $nlhe.showdown(%values)
  2411.         if ($numtok(%winners,32) > 1) {
  2412.           var %w = 1
  2413.           while ($gettok(%winners,%w,32)) {
  2414.             var %cwinner = $gettok(%cplayers,$ifmatch,32)
  2415.             var %winamount = $calc(%cpotamount / $numtok(%winners,32))
  2416.             if (!%decced) {
  2417.               var %dec = $round($calc((%winamount - $int(%winamount)) * $numtok(%winners,32)),0)
  2418.               if (%dec) {
  2419.                 var %winamount = $calc($int(%winamount) + %dec)
  2420.               }
  2421.               %decced = 1
  2422.             }
  2423.             else {
  2424.               var %winamount = $int(%winamount)
  2425.             }
  2426.             nlhe.msg $1  $+ %cwinner $+  ties for the $iif($remove(%pot,pot),side pot $remove(%pot,pot),pot) and wins $ $+ %winamount $+ .
  2427.             inc %nlhe. [ $+ [ $1 ] $+ . $+ [ %cwinner ] ] %winamount
  2428.             inc %w
  2429.           }
  2430.         }
  2431.         else {
  2432.           var %cwinner = $gettok(%cplayers,%winners,32)
  2433.           nlhe.msg $1  $+ %cwinner $+  wins the $iif($remove(%pot,pot),side pot $remove(%pot,pot),pot) of $ $+ %cpotamount $+ .
  2434.           inc %nlhe. [ $+ [ $1 ] $+ . $+ [ %cwinner ] ] %cpotamount
  2435.         }
  2436.         var %values = ""
  2437.       }
  2438.       inc %i
  2439.     }
  2440.   }
  2441.   var %b = 1, %allp = [ %nlhe. [ $+ [ $1 ] $+ .players ] ]
  2442.   while ($gettok(%allp,%b,32)) {
  2443.     var %player = $ifmatch
  2444.     if ([ %nlhe. [ $+ [ $1 ] $+ . $+ [ %player ] ] ] < 1) {
  2445.       nlhe.msg $1  $+ %player $+  has gone busted! Bye bye.
  2446.       if ([ %nlhe. [ $+ [ $1 ] $+ .button ] ] == %player) {
  2447.         set %nlhe. [ $+ [ $1 ] $+ .button ] $nlhe.prevp($1,pot,%player)
  2448.       }
  2449.       set %nlhe. [ $+ [ $1 ] $+ .players ] $remtok([ %nlhe. [ $+ [ $1 ] $+ .players ] ],%player,1,32)
  2450.       unset %nlhe. [ $+ [ $1 ] $+ . $+ [ %player ] $+ * ]
  2451.     }
  2452.     inc %b
  2453.   }
  2454.   if ($numtok([ %nlhe. [ $+ [ $1 ] $+ .players ] ],32) < 2) {
  2455.     nlhe.msg $1  $+ [ %nlhe. [ $+ [ $1 ] $+ .players ] ] $+  has won the game!
  2456.     var %msgt = [ %nlhe. [ $+ [ $1 ] $+ .msgtime ] ]
  2457.     unset %nlhe. [ $+ [ $1 ] $+ .* ]
  2458.     hfree -w nlhe. $+ $1
  2459.     .timernlhe. $+ $1 $+ .blinds off
  2460.     .timernlhe. $+ $1 $+ .turn* off
  2461.     if (%msgt) { set %nlhe. [ $+ [ $1 ] $+ .msgtime ] %msgt }
  2462.     return
  2463.   }
  2464.   nlhe.nextround $1
  2465. }
Add Comment
Please, Sign In to add comment