Advertisement
kazmadan

elobot

Jan 2nd, 2018
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 40.46 KB | None | 0 0
  1. set %Loser
  2. set %LoserPartner
  3. set %Winnerh
  4. set %WinnerPartner
  5. set %elogame
  6. set %1p
  7. set %2p
  8. set %gamelist GG exvs bbcp mafia UNIEL melty p4a saltybrett test KillCount
  9. set %lobbygamed
  10. set %regulars
  11. set %pot_total
  12. set %odds
  13. set %lobbygame
  14. set %printscores true
  15.  
  16. on *:START:{
  17.  
  18. hmake -s ratingtable 200
  19. hmake -s sortedtable 200
  20. echo -s table created
  21. hload -s ratingtable ratingtable.txt
  22.  
  23.  
  24. ;syntax is [Name} BetAmount 1p/2p
  25. ;hload -s saltyTable saltyTable.txt
  26.  
  27.  
  28. /timerbackup 0 6000 /elobackup
  29. echo -s table loaded
  30. set %gamelist GG exvs bbcp mafia UNIEL melty p4a saltybrett test
  31. set %lobbygame UNIEL
  32. set %regulars $read(regulars.txt,1)
  33. }
  34.  
  35. on *:EXIT:{
  36. hsave -os ratingtable ratingtable.txt
  37. }
  38.  
  39. alias resavehash {
  40. ;hsave -os ratingtable ratingtable.txt
  41.  
  42. ;hload -i ratingtable sorthash.txt
  43. hmake -s sortedtable 200
  44. echo -s table made
  45. hload -i sortedtable sorthash.txt stats
  46.  
  47. hsave -os sortedtable sortedtable2.txt
  48.  
  49. }
  50.  
  51. alias elobackup {
  52.  
  53. var %number = $rand(1,10000)
  54. hsave -os ratingtable $+(ratingbackup,/,ratingtable,%number,.,txt)
  55.  
  56.  
  57. }
  58.  
  59. on *:TEXT:!regulars add *:#:{
  60.  
  61. if ($nick isop $chan) || ($regcheck($nick)) {
  62.  
  63. if ($regcheck($3)) {
  64.  
  65. /msg $chan $nick <- That person is already a regular.
  66. }
  67. else {
  68.  
  69. write -n regulars.txt $3 $+ ;
  70. msg $chan $nick <- Adding $3 to the regulars list
  71. set %regulars $read(regulars.txt,1)
  72. }
  73.  
  74. }
  75. else {
  76.  
  77. /msg $chan $nick <- You are not a mod or regular.
  78. }
  79. }
  80.  
  81. alias regcheck {
  82.  
  83.  
  84. set %regulars $read(regulars.txt,1)
  85. if ($1 == $null) {
  86.  
  87. echo not enough param
  88. }
  89. elseif ($istok(%regulars, $1, 59)) {
  90. /echo $1 is a regular
  91. return $true
  92.  
  93. }
  94. else {
  95. /echo $1 is not a regular
  96. return $false
  97. }
  98.  
  99.  
  100.  
  101. }
  102.  
  103. on *:TEXT:!regulars test:#:{
  104.  
  105. ;set %regulars $read(regulars.txt,1)
  106. if ($regcheck($nick)) {
  107.  
  108. /msg $chan $nick yes you are a regular
  109. }
  110. else {
  111. msg $chan $nick <- You are not a regular
  112. }
  113.  
  114. }
  115.  
  116. ;/////////////// syntax is !lobby help //////////////////////
  117. on *:TEXT:!lobbyhelp:#:{
  118.  
  119.  
  120. msg $chan Mod Commands: !lobbyupdate <1p> <2p> / !lobbywin <1p/2p> / !report <game> <winner> <loser> / !register <nick> / !leaderboard <game>
  121. msg $chan User commands: !register / !won/!lost <game> <opponent> / !lost <game> <opponent> / !confirm <win/loss> / !rank <game> / !rank <game> <name>
  122.  
  123. }
  124.  
  125.  
  126. /*
  127. ;/////////////// syntax is !top5 <game> ///////////////////////
  128. on *:TEXT:!top5 *:#:{
  129.  
  130. if ( $count(%gamelist,$2) == 0 ) {
  131. echo -a Not a game
  132. msg #thebrett $nick <- Not a valid game type.
  133. }
  134. else {
  135. /hashsort $2
  136.  
  137. msg $chan Ranks for $2 $+ :
  138.  
  139. ;msg $chan 1. $read(sorthash.txt,1)
  140. ;msg $chan 2. $read(%sorthash,2)
  141. ;msg $chan 3. $read(%sorthash,3)
  142.  
  143. var %max = 5
  144. var %count = 1
  145. while (%count < $calc( %max + 1 )) {
  146.  
  147.  
  148. var %rankname = $gettok($read(sorthash.txt,%count),1,61)
  149. ;echo posting rank for %rankname
  150. ;msg $chan %count $+ . %rankname - $getelo(%rankname,$2) $+ SP $getwins(%rankname,$2) $+ W $+ - $+ $getlosses(%rankname,$2) $+ L ( $+ $round($calc($getwins(%rankname,$2) * 100 / $getTotalGames(%rankname,$2)),2) $+ % $+ ) $+ .
  151.  
  152. inc %count
  153.  
  154. }
  155.  
  156. }
  157. }
  158.  
  159. */
  160.  
  161. ;///////////// !leaderboard /////////////////
  162. on *:TEXT:!leaderboard *:#:{
  163.  
  164. if ($nick !isop $chan) {
  165.  
  166. ;msg $chan $nick <- You must be a mod to use this command
  167.  
  168. }
  169. elseif ( $count(%gamelist,$2) == 0 ) {
  170. echo -a Not a game
  171. msg $chan $nick <- Not a valid game type.
  172. }
  173. else {
  174. /makeleader $2
  175. /msg # Displaying leaderboard for $2
  176. }
  177.  
  178. }
  179.  
  180. alias top5 {
  181.  
  182. if ($1 == $null) {
  183.  
  184. echo error no parameters
  185. return
  186.  
  187. }
  188.  
  189. else {
  190. /hashsort $1
  191.  
  192. ;msg $chan Ranks for $upper($1) $+ :
  193.  
  194. ;msg $chan 1. $read(sorthash.txt,1)
  195. ;msg $chan 2. $read(%sorthash,2)
  196. ;msg $chan 3. $read(%sorthash,3)
  197.  
  198. var %max = $hget(ratingtable,0).item
  199. var %count = 1
  200. /write -c RankingChart.txt NCD Rankings for $upper($1) - updated $adate
  201. var %tiecount = 0
  202. while (%count < $calc( %max + 1 )) {
  203.  
  204.  
  205. var %rankname = $gettok($read(sorthash.txt,%count),1,61)
  206. if (%count > 1) {
  207. var %prevrankname = $gettok($read(sorthash.txt,$calc( %count - 1 )),1,61)
  208.  
  209. }
  210.  
  211. if ( $getelo(%rankname,$1) == $getelo(%prevrankname,$1) ) {
  212. ;echo posting rank for %rankname
  213. inc %tiecount
  214. var %msg = $calc(%count - %tiecount ) $+ . %rankname - $getelo(%rankname,$1) $+ SP $getwins(%rankname,$1) $+ W $+ - $+ $getlosses(%rankname,$1) $+ L ( $+ $round($calc($getwins(%rankname,$1) * 100 / $getTotalGames(%rankname,$1)),2) $+ % $+ ) $+ .
  215.  
  216.  
  217. }
  218.  
  219. else {
  220. %tiecount = 0
  221. ;echo posting rank for %rankname
  222. var %msg = %count $+ . %rankname - $getelo(%rankname,$1) $+ SP $getwins(%rankname,$1) $+ W $+ - $+ $getlosses(%rankname,$1) $+ L ( $+ $round($calc($getwins(%rankname,$1) * 100 / $getTotalGames(%rankname,$1)),2) $+ % $+ ) $+ .
  223.  
  224. }
  225. if ( $gettotalgames(%rankname, $1) > 0) {
  226. /write RankingChart.txt %msg
  227.  
  228. }
  229. inc %count
  230. }
  231. }
  232.  
  233. }
  234.  
  235. ;syntax makeRank <game>
  236. alias makeRank {
  237.  
  238. var %makeRank = makeRank.txt
  239. var %rank = 0
  240.  
  241.  
  242. if ($1 == $null) {
  243.  
  244. echo error no parameters
  245. return
  246.  
  247. }
  248.  
  249.  
  250. else {
  251. /hashsort $1
  252.  
  253. var %max = $hget(ratingtable,0).item
  254. var %count = 1
  255. /write -c %makeRank Ranks for $upper($1) - updated $adate
  256. var %tiecount = 0
  257.  
  258.  
  259.  
  260. while (%count < $calc( %max + 1 )) {
  261.  
  262. var %rankname = $gettok($read(sorthash.txt,%count),1,61)
  263.  
  264. if ( $gettotalgames(%rankname, $1) > 0) {
  265.  
  266.  
  267. if (%count > 1) {
  268. var %prevrankname = $gettok($read(sorthash.txt,$calc( %count - 1 )),1,61)
  269.  
  270. }
  271.  
  272. if ( $getelo(%rankname,$1) == $getelo(%prevrankname,$1) ) {
  273.  
  274. ;TIE
  275. ;echo posting rank for %rankname
  276.  
  277. inc %tiecount
  278. var %msg = %rankname - Rank is %rank $+ - $getelo(%rankname,$1) $+ SP $getwins(%rankname,$1) $+ W $+ - $+ $getlosses(%rankname,$1) $+ L ( $+ $round($calc($getwins(%rankname,$1) * 100 / $getTotalGames(%rankname,$1)),2) $+ % $+ ) $+ .
  279.  
  280.  
  281.  
  282. }
  283.  
  284. else {
  285.  
  286. ;not a time
  287. inc %rank
  288. inc %rank %tiecount
  289. %tiecount = 0
  290. echo posting rank for %rankname
  291. var %msg = %rankname - Rank is %rank $+ . $getelo(%rankname,$1) $+ SP $getwins(%rankname,$1) $+ W $+ - $+ $getlosses(%rankname,$1) $+ L ( $+ $round($calc($getwins(%rankname,$1) * 100 / $getTotalGames(%rankname,$1)),2) $+ % $+ ) $+ .
  292.  
  293.  
  294.  
  295.  
  296.  
  297.  
  298. }
  299.  
  300. write %makeRank %msg
  301. }
  302. inc %count
  303. }
  304.  
  305. }
  306. }
  307.  
  308.  
  309.  
  310. ;syntax makeLeader <game>
  311. alias makeLeader {
  312.  
  313. var %makeRank = leaderboard.txt
  314. var %leaderboardPSR = leaderboardPSR.txt
  315. var %leaderboardRank = leaderboardRank.txt
  316. var %leaderboardTitle = leaderboardTitle.txt
  317. var %rank = 0
  318.  
  319.  
  320. if ($1 == $null) {
  321.  
  322. echo error no parameters
  323. return
  324.  
  325. }
  326.  
  327.  
  328. else {
  329. /hashsort $1
  330.  
  331. var %max = $hget(ratingtable,0).item
  332. var %count = 1
  333. ;/write -c %makeRank Ranks for $upper($1) - updated $adate
  334. /write -c %leaderboardTitle $upper($1) Leaderboard
  335. /write -c %makeRank
  336. ;/write -c %makeRank
  337. /write -c %leaderboardPSR
  338. /write -c %leaderboardRank
  339. var %tiecount = 0
  340.  
  341.  
  342.  
  343. while (%count < $calc( %max + 1 )) {
  344.  
  345. var %rankname = $gettok($read(sorthash.txt,%count),1,61)
  346.  
  347. if ( $gettotalgames(%rankname, $1) > 0) {
  348.  
  349.  
  350. if (%count > 1) {
  351. var %prevrankname = $gettok($read(sorthash.txt,$calc( %count - 1 )),1,61)
  352.  
  353. }
  354.  
  355. if ( $getelo(%rankname,$1) == $getelo(%prevrankname,$1) ) {
  356.  
  357. ;TIE
  358. echo posting rank for %rankname
  359.  
  360. inc %tiecount
  361. ;var %msg = %rankname - Rank is %rank $+ - $getelo(%rankname,$1) $+ SP $getwins(%rankname,$1) $+ W $+ - $+ $getlosses(%rankname,$1) $+ L ( $+ $round($calc($getwins(%rankname,$1) * 100 / $getTotalGames(%rankname,$1)),2) $+ % $+ ) $+ .
  362. var %msg = $upper($left(%rankname,1)) $+ $mid(%rankname,2,15)
  363. ;var %msg = %rank $+ . $upper($left(%rankname,1)) $+ $mid(%rankname,2,15)
  364. ;var %msg = %rank $+ . %rankname - $getelo(%rankname,$1) $+ RIP
  365. ;$getwins(%rankname,$1) $+ W $+ - $+ $getlosses(%rankname,$1) $+ L ( $+ $round($calc($getwins(%rankname,$1) * 100 / $getTotalGames(%rankname,$1)),2) $+ % $+ ) $+ .
  366.  
  367. }
  368.  
  369. else {
  370.  
  371. ;not a time
  372. inc %rank
  373. inc %rank %tiecount
  374. %tiecount = 0
  375. echo posting rank for %rankname
  376. var %msg = $upper($left(%rankname,1)) $+ $mid(%rankname,2,15)
  377. ;var %msg = %rank $+ . $upper($left(%rankname,1)) $+ $mid(%rankname,2,15)
  378. ;var %msg = %rank $+ . %rankname - $getelo(%rankname,$1) $+ RIP
  379. ;$getwins(%rankname,$1) $+ W $+ - $+ $getlosses(%rankname,$1) $+ L ( $+ $round($calc($getwins(%rankname,$1) * 100 / $getTotalGames(%rankname,$1)),2) $+ % $+ ) $+ .
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387. }
  388. write %leaderboardRank %rank
  389. write %makeRank %msg
  390. write %leaderboardPSR $round($getelo(%rankname,$1),0)
  391. }
  392. inc %count
  393. }
  394.  
  395. }
  396. }
  397.  
  398.  
  399.  
  400. ;hashsort game
  401. alias hashsort {
  402.  
  403. hsave -os ratingtable ratingtable.txt
  404. var %sorthash = sorthash.txt
  405. hsave -io ratingtable %sorthash
  406. var %sortPos = $calc($findtok($hget(ratingtable,1).data,$1,1,32) + 1)
  407. ;echo -a sort position is %sortpos
  408. ;filter -ffxcteu %sortpos 32 %sorthash %sorthash [*]
  409. filter -ffxcteu %sortpos 32 %sorthash %sorthash [*]
  410. ;filter -ffxcteu %sortpos 32 %sorthash %sorthash *$11500 0 0*
  411. ;/write -il1 %sorthash [stats]
  412. ;hload -i sortedtable %sorthash stats
  413.  
  414. ;hsave -os sortedtable sortedtable7.txt
  415.  
  416.  
  417.  
  418.  
  419. }
  420. alias eloReload {
  421.  
  422. hfree ratingtable
  423. hmake -s ratingtable 200
  424. echo -s table created
  425. hload -s ratingtable ratingtable.txt
  426. hsave -os ratingtable ratingtable.txt
  427. echo -s table loaded
  428.  
  429. }
  430.  
  431.  
  432. ;syntax is 1P 2P
  433. alias lobbyTitle {
  434.  
  435. var %titlegame = %lobbygame
  436. if ($2 == $null) {
  437.  
  438. echo -a not enough parameters
  439.  
  440. }
  441.  
  442. elseif ($hget(ratingtable,$1) == $null) {
  443.  
  444. echo -a $1 not a registered player
  445.  
  446. }
  447.  
  448. elseif ($hget(ratingtable,$2) == $null) {
  449.  
  450. echo -a $2 not a registered player
  451.  
  452. }
  453. ;var %rank1p = $getRank($1,%titlegame)
  454. ;var %rank2p = $getRank($2,%titlegame)
  455. var %rank1p = Unranked
  456. var %rank2p = Unranked
  457.  
  458. if ( %rank1p == Unranked ) {
  459.  
  460. var %rank1p = ??
  461.  
  462. }
  463.  
  464. if ( %rank2p == Unranked ) {
  465.  
  466. var %rank2p = ??
  467.  
  468. }
  469.  
  470. var %1pElo = $getelo($1,%titlegame)
  471. var %2pElo = $getelo($2,%titlegame)
  472.  
  473. write -c delta.txt + $+ $elodelta(%1pElo,$getTotalGames($1,%titlegame),%2pElo,$getTotalGames($2,%titlegame) ) $chr(32) $chr(32) $chr(32) + $+ $elodelta(%2pElo,$getTotalGames($2,%titlegame),%1pElo,$getTotalGames($1,%titlegame) )
  474. write -c 1p.txt $left($1,18)
  475. write 1p.txt Rank %rank1p $chr(124) %1pElo RIP
  476. write -c 2p.txt $left($2,18)
  477. write 2p.txt %2pElo RIP $chr(124) Rank %rank2p
  478.  
  479. ;write -c 1pPSR.txt Rank %rank2p $chr(124) $getelo($1,%titlegame) RIP
  480.  
  481.  
  482.  
  483. }
  484. on *:TEXT:!lobbyupdate *:#:{
  485.  
  486. if ($nick isop $chan) || ($regcheck($nick)) {
  487.  
  488. if ($3 == $null) {
  489.  
  490. echo not enough parameters
  491. msg $chan $nick <- Incorrect syntax. Use !lobbyupdate <1p> <2p>
  492.  
  493. }
  494.  
  495. elseif ( $hget(ratingtable,$2) == $null ) {
  496.  
  497. msg $chan $nick <- $2 is not registered
  498.  
  499. }
  500.  
  501. elseif ( $hget(ratingtable,$3) == $null ) {
  502.  
  503. msg $chan $nick <- $3 is not registered
  504.  
  505. }
  506.  
  507. elseif ( $hget(saltyTable) == saltytable ) {
  508. msg # $nick <- There is a SaltyBrett already occurring
  509. }
  510.  
  511. else {
  512. set %1p $upper($left($2,1)) $+ $right($2,$calc($len($2)-1)))
  513. set %2p $upper($left($3,1)) $+ $right($3,$calc($len($3)-1)))
  514.  
  515.  
  516. lobbyTitle %1p %2p
  517. msg $chan $nick <- Setting Lobby titles - %1p VS %2p
  518. msg # $nick has earned 100 dollars for his contribution O u O
  519. /makeleader %lobbygame
  520. incelo $nick SaltyBrett 100
  521. incWin $nick SaltyBrett
  522. timerWipeLobby off
  523. timerWipeLobby 1 1000 /wipeLobby
  524. }
  525. }
  526. else {
  527.  
  528. msg $chan $nick <- You must be a regular or mod to use this command. Regulars can be added with !regulars add <nick>
  529. }
  530. }
  531.  
  532. on *:TEXT:!lobbywin *:#:{
  533. if ($nick isop $chan) || ($regcheck($nick)) {
  534.  
  535. if ( %2p == $null || %1p == $null ) {
  536. msg $chan $nick <- No one is playing right now
  537. }
  538.  
  539. elseif ($2 != 1p ) && ($2 != 2p) {
  540. msg # $nick <- Incorrect syntax - !lobbywin 1p/2p
  541.  
  542. }
  543. else {
  544.  
  545. var %saltyWinner
  546. var %saltyLoser
  547.  
  548. if ($2 == 1p ) {
  549.  
  550. var %saltyWinner = %1p
  551. var %saltyLoser = %2p
  552.  
  553. set %odds $calc( %pot2 / %pot1 )
  554.  
  555. eloreport %1p %2p %lobbygame
  556. ;msg $chan Reported a game - %1p beating %2p
  557. lobbyTitle %1p %2p
  558.  
  559. }
  560. if ($2 == 2p ) {
  561.  
  562. var %saltyWinner = %2p
  563. var %saltyLoser = %1p
  564.  
  565. set %odds $calc(%pot1 / %pot2)
  566.  
  567. ;/msg # 2p was the winner. The odds were %odds to 1
  568. eloreport %2p %1p %lobbygame
  569. ;msg $chan Reported a game - %2p beating %1p
  570. ;lobbyTitle %1p %2p
  571. ;lobbytitle is disabled for performance
  572.  
  573. }
  574.  
  575. if ($hget(saltyTable) == saltytable) {
  576. msg # %SaltyWinner was the winner. The odds were %odds to 1
  577.  
  578.  
  579. echo -a pot was %pot1 and %pot2
  580.  
  581. var %count = $hget(saltytable,0).data
  582.  
  583. if ( %pot1 > 0 ) && ( %pot2 > 0 ) {
  584.  
  585. while (%count > 0) {
  586.  
  587. var %curName = $hget(saltytable,%count).item
  588. var %bet = $gettok($hget(saltytable,%count).data,1,32)
  589. var %target = $gettok($hget(saltytable,%count).data,2,32)
  590.  
  591. if ( %target == $2) {
  592.  
  593. incElo %curName saltybrett $calc(%bet * %odds)
  594. incWin %curName saltybrett
  595. echo %curName bet %bet dollars on %target $+ , odds were %odds gaining + $calc(%bet * %odds)
  596.  
  597. }
  598.  
  599. else {
  600. incLoss %curName saltybrett
  601. decElo %curName saltybrett %bet
  602.  
  603. if ($getelo(%curName, saltybrett) < 0) {
  604.  
  605. setelo %curName saltybrett 0
  606. }
  607.  
  608. }
  609. ;setvar %curName cash $calc($getvar(%curName,cash) + $getvar(%curName,bet) + $getvar(%curName,bet)*%odds)
  610.  
  611. dec %count
  612. /echo lowering count
  613.  
  614. }
  615. ;makeleader saltybrett
  616.  
  617.  
  618. }
  619. else {
  620. msg $chan No betting occured for one side.
  621. }
  622.  
  623. }
  624.  
  625. else {
  626. msg $chan Reported a game - %saltyWinner beating %saltyLoser
  627. ;makeleader %lobbygame
  628. }
  629.  
  630. ;eloreport %saltyWinner %saltyLoser %lobbygame
  631.  
  632. ;lobbyTitle %1p %2p
  633.  
  634. ;disabling makeleader for performance
  635. ;makeleader %lobbygame
  636. set %1p $null
  637. set %2p $null
  638. /wipelobby
  639. set %clearing 1
  640. ;timerWipea 1 4 set %1p $null
  641. ;timerWipeb 1 4 set %2p $null
  642. ;timerWipec 1 2 wipeLobby
  643. timerWiped 1 2 set %clearing 0
  644. ;msg # wiping
  645.  
  646. }
  647.  
  648. }
  649. else {
  650. msg $chan $nick <- You must be a mod or regular to report.
  651. }
  652.  
  653.  
  654.  
  655.  
  656.  
  657. }
  658.  
  659. /*
  660.  
  661. on *:TEXT:!lobbywin 2p:#:{
  662. if ($nick isop $chan) || ($regcheck($nick)) {
  663.  
  664.  
  665.  
  666. if ( %2p == $null ) {
  667.  
  668. msg $chan $nick <- No one is playing right now
  669.  
  670. }
  671.  
  672. else {
  673.  
  674. eloreport %2p %1p %lobbygame
  675. msg $chan Reported a game - %2p beating %1p
  676. lobbyTitle %1p %2p
  677. set %1p $null
  678. set %2p $null
  679. timerWipeb 1 4 /wipeLobby
  680. }
  681.  
  682. }
  683. else { msg $chan $nick <- You must be a mod or regular to report.
  684. }
  685. }
  686.  
  687.  
  688. */
  689.  
  690. on *:TEXT:!register:#:{
  691.  
  692. if (!$hget(ratingtable,$nick)) {
  693. /eloregister $nick
  694. msg $chan $nick <- You are now registered.
  695. write -a logforscores.txt $fulldate :: Register :: $nick
  696. }
  697. else {
  698. msg $chan $nick <- You are already registered.
  699. echo -ag hashtable entry for $remove($nick,-tk) $+ : $hget(ratingtable,$remove($nick,-tk))
  700. }
  701. hsave -os ratingtable ratingtable.txt
  702.  
  703. }
  704.  
  705. alias wipeLobby {
  706. write -l10 "D:\streamcontrol.xml" <pName1></pName1>
  707. write -l3 "D:\streamcontrol.xml" <timestamp> $+ $ctime $+ </timestamp>
  708.  
  709. set %1p $null
  710. set %2p $null
  711. set %pot1 0
  712. set %pot2 0
  713. write -c saltyodds1.txt
  714. write -c saltyodds2.txt
  715. write -c delta.txt
  716. write -c 1p.txt
  717. write -c 1pPSR.txt
  718. write -c 2p.txt
  719. write -c 2pPSR.txt
  720. hfree -s saltytable
  721.  
  722.  
  723. }
  724.  
  725. on *:TEXT:!register *:#:{
  726.  
  727. if ($nick !isop $chan) && ( $regcheck($nick) == $false ) {
  728.  
  729. msg $chan $nick <- You must be an OP to use this command.
  730. }
  731. elseif (!$hget(ratingtable,$2)) {
  732. /eloregister $2
  733. msg $chan $2 is now registered.
  734. write -a logforscores.txt $fulldate :: Register :: $2
  735. }
  736. else {
  737. msg $chan $2 is already registered.
  738. echo -ag hashtable entry for $remove($nick,-tk) $+ : $hget(ratingtable,$remove($nick,-tk))
  739. }
  740. hsave -os ratingtable ratingtable.txt
  741.  
  742. }
  743.  
  744.  
  745.  
  746.  
  747.  
  748.  
  749. ;syntax is !won <game> <opponent>
  750. OR
  751. ;syntax is !won EXVS partner <opponent1> <opponent2>
  752. on *:TEXT:!won *:#:{
  753.  
  754.  
  755.  
  756.  
  757. if ($3 == $null) {
  758.  
  759. /msg $chan $nick <- Incorrect syntax. The syntax is !won <game> <opponent>
  760.  
  761. }
  762.  
  763. elseif ( $hget(ratingtable,$nick) == $null ) {
  764.  
  765. msg $chan $nick <- You must be registered to use this command. Register with !register
  766. }
  767.  
  768. elseif ( $hget(ratingtable,$3) == $null ) {
  769.  
  770. msg $chan $nick <- $3 is not registered. Players can register with !register
  771. }
  772. elseif ( $count(%gamelist,$2) == 0 ) {
  773. echo -a Not a game
  774. msg #thebrett Not a valid game type.
  775. }
  776. elseif ( %loser != $null ) || ( %winner != $null ) || ( %elogame != $null ) {
  777.  
  778. msg $chan someone has already used this command - winner is %winner
  779. }
  780.  
  781. elseif ( $2 == exvs ) && ( $5 == $null ) {
  782.  
  783. msg $chan $nick <- Improper syntax for EXVS - syntax is !won EXVS <partner> <opponent1> <opponent2>
  784. }
  785. elseif ( $2 == exvs ) && ( $hget(ratingtable,$3) == $null ) {
  786.  
  787. msg $chan $nick <- $3 is not registered. Players can register with !register
  788.  
  789. }
  790.  
  791. elseif ( $2 == exvs ) && ( $hget(ratingtable,$4) == $null ) {
  792.  
  793. msg $chan $nick <- $4 is not registered. Players can register with !register
  794.  
  795. }
  796.  
  797. elseif ( $2 == exvs ) && ( $hget(ratingtable,$5) == $null ) {
  798.  
  799. msg $chan $nick <- $5 is not registered. Players can register with !register
  800.  
  801. }
  802.  
  803. ;if the game is exvs, change the nicks appropriately
  804. elseif ( $2 == exvs ) {
  805.  
  806. set %winner $nick
  807. set %winnerpartner $3
  808. set %loser $4
  809. set %loserpartner $5
  810. set %elogame $2
  811. msg $chan Waiting 40 seconds for %loser or %loserpartner to use !confirm loss to report score.
  812. ;msg $chan this is exvs
  813. /timerEloWon 1 40 /flushNames
  814. }
  815.  
  816. else {
  817. ;msg $chan this is not exvs
  818. set %winner $nick
  819. set %loser $3
  820. set %elogame $2
  821. msg $chan Waiting 40 seconds for %loser to use !confirm loss to report score.
  822. /timerEloWon 1 40 /flushNames
  823.  
  824.  
  825. }
  826.  
  827. }
  828.  
  829. on *:TEXT:!win *:#:{
  830.  
  831.  
  832.  
  833.  
  834. if ($3 == $null) {
  835.  
  836. /msg $chan $nick <- Incorrect syntax. The syntax is !won <game> <opponent>
  837.  
  838. }
  839.  
  840. elseif ( $hget(ratingtable,$nick) == $null ) {
  841.  
  842. msg $chan $nick <- You must be registered to use this command. Register with !register
  843. }
  844.  
  845. elseif ( $hget(ratingtable,$3) == $null ) {
  846.  
  847. msg $chan $nick <- $3 is not registered. Players can register with !register
  848. }
  849. elseif ( $count(%gamelist,$2) == 0 ) {
  850. echo -a Not a game
  851. msg #thebrett Not a valid game type.
  852. }
  853. elseif ( %loser != $null ) || ( %winner != $null ) || ( %elogame != $null ) {
  854.  
  855. msg $chan someone has already used this command - winner is %winner
  856. }
  857.  
  858. elseif ( $2 == exvs ) && ( $5 == $null ) {
  859.  
  860. msg $chan $nick <- Improper syntax for EXVS - syntax is !won EXVS <partner> <opponent1> <opponent2>
  861. }
  862. elseif ( $2 == exvs ) && ( $hget(ratingtable,$3) == $null ) {
  863.  
  864. msg $chan $nick <- $3 is not registered. Players can register with !register
  865.  
  866. }
  867.  
  868. elseif ( $2 == exvs ) && ( $hget(ratingtable,$4) == $null ) {
  869.  
  870. msg $chan $nick <- $4 is not registered. Players can register with !register
  871.  
  872. }
  873.  
  874. elseif ( $2 == exvs ) && ( $hget(ratingtable,$5) == $null ) {
  875.  
  876. msg $chan $nick <- $5 is not registered. Players can register with !register
  877.  
  878. }
  879.  
  880. ;if the game is exvs, change the nicks appropriately
  881. elseif ( $2 == exvs ) {
  882.  
  883. set %winner $nick
  884. set %winnerpartner $3
  885. set %loser $4
  886. set %loserpartner $5
  887. set %elogame $2
  888. msg $chan Waiting 40 seconds for %loser or %loserpartner to use !confirm loss to report score.
  889. ;msg $chan this is exvs
  890. /timerEloWon 1 40 /flushNames
  891. }
  892.  
  893. else {
  894. ;msg $chan this is not exvs
  895. set %winner $nick
  896. set %loser $3
  897. set %elogame $2
  898. msg $chan Waiting 40 seconds for %loser to use !confirm loss to report score.
  899. /timerEloWon 1 40 /flushNames
  900.  
  901.  
  902. }
  903.  
  904. }
  905.  
  906. ;syntax is !lost <game> <opponent>
  907. ;OR
  908. ;syntax is !lost EXVS <partner> <opponent1> <opponent2>
  909. on *:TEXT:!lost *:#:{
  910.  
  911.  
  912.  
  913.  
  914. if ($3 == $null) {
  915.  
  916. /msg $chan $nick <- Incorrect syntax. The syntax is !lost <game> <opponent>
  917.  
  918. }
  919.  
  920. elseif ( $hget(ratingtable,$nick) == $null ) {
  921.  
  922. msg $chan $nick <- You must be registered to use this command. Register with !register
  923. }
  924.  
  925. elseif ( $hget(ratingtable,$3) == $null ) {
  926.  
  927. msg $chan $nick <- That opponent is not registered.
  928. }
  929.  
  930. elseif ( %loser != $null ) || ( %winner != $null ) || ( %elogame != $null ) {
  931.  
  932. msg $chan someone has already used this command - winner is %winner
  933. }
  934. elseif ( $count(%gamelist,$2) == 0 ) {
  935. echo -a Not a game
  936. msg #thebrett Not a valid game type.
  937. }
  938.  
  939. elseif ( $2 == exvs ) && ( $5 == $null ) {
  940.  
  941. msg $chan $nick <- Improper syntax for EXVS - syntax is !lost EXVS <partner> <opponent1> <opponent2>
  942. }
  943.  
  944. elseif ( $2 == exvs ) && ( $hget(ratingtable,$3) == $null ) {
  945.  
  946. msg $chan $nick <- $3 is not registered. Please use !register
  947.  
  948. }
  949.  
  950. elseif ( $2 == exvs ) && ( $hget(ratingtable,$4) == $null ) {
  951.  
  952. msg $chan $nick <- $4 is not registered. Please use !register
  953.  
  954. }
  955.  
  956. elseif ( $2 == exvs ) && ( $hget(ratingtable,$5) == $null ) {
  957.  
  958. msg $chan $nick <- $5 is not registered. Please use !register
  959.  
  960. }
  961. ;if the game is exvs, change the nicks appropriately
  962. elseif ( $2 == exvs ) {
  963.  
  964. set %winner $4
  965. set %winnerpartner $5
  966. set %loser $nick
  967. set %loserpartner $3
  968. set %elogame $2
  969. msg $chan Waiting 40 seconds for %winner or %winnerpartner to use !confirm win to report score.
  970. ;msg $chan this is exvs
  971. /timerEloWon 1 40 /flushNames
  972.  
  973. }
  974.  
  975. else {
  976. ;msg $chan this is not exvs
  977. set %winner $3
  978. set %loser $nick
  979. set %elogame $2
  980. msg $chan Waiting 40 seconds for %winner to use !confirm win to report score.
  981. /timerEloWon 1 40 /flushNames
  982.  
  983. }
  984.  
  985. }
  986.  
  987.  
  988.  
  989.  
  990. ;syntax is !won <game> <winner> <loser>
  991. ;OR
  992. ;syntax is !won EXVS <winner1> <winner2> <opponent1> <opponent2>
  993.  
  994. on *:TEXT:!report *:#:{
  995.  
  996.  
  997. if ($nick !isop $chan) {
  998.  
  999. msg $chan $nick <- You must be a mod to use this command
  1000.  
  1001. }
  1002.  
  1003. elseif ($4 == $null) {
  1004.  
  1005. /msg $chan $nick <- Incorrect syntax. The syntax is !report <game> <winner> <loser>
  1006.  
  1007. }
  1008.  
  1009. elseif ( $count(%gamelist,$2) == 0 ) {
  1010. echo -a Not a game
  1011. msg #thebrett Not a valid game type.
  1012. }
  1013.  
  1014. elseif ( $hget(ratingtable,$3) == $null ) {
  1015.  
  1016. msg $chan $nick <- $3 is not registered.
  1017.  
  1018. }
  1019.  
  1020. elseif ( $hget(ratingtable,$4) == $null ) {
  1021.  
  1022. msg $chan $nick <- $4 is not registered.
  1023.  
  1024. }
  1025.  
  1026. elseif ( %loser != $null ) || ( %winner != $null ) || ( %elogame != $null ) {
  1027.  
  1028. msg $chan There is currently a - winner is %winner
  1029.  
  1030. }
  1031.  
  1032. elseif ( $2 == exvs ) && ( ( $hget(ratingtable,$3) == $null ) || ( $hget(ratingtable,$4) == $null ) || ( $hget(ratingtable,$5) == $null ) || ( $hget(ratingtable,$6) == $null ) ) {
  1033.  
  1034. msg $chan $nick <- One of these players is not registered. Please use !register
  1035.  
  1036. }
  1037.  
  1038. ;if the game is exvs, change the nicks appropriately
  1039. elseif ( $2 == exvs ) {
  1040.  
  1041. set %winner $3
  1042. set %winnerpartner $4
  1043. set %loser $5
  1044. set %loserpartner $6
  1045. set %elogame $2
  1046. ;msg $chan this is exvs
  1047. echo -a reporting team elo
  1048. /eloteamreport %winner %winnerpartner %loser %loserpartner %elogame
  1049. /msg $chan $nick <- Score has been reported - thanks for your contribution!
  1050. }
  1051.  
  1052. else {
  1053. ;msg $chan this is not exvs
  1054. set %winner $3
  1055. set %loser $4
  1056. set %elogame $2
  1057. /msg $chan $nick <- Score has been reported - thanks for your contribution!
  1058. /eloReport %winner %loser %elogame
  1059.  
  1060. }
  1061. /flushNames
  1062.  
  1063. }
  1064.  
  1065. alias conditiontest {
  1066.  
  1067. var %a = b
  1068. var %b = f
  1069. var %c = c
  1070.  
  1071.  
  1072. if (%a == a) && ( (%b == b) || (%c == c) ) {
  1073.  
  1074. echo true
  1075.  
  1076. }
  1077.  
  1078. else {
  1079.  
  1080. echo false
  1081.  
  1082. }
  1083.  
  1084. }
  1085.  
  1086. on *:TEXT:!confirm loss:#:{
  1087.  
  1088.  
  1089. if ( $hget(ratingtable,$nick) == $null ) {
  1090.  
  1091. msg $chan $nick <- You must be registered to use this command. Register with !register
  1092. }
  1093.  
  1094. elseif ( %loser == $null ) || ( %winner == $null ) || ( %elogame == $null ) {
  1095.  
  1096. msg $chan There is no result to confirm.
  1097. }
  1098.  
  1099. elseif ( $nick != %loser ) && ( $nick != %loserpartner ) {
  1100.  
  1101. msg $chan $nick <- You aren't listed as losing this match
  1102.  
  1103. }
  1104.  
  1105. elseif ( %elogame == EXVS ) {
  1106.  
  1107. echo -a reporting team elo
  1108. /eloteamreport %winner %winnerpartner %loser %loserpartner %elogame
  1109. /msg $chan $nick <- Score has been reported - thanks for your contribution!
  1110. /flushNames
  1111. }
  1112. else {
  1113.  
  1114. /msg $chan $nick <- Score has been reported - thanks for your contribution!
  1115. /eloReport %winner %loser %elogame
  1116. /flushNames
  1117.  
  1118. }
  1119. }
  1120.  
  1121. on *:TEXT:!confirm win:#:{
  1122.  
  1123.  
  1124. if ( $hget(ratingtable,$nick) == $null ) {
  1125.  
  1126. msg $chan $nick <- You must be registered to use this command. Register with !register
  1127. }
  1128.  
  1129. elseif ( %loser == $null ) || ( %winner == $null ) || ( %elogame == $null ) {
  1130.  
  1131. msg $chan There is no result to confirm.
  1132. }
  1133.  
  1134. elseif ( $nick != %winner ) && ( $nick != %winnerpartner ) {
  1135.  
  1136. msg $chan $nick <- You aren't listed as winning this match
  1137.  
  1138. }
  1139.  
  1140. elseif ( %elogame == EXVS ) {
  1141.  
  1142. echo -a reporting team elo
  1143. /eloteamreport %winner %winnerpartner %loser %loserpartner %elogame
  1144. /msg $chan $nick <- Score has been reported - thanks for your contribution!
  1145. /flushNames
  1146. }
  1147. else {
  1148.  
  1149. /msg $chan $nick <- Score has been reported - thanks for your contribution!
  1150. /eloReport %winner %loser %elogame
  1151. /flushNames
  1152.  
  1153. }
  1154. }
  1155.  
  1156.  
  1157.  
  1158.  
  1159.  
  1160. alias flushNames {
  1161. /unset %winner
  1162. /unset %loser
  1163. /unset %eloGame
  1164. /unset %winnerpartner
  1165. /unset %loserpartner
  1166. }
  1167.  
  1168.  
  1169. ;syntax is !rank game nick
  1170. on *:TEXT:!rank *:#:{
  1171. echo -a working
  1172. if ((%wait.ctime !isnum) || ((%wait.ctime isnum) && (%wait.ctime < $ctime))) {
  1173. set %wait.ctime $calc($ctime + 2)
  1174. echo -a working 2
  1175.  
  1176. if ($2 == $null) {
  1177. /echo param error
  1178. msg $chan $nick <- Incorrect syntax. Syntax is !rank <game> or !rank <game> <nick>
  1179.  
  1180. }
  1181. elseif ( $count(%gamelist,$2) == 0 ) {
  1182. echo -a Not a game
  1183. msg $chan $nick <- $2 is not a valid game type.
  1184. }
  1185.  
  1186. elseif ( $hget(ratingtable,$nick) == $null ) && ( $3 == $null ) {
  1187. msg $chan $nick <- You are not registered. Please register with !register
  1188. echo -a $nick <- You are not registered. Please register with !register
  1189.  
  1190.  
  1191. }
  1192.  
  1193. elseif $3 != $null && $hget(ratingtable,$3) == $null {
  1194.  
  1195. echo -a $nick <- $3 has not registered.
  1196.  
  1197. msg $chan $nick <- $3 has not registered.
  1198.  
  1199. }
  1200.  
  1201.  
  1202. elseif ($3 == $null) {
  1203. var %rankname = $nick
  1204. echo posting rank
  1205. ;msg $chan %rankname $+ : Rank $getRank(%rankname,$2) $round($getelo(%rankname,$2),2) $+ RIP $getwins(%rankname,$2) $+ W $+ - $+ $getlosses(%rankname,$2) $+ L ( $+ $round($calc($getwins(%rankname,$2) * 100 / $getTotalGames(%rankname,$2)),2) $+ % $+ ) $+ .
  1206.  
  1207. if ($2 == saltybrett) {
  1208. msg $chan %rankname $+ : $+($,$round($getelo(%rankname,$2),2)) $getwins(%rankname,$2) $+ W $+ - $+ $getlosses(%rankname,$2) $+ L ( $+ $round($calc($getwins(%rankname,$2) * 100 / $getTotalGames(%rankname,$2)),2) $+ % $+ ) Shamed $getshame($nick) times.
  1209.  
  1210.  
  1211.  
  1212. }
  1213. else {
  1214. msg $chan %rankname $+ : $round($getelo(%rankname,$2),2) $+ RIP $getwins(%rankname,$2) $+ W $+ - $+ $getlosses(%rankname,$2) $+ L ( $+ $round($calc($getwins(%rankname,$2) * 100 / $getTotalGames(%rankname,$2)),2) $+ % $+ ) $+ .
  1215.  
  1216. }
  1217. }
  1218.  
  1219. else {
  1220. %rankname = $3
  1221. echo posting rank
  1222. ;msg $chan %rankname $+ : Rank $getRank(%rankname,$2) $round($getelo(%rankname,$2),2) $+ RIP $getwins(%rankname,$2) $+ W $+ - $+ $getlosses(%rankname,$2) $+ L ( $+ $round($calc($getwins(%rankname,$2) * 100 / $getTotalGames(%rankname,$2)),2) $+ % $+ ) $+ .
  1223.  
  1224. if ($2 == saltybrett) {
  1225.  
  1226.  
  1227.  
  1228. msg $chan %rankname $+ : $+($,$round($getelo(%rankname,$2),2)) $getwins(%rankname,$2) $+ W $+ - $+ $getlosses(%rankname,$2) $+ L ( $+ $round($calc($getwins(%rankname,$2) * 100 / $getTotalGames(%rankname,$2)),2) $+ % $+ ) Shamed $getshame($3) times.
  1229.  
  1230.  
  1231. }
  1232.  
  1233.  
  1234. else {
  1235. msg $chan %rankname $+ : $round($getelo(%rankname,$2),2) $+ RIP $getwins(%rankname,$2) $+ W $+ - $+ $getlosses(%rankname,$2) $+ L ( $+ $round($calc($getwins(%rankname,$2) * 100 / $getTotalGames(%rankname,$2)),2) $+ % $+ ) $+ .
  1236.  
  1237. }
  1238. }
  1239. }
  1240.  
  1241. }
  1242.  
  1243.  
  1244. ;syntax is eloDelta(winnerelo,gamesplayed,loserelo,gamesplayed)
  1245. alias eloDelta {
  1246.  
  1247. var %winner_elo_old = $1
  1248. var %loser_elo_old = $3
  1249. ;check number of games played
  1250. var %winnergamesplayed = $2
  1251. var %losergamesplayed = $4
  1252.  
  1253. if ( %winnergamesplayed <= 30 ) {
  1254. var %kfactorwinner = 30 }
  1255. elseif ( %winner_elo_old >= 2400 ) {
  1256. var %kfactorwinner = 10 }
  1257. else { var %kfactorwinner = 30 }
  1258.  
  1259.  
  1260. if ( %losergamesplayed <= 30 ) {
  1261. var %kfactorloser = 30 }
  1262. elseif ( %%loser_elo_old >= 2400 ) {
  1263. var %kfactorloser = 10 }
  1264. else { var %kfactorloser = 15 }
  1265.  
  1266. ;calcuate odds
  1267. var %EaOddsa = $calc(1/(1 + 10^$calc((%winner_elo_old - %loser_elo_old) / 400)))
  1268. var %EaOddsb = $calc(1/(1 + 10^$calc((%loser_elo_old - %winner_elo_old) / 400)))
  1269. var %winner_elo_new = $calc(%winner_elo_old + (%kfactorwinner * (1- %EaOddsb)))
  1270. var %loser_elo_new = $calc(%loser_elo_old + (%kfactorloser * (0 - %EaOddsa)))
  1271. ;return $round(%winner_elo_new,0) $round(%loser_elo_new,0) Delta = $round($calc(%kfactorwinner * (1- %EaOddsb)),0)
  1272. return $round($calc(%kfactorwinner * (1- %EaOddsb)),0)
  1273.  
  1274. }
  1275.  
  1276.  
  1277. ;syntax is eloReport winner loser game
  1278. alias eloReport {
  1279.  
  1280. if ($2 == $null) {
  1281. echo -a not enough parameters
  1282. return }
  1283. elseif ( $count(%gamelist,$3) == 0 ) {
  1284. echo -a Not a game
  1285. msg #thebrett Not a valid game type.
  1286.  
  1287. }
  1288. else {
  1289.  
  1290.  
  1291. ;setElo $calc( $getElo($1,$3) + $eloDelta($getElo($1,$3),$getTotalGames($1,$3),$getElo($2,$3),$getTotalGames($2,$3)) )
  1292. /echo winner $1 has elo $getElo($1,$3) and loser $2 has elo of $getElo($2,$3) - they have a delta of $eloDelta($getElo($1,$3),$getTotalGames($1,$3),$getElo($2,$3),$getTotalGames($2,$3))
  1293. var %delta = $eloDelta($getElo($1,$3),$getTotalGames($1,$3),$getElo($2,$3),$getTotalGames($2,$3))
  1294. /echo -a %delta
  1295. ;set winners elo
  1296. setElo $1 $3 $calc( $getElo($1,$3) + %delta )
  1297. ;set losers elo
  1298. setElo $2 $3 $calc( $getElo($2,$3) - %delta )
  1299. ;set winners win +
  1300. /incwin $1 $3
  1301. ;set losers loss +
  1302. /incloss $2 $3
  1303. hsave -os ratingtable ratingtable.txt
  1304. ;makeLeader $3
  1305. }
  1306. }
  1307.  
  1308.  
  1309.  
  1310.  
  1311.  
  1312.  
  1313. ;syntax is eloTeamReport winner1 winner2 loser1 loser2 game
  1314. alias eloTeamReport {
  1315.  
  1316. if ($5 == $null) {
  1317. echo -a not enough parameters
  1318. return }
  1319. elseif ( $count(%gamelist,$5) == 0 ) {
  1320. echo -a Not a game
  1321. msg #thebrett Not a valid game type.
  1322. }
  1323. else {
  1324.  
  1325.  
  1326. ;setElo $calc( $getElo($1,$3) + $eloDelta($getElo($1,$3),$getTotalGames($1,$3),$getElo($2,$3),$getTotalGames($2,$3)) )
  1327. ;/echo winner $1 has elo $getElo($1,$3) and loser $2 has elo of $getElo($2,$3) - they have a delta of $eloDelta($getElo($1,$3),$getTotalGames($1,$3),$getElo($2,$3),$getTotalGames($2,$3))
  1328.  
  1329. var %averageelowinner = $calc( ($getElo($1,$5) + $getElo($2,$5)) / 2)
  1330. var %averageeloloser = $calc( ($getElo($3,$5) + $getElo($4,$5)) / 2)
  1331. var %totalgameswinner = $calc( ($getTotalGames($1,$5) + $getTotalGames($2,$5)) / 2 )
  1332. var %totalgamesloser = $calc( ($getTotalGames($3,$5) + $getTotalGames($4,$5)) / 2 )
  1333. var %delta = $eloDelta(%averageelowinner,%totalgameswinner,%averageeloloser,%totalgamesloser)
  1334.  
  1335. /echo -a winners average elo: %averageelowinner losers average elo: %averageeloloser
  1336. /echo -a winners average games played %totalgameswinner losers average agmes played %totalgamesloser
  1337. /echo -a delta is %delta
  1338.  
  1339. ;set winners elo
  1340. setElo $1 $5 $calc( $getElo($1,$5) + %delta )
  1341. setElo $2 $5 $calc( $getElo($2,$5) + %delta )
  1342.  
  1343. ;set losers elo
  1344. setElo $3 $5 $calc( $getElo($3,$5) - %delta )
  1345. setElo $4 $5 $calc( $getElo($4,$5) - %delta )
  1346. ;set winners win +
  1347. /incwin $1 $5
  1348. /incwin $2 $5
  1349.  
  1350. ;set losers loss +
  1351. /incloss $3 $5
  1352. /incloss $4 $5
  1353. hsave -os ratingtable ratingtable.txt
  1354. }
  1355. }
  1356.  
  1357.  
  1358. ;syntax is setElo(name,game,new elo)
  1359.  
  1360. alias setElo {
  1361. if ($3 == $null) {
  1362. echo -a not enough parameters
  1363. return }
  1364. elseif ( $hget(ratingtable,$1) == $null ) {
  1365. echo -a Player not registered
  1366. }
  1367.  
  1368. else {
  1369.  
  1370. var %eloPos = $calc($findtok($hget(ratingtable,$1),$2,1,32) + 1)
  1371. /echo -a position is %eloPos
  1372. hadd ratingtable $1 $puttok($hget(ratingtable,$1),$3,%eloPos,32)
  1373. hsave -os ratingtable ratingtable.txt
  1374. }
  1375. }
  1376.  
  1377. ;syntax is name,game,amnt
  1378.  
  1379.  
  1380. alias incElo {
  1381.  
  1382. if ($3 == $null) {
  1383. echo -a not enough parameters
  1384. return }
  1385. elseif ( $hget(ratingtable,$1) == $null ) {
  1386. echo -a Player not registered
  1387. }
  1388.  
  1389. else {
  1390.  
  1391. setelo $1 $2 $calc($getelo($1,$2) + $3)
  1392.  
  1393. }
  1394.  
  1395.  
  1396. }
  1397.  
  1398. on *:TEXT:!bertbucks give *:#:{
  1399. if ($nick == thebrett || $nick == kazukimutou || $nick == ubw_roach ) {
  1400. msg # Awarding $3 $4 bertbucks
  1401. /incElo $3 SaltyBrett $4
  1402. }
  1403. }
  1404.  
  1405. on *:TEXT:!bertbucks take *:#:{
  1406. if ($nick == thebrett || $nick == kazukimutou || $nick == ubw_roach) {
  1407. msg # Taking away $4 bertbucks from $3
  1408. /decElo $3 SaltyBrett $4
  1409. }
  1410. }
  1411.  
  1412. alias decElo {
  1413.  
  1414. if ($3 == $null) {
  1415. echo -a not enough parameters
  1416. return }
  1417. elseif ( $hget(ratingtable,$1) == $null ) {
  1418. echo -a Player not registered
  1419. }
  1420.  
  1421. else {
  1422.  
  1423. setelo $1 $2 $calc($getelo($1,$2) - $3)
  1424.  
  1425. }
  1426.  
  1427.  
  1428. }
  1429.  
  1430. ;syntax is setLoss(name,game,new loss)
  1431. alias setLoss {
  1432.  
  1433. if ($3 == $null) {
  1434. echo -a not enough parameters
  1435. return }
  1436. elseif ( $hget(ratingtable,$1) == $null ) {
  1437. echo -a Player not registered
  1438. }
  1439. else {
  1440. var %lossPos = $calc($findtok($hget(ratingtable,$1),$2,1,32) + 3)
  1441. /echo -a position is %lossPos
  1442. hadd ratingtable $1 $puttok($hget(ratingtable,$1),$3,%lossPos,32)
  1443. hsave -os ratingtable ratingtable.txt
  1444. }
  1445. }
  1446.  
  1447. ;syntax is setWin(name,game,new win)
  1448. alias setWin {
  1449.  
  1450. if ($3 == $null) {
  1451. echo -a not enough parameters
  1452. return }
  1453. elseif ( $hget(ratingtable,$1) == $null ) {
  1454. echo -a Player not registered
  1455. }
  1456. else {
  1457. var %winPos = $calc($findtok($hget(ratingtable,$1),$2,1,32) + 2)
  1458. /echo -a position is %winPos
  1459. hadd ratingtable $1 $puttok($hget(ratingtable,$1),$3,%winPos,32)
  1460. hsave -os ratingtable ratingtable.txt
  1461. }
  1462. }
  1463.  
  1464. ;syntax is incShame(name)
  1465. alias incShame {
  1466.  
  1467. if ($1 == $null) {
  1468. echo -a not enough parameters
  1469. return }
  1470. elseif ( $hget(ratingtable,$1) == $null ) {
  1471. echo -a Player not registered
  1472. }
  1473. else {
  1474. var %winPos = $calc($findtok($hget(ratingtable,$1),SaltyBrett,1,32) + 4)
  1475. /echo -a position is %winPos
  1476. hadd ratingtable $1 $puttok($hget(ratingtable,$1),$calc($getShame($1) + 1),%winPos,32)
  1477. hsave -os ratingtable ratingtable.txt
  1478. }
  1479. }
  1480.  
  1481. ;syntax is incWin(name,game)
  1482. alias incWin {
  1483.  
  1484. if ($2 == $null) {
  1485. echo -a not enough parameters
  1486. return }
  1487. elseif ( $hget(ratingtable,$1) == $null ) {
  1488. echo -a Player not registered
  1489. }
  1490. else {
  1491. var %winPos = $calc($findtok($hget(ratingtable,$1),$2,1,32) + 2)
  1492. /echo -a position is %winPos
  1493. hadd ratingtable $1 $puttok($hget(ratingtable,$1),$calc($getWins($1,$2) + 1),%winPos,32)
  1494. hsave -os ratingtable ratingtable.txt
  1495. }
  1496. }
  1497.  
  1498.  
  1499.  
  1500.  
  1501.  
  1502. ;syntax is incLoss(name,game)
  1503.  
  1504. alias incLoss {
  1505. if ($2 == $null) {
  1506. echo -a not enough parameters
  1507. return }
  1508. elseif ( $hget(ratingtable,$1) == $null ) {
  1509. echo -a Player not registered
  1510. }
  1511. else {
  1512.  
  1513. var %lossPos = $calc($findtok($hget(ratingtable,$1),$2,1,32) + 3)
  1514. ;/echo -a position is %lossPos
  1515. echo -a increasing loss for $1
  1516. hadd ratingtable $1 $puttok($hget(ratingtable,$1),$calc($getLosses($1,$2) + 1),%lossPos,32)
  1517. hsave -os ratingtable ratingtable.txt
  1518. }
  1519. }
  1520.  
  1521.  
  1522.  
  1523.  
  1524. alias eloRegister {
  1525.  
  1526.  
  1527. if (!$hget(ratingtable,$1)) {
  1528. echo -a registered name: $1
  1529. hadd -s ratingtable $1 GG 1500 0 0 ; EXVS 1500 0 0 ; BBCP 1500 0 0 ; Mafia 1500 0 0 ; UNIEL 1500 0 0 ; Medley 1500 0 0 ; Melty 1500 0 0 ; P4A 1500 0 0 ; SaltyBrett 400 0 0 0 ; KillCount 1500 0 0 ; Place4 1500 0 0 ; Place5 1500 0 0
  1530. ;msg $chan $nick <- You are now registered.
  1531. ;write -a logforscores.txt $fulldate :: Register :: $nick
  1532.  
  1533. }
  1534. else {
  1535. ;msg $chan $nick <- You are already registered.
  1536. ;echo -ag hashtable entry for $remove($nick,-tk) $+ : $hget(ratingtable,$remove($nick,-tk))
  1537. echo -a $1 was already found
  1538. }
  1539. hsave -os ratingtable ratingtable.txt
  1540. }
  1541.  
  1542. alias eloReset {
  1543.  
  1544. if ($1 == $null) {
  1545.  
  1546. echo error
  1547. }
  1548. else {
  1549. eloRemove $1
  1550. eloRegister $1
  1551.  
  1552. }
  1553. }
  1554.  
  1555. ;syntax is getRank <name> <game>
  1556. alias getRank {
  1557.  
  1558. var %makeRank = testtest.txt
  1559. var %rank = 0
  1560.  
  1561. if ($2 == $null) {
  1562.  
  1563. echo error no parameters
  1564. return
  1565.  
  1566. }
  1567.  
  1568. elseif ( $gettotalgames($1, $2) == 0 ) {
  1569. return Unranked
  1570. }
  1571. else {
  1572. /hashsort $2
  1573.  
  1574. var %max = $hget(ratingtable,0).item
  1575. var %count = 1
  1576. /write -c %makeRank Ranks for $upper($2) - updated $adate
  1577. var %tiecount = 0
  1578.  
  1579.  
  1580.  
  1581. while (%count < $calc( %max + 1 )) {
  1582.  
  1583. var %rankname = $gettok($read(sorthash.txt,%count),1,61)
  1584.  
  1585. if ( $gettotalgames(%rankname, $2) > 0) {
  1586.  
  1587.  
  1588. if (%count > 1) {
  1589. var %prevrankname = $gettok($read(sorthash.txt,$calc( %count - 1 )),1,61)
  1590.  
  1591. }
  1592.  
  1593. if ( $getelo(%rankname,$2) == $getelo(%prevrankname,$2) ) {
  1594.  
  1595. ;TIE
  1596. ;echo posting rank for %rankname
  1597.  
  1598. if (%rankname == $1) {
  1599. echo %rankname has a rank of %rank
  1600. return %rank
  1601. }
  1602. inc %tiecount
  1603. var %msg = %rankname - Rank is %rank $+ - $getelo(%rankname,$2) $+ SP $getwins(%rankname,$2) $+ W $+ - $+ $getlosses(%rankname,$2) $+ L ( $+ $round($calc($getwins(%rankname,$2) * 100 / $getTotalGames(%rankname,$2)),2) $+ % $+ ) $+ .
  1604.  
  1605.  
  1606.  
  1607. }
  1608.  
  1609. else {
  1610.  
  1611. ;not a time
  1612. inc %rank
  1613. inc %rank %tiecount
  1614. %tiecount = 0
  1615. ;echo posting rank for %rankname
  1616. if (%rankname == $1) {
  1617. echo %rankname has a rank of %rank
  1618. return %rank
  1619. }
  1620. var %msg = %rankname - Rank is %rank $+ . $getelo(%rankname,$2) $+ SP $getwins(%rankname,$2) $+ W $+ - $+ $getlosses(%rankname,$2) $+ L ( $+ $round($calc($getwins(%rankname,$2) * 100 / $getTotalGames(%rankname,$2)),2) $+ % $+ ) $+ .
  1621.  
  1622.  
  1623.  
  1624.  
  1625.  
  1626.  
  1627. }
  1628.  
  1629. ;write %makeRank %msg
  1630. }
  1631. inc %count
  1632. }
  1633.  
  1634. }
  1635. ;return Unranked
  1636. }
  1637.  
  1638.  
  1639. /*
  1640. ;syntax: /getRank(name,game)
  1641. alias getRank {
  1642.  
  1643. /*
  1644. if ($2 == $null) {
  1645.  
  1646. echo -a not enough parameters
  1647. }
  1648.  
  1649. elseif ( $hget(ratingtable,$1) == $null) {
  1650.  
  1651. echo -a $1 is not registered
  1652.  
  1653. }
  1654. else {
  1655. /echo hi
  1656. top5 $2
  1657. echo -a $read(makeRank.txt, s, $1)
  1658. var %rank = $calc( $readn + 1 )
  1659. echo -a %rank
  1660. return %rank
  1661. }
  1662. */
  1663.  
  1664. }
  1665.  
  1666. */
  1667.  
  1668. alias eloRemove {
  1669.  
  1670.  
  1671. if ( $hget(ratingtable,$1) == $null ) {
  1672.  
  1673. ;msg $chan $nick <- $3 is not registered.
  1674.  
  1675. }
  1676.  
  1677. else {
  1678.  
  1679.  
  1680. }
  1681. hdel ratingtable $1
  1682. hsave -os ratingtable ratingtable.txt
  1683.  
  1684. }
  1685.  
  1686. ;syntax is $getElo(nick,game)
  1687. alias getElo {
  1688.  
  1689. return $gettok($matchtok($hget(ratingtable,$1),$2,1,59),2,32)
  1690.  
  1691. }
  1692.  
  1693. alias getWins {
  1694.  
  1695. return $gettok($matchtok($hget(ratingtable,$1),$2,1,59),3,32)
  1696.  
  1697. }
  1698.  
  1699. alias getLosses {
  1700.  
  1701. return $gettok($matchtok($hget(ratingtable,$1),$2,1,59),4,32)
  1702.  
  1703. }
  1704.  
  1705. ;syntax is Name
  1706. alias getShame {
  1707.  
  1708. return $gettok($matchtok($hget(ratingtable,$1),SaltyBrett,1,59),5,32)
  1709.  
  1710. }
  1711.  
  1712.  
  1713. alias getTotalGames {
  1714.  
  1715. return $calc( $getWins($1,$2) + $getLosses($1,$2) )
  1716.  
  1717. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement