Guest User

Untitled

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