Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- set %Loser
- set %LoserPartner
- set %Winnerh
- set %WinnerPartner
- set %elogame
- set %1p
- set %2p
- set %gamelist GG exvs bbcp mafia UNIEL melty p4a saltybrett test KillCount
- set %lobbygamed
- set %regulars
- set %pot_total
- set %odds
- set %lobbygame
- set %printscores true
- on *:START:{
- hmake -s ratingtable 200
- hmake -s sortedtable 200
- echo -s table created
- hload -s ratingtable ratingtable.txt
- ;syntax is [Name} BetAmount 1p/2p
- ;hload -s saltyTable saltyTable.txt
- /timerbackup 0 6000 /elobackup
- echo -s table loaded
- set %gamelist GG exvs bbcp mafia UNIEL melty p4a saltybrett test
- set %lobbygame UNIEL
- set %regulars $read(regulars.txt,1)
- }
- on *:EXIT:{
- hsave -os ratingtable ratingtable.txt
- }
- alias resavehash {
- ;hsave -os ratingtable ratingtable.txt
- ;hload -i ratingtable sorthash.txt
- hmake -s sortedtable 200
- echo -s table made
- hload -i sortedtable sorthash.txt stats
- hsave -os sortedtable sortedtable2.txt
- }
- alias elobackup {
- var %number = $rand(1,10000)
- hsave -os ratingtable $+(ratingbackup,/,ratingtable,%number,.,txt)
- }
- on *:TEXT:!regulars add *:#:{
- if ($nick isop $chan) || ($regcheck($nick)) {
- if ($regcheck($3)) {
- /msg $chan $nick <- That person is already a regular.
- }
- else {
- write -n regulars.txt $3 $+ ;
- msg $chan $nick <- Adding $3 to the regulars list
- set %regulars $read(regulars.txt,1)
- }
- }
- else {
- /msg $chan $nick <- You are not a mod or regular.
- }
- }
- alias regcheck {
- set %regulars $read(regulars.txt,1)
- if ($1 == $null) {
- echo not enough param
- }
- elseif ($istok(%regulars, $1, 59)) {
- /echo $1 is a regular
- return $true
- }
- else {
- /echo $1 is not a regular
- return $false
- }
- }
- on *:TEXT:!regulars test:#:{
- ;set %regulars $read(regulars.txt,1)
- if ($regcheck($nick)) {
- /msg $chan $nick yes you are a regular
- }
- else {
- msg $chan $nick <- You are not a regular
- }
- }
- ;/////////////// syntax is !lobby help //////////////////////
- on *:TEXT:!lobbyhelp:#:{
- msg $chan Mod Commands: !lobbyupdate <1p> <2p> / !lobbywin <1p/2p> / !report <game> <winner> <loser> / !register <nick> / !leaderboard <game>
- msg $chan User commands: !register / !won/!lost <game> <opponent> / !lost <game> <opponent> / !confirm <win/loss> / !rank <game> / !rank <game> <name>
- }
- /*
- ;/////////////// syntax is !top5 <game> ///////////////////////
- on *:TEXT:!top5 *:#:{
- if ( $count(%gamelist,$2) == 0 ) {
- echo -a Not a game
- msg #thebrett $nick <- Not a valid game type.
- }
- else {
- /hashsort $2
- msg $chan Ranks for $2 $+ :
- ;msg $chan 1. $read(sorthash.txt,1)
- ;msg $chan 2. $read(%sorthash,2)
- ;msg $chan 3. $read(%sorthash,3)
- var %max = 5
- var %count = 1
- while (%count < $calc( %max + 1 )) {
- var %rankname = $gettok($read(sorthash.txt,%count),1,61)
- ;echo posting rank for %rankname
- ;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) $+ % $+ ) $+ .
- inc %count
- }
- }
- }
- */
- ;///////////// !leaderboard /////////////////
- on *:TEXT:!leaderboard *:#:{
- if ($nick !isop $chan) {
- ;msg $chan $nick <- You must be a mod to use this command
- }
- elseif ( $count(%gamelist,$2) == 0 ) {
- echo -a Not a game
- msg $chan $nick <- Not a valid game type.
- }
- else {
- /makeleader $2
- /msg # Displaying leaderboard for $2
- }
- }
- alias top5 {
- if ($1 == $null) {
- echo error no parameters
- return
- }
- else {
- /hashsort $1
- ;msg $chan Ranks for $upper($1) $+ :
- ;msg $chan 1. $read(sorthash.txt,1)
- ;msg $chan 2. $read(%sorthash,2)
- ;msg $chan 3. $read(%sorthash,3)
- var %max = $hget(ratingtable,0).item
- var %count = 1
- /write -c RankingChart.txt NCD Rankings for $upper($1) - updated $adate
- var %tiecount = 0
- while (%count < $calc( %max + 1 )) {
- var %rankname = $gettok($read(sorthash.txt,%count),1,61)
- if (%count > 1) {
- var %prevrankname = $gettok($read(sorthash.txt,$calc( %count - 1 )),1,61)
- }
- if ( $getelo(%rankname,$1) == $getelo(%prevrankname,$1) ) {
- ;echo posting rank for %rankname
- inc %tiecount
- 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) $+ % $+ ) $+ .
- }
- else {
- %tiecount = 0
- ;echo posting rank for %rankname
- 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) $+ % $+ ) $+ .
- }
- if ( $gettotalgames(%rankname, $1) > 0) {
- /write RankingChart.txt %msg
- }
- inc %count
- }
- }
- }
- ;syntax makeRank <game>
- alias makeRank {
- var %makeRank = makeRank.txt
- var %rank = 0
- if ($1 == $null) {
- echo error no parameters
- return
- }
- else {
- /hashsort $1
- var %max = $hget(ratingtable,0).item
- var %count = 1
- /write -c %makeRank Ranks for $upper($1) - updated $adate
- var %tiecount = 0
- while (%count < $calc( %max + 1 )) {
- var %rankname = $gettok($read(sorthash.txt,%count),1,61)
- if ( $gettotalgames(%rankname, $1) > 0) {
- if (%count > 1) {
- var %prevrankname = $gettok($read(sorthash.txt,$calc( %count - 1 )),1,61)
- }
- if ( $getelo(%rankname,$1) == $getelo(%prevrankname,$1) ) {
- ;TIE
- ;echo posting rank for %rankname
- inc %tiecount
- 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) $+ % $+ ) $+ .
- }
- else {
- ;not a time
- inc %rank
- inc %rank %tiecount
- %tiecount = 0
- echo posting rank for %rankname
- 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) $+ % $+ ) $+ .
- }
- write %makeRank %msg
- }
- inc %count
- }
- }
- }
- ;syntax makeLeader <game>
- alias makeLeader {
- var %makeRank = leaderboard.txt
- var %leaderboardPSR = leaderboardPSR.txt
- var %leaderboardRank = leaderboardRank.txt
- var %leaderboardTitle = leaderboardTitle.txt
- var %rank = 0
- if ($1 == $null) {
- echo error no parameters
- return
- }
- else {
- /hashsort $1
- var %max = $hget(ratingtable,0).item
- var %count = 1
- ;/write -c %makeRank Ranks for $upper($1) - updated $adate
- /write -c %leaderboardTitle $upper($1) Leaderboard
- /write -c %makeRank
- ;/write -c %makeRank
- /write -c %leaderboardPSR
- /write -c %leaderboardRank
- var %tiecount = 0
- while (%count < $calc( %max + 1 )) {
- var %rankname = $gettok($read(sorthash.txt,%count),1,61)
- if ( $gettotalgames(%rankname, $1) > 0) {
- if (%count > 1) {
- var %prevrankname = $gettok($read(sorthash.txt,$calc( %count - 1 )),1,61)
- }
- if ( $getelo(%rankname,$1) == $getelo(%prevrankname,$1) ) {
- ;TIE
- echo posting rank for %rankname
- inc %tiecount
- ;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) $+ % $+ ) $+ .
- var %msg = $upper($left(%rankname,1)) $+ $mid(%rankname,2,15)
- ;var %msg = %rank $+ . $upper($left(%rankname,1)) $+ $mid(%rankname,2,15)
- ;var %msg = %rank $+ . %rankname - $getelo(%rankname,$1) $+ RIP
- ;$getwins(%rankname,$1) $+ W $+ - $+ $getlosses(%rankname,$1) $+ L ( $+ $round($calc($getwins(%rankname,$1) * 100 / $getTotalGames(%rankname,$1)),2) $+ % $+ ) $+ .
- }
- else {
- ;not a time
- inc %rank
- inc %rank %tiecount
- %tiecount = 0
- echo posting rank for %rankname
- var %msg = $upper($left(%rankname,1)) $+ $mid(%rankname,2,15)
- ;var %msg = %rank $+ . $upper($left(%rankname,1)) $+ $mid(%rankname,2,15)
- ;var %msg = %rank $+ . %rankname - $getelo(%rankname,$1) $+ RIP
- ;$getwins(%rankname,$1) $+ W $+ - $+ $getlosses(%rankname,$1) $+ L ( $+ $round($calc($getwins(%rankname,$1) * 100 / $getTotalGames(%rankname,$1)),2) $+ % $+ ) $+ .
- }
- write %leaderboardRank %rank
- write %makeRank %msg
- write %leaderboardPSR $round($getelo(%rankname,$1),0)
- }
- inc %count
- }
- }
- }
- ;hashsort game
- alias hashsort {
- hsave -os ratingtable ratingtable.txt
- var %sorthash = sorthash.txt
- hsave -io ratingtable %sorthash
- var %sortPos = $calc($findtok($hget(ratingtable,1).data,$1,1,32) + 1)
- ;echo -a sort position is %sortpos
- ;filter -ffxcteu %sortpos 32 %sorthash %sorthash [*]
- filter -ffxcteu %sortpos 32 %sorthash %sorthash [*]
- ;filter -ffxcteu %sortpos 32 %sorthash %sorthash *$11500 0 0*
- ;/write -il1 %sorthash [stats]
- ;hload -i sortedtable %sorthash stats
- ;hsave -os sortedtable sortedtable7.txt
- }
- alias eloReload {
- hfree ratingtable
- hmake -s ratingtable 200
- echo -s table created
- hload -s ratingtable ratingtable.txt
- hsave -os ratingtable ratingtable.txt
- echo -s table loaded
- }
- ;syntax is 1P 2P
- alias lobbyTitle {
- var %titlegame = %lobbygame
- if ($2 == $null) {
- echo -a not enough parameters
- }
- elseif ($hget(ratingtable,$1) == $null) {
- echo -a $1 not a registered player
- }
- elseif ($hget(ratingtable,$2) == $null) {
- echo -a $2 not a registered player
- }
- ;var %rank1p = $getRank($1,%titlegame)
- ;var %rank2p = $getRank($2,%titlegame)
- var %rank1p = Unranked
- var %rank2p = Unranked
- if ( %rank1p == Unranked ) {
- var %rank1p = ??
- }
- if ( %rank2p == Unranked ) {
- var %rank2p = ??
- }
- var %1pElo = $getelo($1,%titlegame)
- var %2pElo = $getelo($2,%titlegame)
- 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) )
- write -c 1p.txt $left($1,18)
- write 1p.txt Rank %rank1p $chr(124) %1pElo RIP
- write -c 2p.txt $left($2,18)
- write 2p.txt %2pElo RIP $chr(124) Rank %rank2p
- ;write -c 1pPSR.txt Rank %rank2p $chr(124) $getelo($1,%titlegame) RIP
- }
- on *:TEXT:!lobbyupdate *:#:{
- if ($nick isop $chan) || ($regcheck($nick)) {
- if ($3 == $null) {
- echo not enough parameters
- msg $chan $nick <- Incorrect syntax. Use !lobbyupdate <1p> <2p>
- }
- elseif ( $hget(ratingtable,$2) == $null ) {
- msg $chan $nick <- $2 is not registered
- }
- elseif ( $hget(ratingtable,$3) == $null ) {
- msg $chan $nick <- $3 is not registered
- }
- elseif ( $hget(saltyTable) == saltytable ) {
- msg # $nick <- There is a SaltyBrett already occurring
- }
- else {
- set %1p $upper($left($2,1)) $+ $right($2,$calc($len($2)-1)))
- set %2p $upper($left($3,1)) $+ $right($3,$calc($len($3)-1)))
- lobbyTitle %1p %2p
- msg $chan $nick <- Setting Lobby titles - %1p VS %2p
- msg # $nick has earned 100 dollars for his contribution O u O
- /makeleader %lobbygame
- incelo $nick SaltyBrett 100
- incWin $nick SaltyBrett
- timerWipeLobby off
- timerWipeLobby 1 1000 /wipeLobby
- }
- }
- else {
- msg $chan $nick <- You must be a regular or mod to use this command. Regulars can be added with !regulars add <nick>
- }
- }
- on *:TEXT:!lobbywin *:#:{
- if ($nick isop $chan) || ($regcheck($nick)) {
- if ( %2p == $null || %1p == $null ) {
- msg $chan $nick <- No one is playing right now
- }
- elseif ($2 != 1p ) && ($2 != 2p) {
- msg # $nick <- Incorrect syntax - !lobbywin 1p/2p
- }
- else {
- var %saltyWinner
- var %saltyLoser
- if ($2 == 1p ) {
- var %saltyWinner = %1p
- var %saltyLoser = %2p
- set %odds $calc( %pot2 / %pot1 )
- eloreport %1p %2p %lobbygame
- ;msg $chan Reported a game - %1p beating %2p
- lobbyTitle %1p %2p
- }
- if ($2 == 2p ) {
- var %saltyWinner = %2p
- var %saltyLoser = %1p
- set %odds $calc(%pot1 / %pot2)
- ;/msg # 2p was the winner. The odds were %odds to 1
- eloreport %2p %1p %lobbygame
- ;msg $chan Reported a game - %2p beating %1p
- ;lobbyTitle %1p %2p
- ;lobbytitle is disabled for performance
- }
- if ($hget(saltyTable) == saltytable) {
- msg # %SaltyWinner was the winner. The odds were %odds to 1
- echo -a pot was %pot1 and %pot2
- var %count = $hget(saltytable,0).data
- if ( %pot1 > 0 ) && ( %pot2 > 0 ) {
- while (%count > 0) {
- var %curName = $hget(saltytable,%count).item
- var %bet = $gettok($hget(saltytable,%count).data,1,32)
- var %target = $gettok($hget(saltytable,%count).data,2,32)
- if ( %target == $2) {
- incElo %curName saltybrett $calc(%bet * %odds)
- incWin %curName saltybrett
- echo %curName bet %bet dollars on %target $+ , odds were %odds gaining + $calc(%bet * %odds)
- }
- else {
- incLoss %curName saltybrett
- decElo %curName saltybrett %bet
- if ($getelo(%curName, saltybrett) < 0) {
- setelo %curName saltybrett 0
- }
- }
- ;setvar %curName cash $calc($getvar(%curName,cash) + $getvar(%curName,bet) + $getvar(%curName,bet)*%odds)
- dec %count
- /echo lowering count
- }
- ;makeleader saltybrett
- }
- else {
- msg $chan No betting occured for one side.
- }
- }
- else {
- msg $chan Reported a game - %saltyWinner beating %saltyLoser
- ;makeleader %lobbygame
- }
- ;eloreport %saltyWinner %saltyLoser %lobbygame
- ;lobbyTitle %1p %2p
- ;disabling makeleader for performance
- ;makeleader %lobbygame
- set %1p $null
- set %2p $null
- /wipelobby
- set %clearing 1
- ;timerWipea 1 4 set %1p $null
- ;timerWipeb 1 4 set %2p $null
- ;timerWipec 1 2 wipeLobby
- timerWiped 1 2 set %clearing 0
- ;msg # wiping
- }
- }
- else {
- msg $chan $nick <- You must be a mod or regular to report.
- }
- }
- /*
- on *:TEXT:!lobbywin 2p:#:{
- if ($nick isop $chan) || ($regcheck($nick)) {
- if ( %2p == $null ) {
- msg $chan $nick <- No one is playing right now
- }
- else {
- eloreport %2p %1p %lobbygame
- msg $chan Reported a game - %2p beating %1p
- lobbyTitle %1p %2p
- set %1p $null
- set %2p $null
- timerWipeb 1 4 /wipeLobby
- }
- }
- else { msg $chan $nick <- You must be a mod or regular to report.
- }
- }
- */
- on *:TEXT:!register:#:{
- if (!$hget(ratingtable,$nick)) {
- /eloregister $nick
- msg $chan $nick <- You are now registered.
- write -a logforscores.txt $fulldate :: Register :: $nick
- }
- else {
- msg $chan $nick <- You are already registered.
- echo -ag hashtable entry for $remove($nick,-tk) $+ : $hget(ratingtable,$remove($nick,-tk))
- }
- hsave -os ratingtable ratingtable.txt
- }
- alias wipeLobby {
- write -l10 "D:\streamcontrol.xml" <pName1></pName1>
- write -l3 "D:\streamcontrol.xml" <timestamp> $+ $ctime $+ </timestamp>
- set %1p $null
- set %2p $null
- set %pot1 0
- set %pot2 0
- write -c saltyodds1.txt
- write -c saltyodds2.txt
- write -c delta.txt
- write -c 1p.txt
- write -c 1pPSR.txt
- write -c 2p.txt
- write -c 2pPSR.txt
- hfree -s saltytable
- }
- on *:TEXT:!register *:#:{
- if ($nick !isop $chan) && ( $regcheck($nick) == $false ) {
- msg $chan $nick <- You must be an OP to use this command.
- }
- elseif (!$hget(ratingtable,$2)) {
- /eloregister $2
- msg $chan $2 is now registered.
- write -a logforscores.txt $fulldate :: Register :: $2
- }
- else {
- msg $chan $2 is already registered.
- echo -ag hashtable entry for $remove($nick,-tk) $+ : $hget(ratingtable,$remove($nick,-tk))
- }
- hsave -os ratingtable ratingtable.txt
- }
- ;syntax is !won <game> <opponent>
- OR
- ;syntax is !won EXVS partner <opponent1> <opponent2>
- on *:TEXT:!won *:#:{
- if ($3 == $null) {
- /msg $chan $nick <- Incorrect syntax. The syntax is !won <game> <opponent>
- }
- elseif ( $hget(ratingtable,$nick) == $null ) {
- msg $chan $nick <- You must be registered to use this command. Register with !register
- }
- elseif ( $hget(ratingtable,$3) == $null ) {
- msg $chan $nick <- $3 is not registered. Players can register with !register
- }
- elseif ( $count(%gamelist,$2) == 0 ) {
- echo -a Not a game
- msg #thebrett Not a valid game type.
- }
- elseif ( %loser != $null ) || ( %winner != $null ) || ( %elogame != $null ) {
- msg $chan someone has already used this command - winner is %winner
- }
- elseif ( $2 == exvs ) && ( $5 == $null ) {
- msg $chan $nick <- Improper syntax for EXVS - syntax is !won EXVS <partner> <opponent1> <opponent2>
- }
- elseif ( $2 == exvs ) && ( $hget(ratingtable,$3) == $null ) {
- msg $chan $nick <- $3 is not registered. Players can register with !register
- }
- elseif ( $2 == exvs ) && ( $hget(ratingtable,$4) == $null ) {
- msg $chan $nick <- $4 is not registered. Players can register with !register
- }
- elseif ( $2 == exvs ) && ( $hget(ratingtable,$5) == $null ) {
- msg $chan $nick <- $5 is not registered. Players can register with !register
- }
- ;if the game is exvs, change the nicks appropriately
- elseif ( $2 == exvs ) {
- set %winner $nick
- set %winnerpartner $3
- set %loser $4
- set %loserpartner $5
- set %elogame $2
- msg $chan Waiting 40 seconds for %loser or %loserpartner to use !confirm loss to report score.
- ;msg $chan this is exvs
- /timerEloWon 1 40 /flushNames
- }
- else {
- ;msg $chan this is not exvs
- set %winner $nick
- set %loser $3
- set %elogame $2
- msg $chan Waiting 40 seconds for %loser to use !confirm loss to report score.
- /timerEloWon 1 40 /flushNames
- }
- }
- on *:TEXT:!win *:#:{
- if ($3 == $null) {
- /msg $chan $nick <- Incorrect syntax. The syntax is !won <game> <opponent>
- }
- elseif ( $hget(ratingtable,$nick) == $null ) {
- msg $chan $nick <- You must be registered to use this command. Register with !register
- }
- elseif ( $hget(ratingtable,$3) == $null ) {
- msg $chan $nick <- $3 is not registered. Players can register with !register
- }
- elseif ( $count(%gamelist,$2) == 0 ) {
- echo -a Not a game
- msg #thebrett Not a valid game type.
- }
- elseif ( %loser != $null ) || ( %winner != $null ) || ( %elogame != $null ) {
- msg $chan someone has already used this command - winner is %winner
- }
- elseif ( $2 == exvs ) && ( $5 == $null ) {
- msg $chan $nick <- Improper syntax for EXVS - syntax is !won EXVS <partner> <opponent1> <opponent2>
- }
- elseif ( $2 == exvs ) && ( $hget(ratingtable,$3) == $null ) {
- msg $chan $nick <- $3 is not registered. Players can register with !register
- }
- elseif ( $2 == exvs ) && ( $hget(ratingtable,$4) == $null ) {
- msg $chan $nick <- $4 is not registered. Players can register with !register
- }
- elseif ( $2 == exvs ) && ( $hget(ratingtable,$5) == $null ) {
- msg $chan $nick <- $5 is not registered. Players can register with !register
- }
- ;if the game is exvs, change the nicks appropriately
- elseif ( $2 == exvs ) {
- set %winner $nick
- set %winnerpartner $3
- set %loser $4
- set %loserpartner $5
- set %elogame $2
- msg $chan Waiting 40 seconds for %loser or %loserpartner to use !confirm loss to report score.
- ;msg $chan this is exvs
- /timerEloWon 1 40 /flushNames
- }
- else {
- ;msg $chan this is not exvs
- set %winner $nick
- set %loser $3
- set %elogame $2
- msg $chan Waiting 40 seconds for %loser to use !confirm loss to report score.
- /timerEloWon 1 40 /flushNames
- }
- }
- ;syntax is !lost <game> <opponent>
- ;OR
- ;syntax is !lost EXVS <partner> <opponent1> <opponent2>
- on *:TEXT:!lost *:#:{
- if ($3 == $null) {
- /msg $chan $nick <- Incorrect syntax. The syntax is !lost <game> <opponent>
- }
- elseif ( $hget(ratingtable,$nick) == $null ) {
- msg $chan $nick <- You must be registered to use this command. Register with !register
- }
- elseif ( $hget(ratingtable,$3) == $null ) {
- msg $chan $nick <- That opponent is not registered.
- }
- elseif ( %loser != $null ) || ( %winner != $null ) || ( %elogame != $null ) {
- msg $chan someone has already used this command - winner is %winner
- }
- elseif ( $count(%gamelist,$2) == 0 ) {
- echo -a Not a game
- msg #thebrett Not a valid game type.
- }
- elseif ( $2 == exvs ) && ( $5 == $null ) {
- msg $chan $nick <- Improper syntax for EXVS - syntax is !lost EXVS <partner> <opponent1> <opponent2>
- }
- elseif ( $2 == exvs ) && ( $hget(ratingtable,$3) == $null ) {
- msg $chan $nick <- $3 is not registered. Please use !register
- }
- elseif ( $2 == exvs ) && ( $hget(ratingtable,$4) == $null ) {
- msg $chan $nick <- $4 is not registered. Please use !register
- }
- elseif ( $2 == exvs ) && ( $hget(ratingtable,$5) == $null ) {
- msg $chan $nick <- $5 is not registered. Please use !register
- }
- ;if the game is exvs, change the nicks appropriately
- elseif ( $2 == exvs ) {
- set %winner $4
- set %winnerpartner $5
- set %loser $nick
- set %loserpartner $3
- set %elogame $2
- msg $chan Waiting 40 seconds for %winner or %winnerpartner to use !confirm win to report score.
- ;msg $chan this is exvs
- /timerEloWon 1 40 /flushNames
- }
- else {
- ;msg $chan this is not exvs
- set %winner $3
- set %loser $nick
- set %elogame $2
- msg $chan Waiting 40 seconds for %winner to use !confirm win to report score.
- /timerEloWon 1 40 /flushNames
- }
- }
- ;syntax is !won <game> <winner> <loser>
- ;OR
- ;syntax is !won EXVS <winner1> <winner2> <opponent1> <opponent2>
- on *:TEXT:!report *:#:{
- if ($nick !isop $chan) {
- msg $chan $nick <- You must be a mod to use this command
- }
- elseif ($4 == $null) {
- /msg $chan $nick <- Incorrect syntax. The syntax is !report <game> <winner> <loser>
- }
- elseif ( $count(%gamelist,$2) == 0 ) {
- echo -a Not a game
- msg #thebrett Not a valid game type.
- }
- elseif ( $hget(ratingtable,$3) == $null ) {
- msg $chan $nick <- $3 is not registered.
- }
- elseif ( $hget(ratingtable,$4) == $null ) {
- msg $chan $nick <- $4 is not registered.
- }
- elseif ( %loser != $null ) || ( %winner != $null ) || ( %elogame != $null ) {
- msg $chan There is currently a - winner is %winner
- }
- elseif ( $2 == exvs ) && ( ( $hget(ratingtable,$3) == $null ) || ( $hget(ratingtable,$4) == $null ) || ( $hget(ratingtable,$5) == $null ) || ( $hget(ratingtable,$6) == $null ) ) {
- msg $chan $nick <- One of these players is not registered. Please use !register
- }
- ;if the game is exvs, change the nicks appropriately
- elseif ( $2 == exvs ) {
- set %winner $3
- set %winnerpartner $4
- set %loser $5
- set %loserpartner $6
- set %elogame $2
- ;msg $chan this is exvs
- echo -a reporting team elo
- /eloteamreport %winner %winnerpartner %loser %loserpartner %elogame
- /msg $chan $nick <- Score has been reported - thanks for your contribution!
- }
- else {
- ;msg $chan this is not exvs
- set %winner $3
- set %loser $4
- set %elogame $2
- /msg $chan $nick <- Score has been reported - thanks for your contribution!
- /eloReport %winner %loser %elogame
- }
- /flushNames
- }
- alias conditiontest {
- var %a = b
- var %b = f
- var %c = c
- if (%a == a) && ( (%b == b) || (%c == c) ) {
- echo true
- }
- else {
- echo false
- }
- }
- on *:TEXT:!confirm loss:#:{
- if ( $hget(ratingtable,$nick) == $null ) {
- msg $chan $nick <- You must be registered to use this command. Register with !register
- }
- elseif ( %loser == $null ) || ( %winner == $null ) || ( %elogame == $null ) {
- msg $chan There is no result to confirm.
- }
- elseif ( $nick != %loser ) && ( $nick != %loserpartner ) {
- msg $chan $nick <- You aren't listed as losing this match
- }
- elseif ( %elogame == EXVS ) {
- echo -a reporting team elo
- /eloteamreport %winner %winnerpartner %loser %loserpartner %elogame
- /msg $chan $nick <- Score has been reported - thanks for your contribution!
- /flushNames
- }
- else {
- /msg $chan $nick <- Score has been reported - thanks for your contribution!
- /eloReport %winner %loser %elogame
- /flushNames
- }
- }
- on *:TEXT:!confirm win:#:{
- if ( $hget(ratingtable,$nick) == $null ) {
- msg $chan $nick <- You must be registered to use this command. Register with !register
- }
- elseif ( %loser == $null ) || ( %winner == $null ) || ( %elogame == $null ) {
- msg $chan There is no result to confirm.
- }
- elseif ( $nick != %winner ) && ( $nick != %winnerpartner ) {
- msg $chan $nick <- You aren't listed as winning this match
- }
- elseif ( %elogame == EXVS ) {
- echo -a reporting team elo
- /eloteamreport %winner %winnerpartner %loser %loserpartner %elogame
- /msg $chan $nick <- Score has been reported - thanks for your contribution!
- /flushNames
- }
- else {
- /msg $chan $nick <- Score has been reported - thanks for your contribution!
- /eloReport %winner %loser %elogame
- /flushNames
- }
- }
- alias flushNames {
- /unset %winner
- /unset %loser
- /unset %eloGame
- /unset %winnerpartner
- /unset %loserpartner
- }
- ;syntax is !rank game nick
- on *:TEXT:!rank *:#:{
- echo -a working
- if ((%wait.ctime !isnum) || ((%wait.ctime isnum) && (%wait.ctime < $ctime))) {
- set %wait.ctime $calc($ctime + 2)
- echo -a working 2
- if ($2 == $null) {
- /echo param error
- msg $chan $nick <- Incorrect syntax. Syntax is !rank <game> or !rank <game> <nick>
- }
- elseif ( $count(%gamelist,$2) == 0 ) {
- echo -a Not a game
- msg $chan $nick <- $2 is not a valid game type.
- }
- elseif ( $hget(ratingtable,$nick) == $null ) && ( $3 == $null ) {
- msg $chan $nick <- You are not registered. Please register with !register
- echo -a $nick <- You are not registered. Please register with !register
- }
- elseif $3 != $null && $hget(ratingtable,$3) == $null {
- echo -a $nick <- $3 has not registered.
- msg $chan $nick <- $3 has not registered.
- }
- elseif ($3 == $null) {
- var %rankname = $nick
- echo posting rank
- ;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) $+ % $+ ) $+ .
- if ($2 == saltybrett) {
- 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.
- }
- else {
- 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) $+ % $+ ) $+ .
- }
- }
- else {
- %rankname = $3
- echo posting rank
- ;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) $+ % $+ ) $+ .
- if ($2 == saltybrett) {
- 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.
- }
- else {
- 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) $+ % $+ ) $+ .
- }
- }
- }
- }
- ;syntax is eloDelta(winnerelo,gamesplayed,loserelo,gamesplayed)
- alias eloDelta {
- var %winner_elo_old = $1
- var %loser_elo_old = $3
- ;check number of games played
- var %winnergamesplayed = $2
- var %losergamesplayed = $4
- if ( %winnergamesplayed <= 30 ) {
- var %kfactorwinner = 30 }
- elseif ( %winner_elo_old >= 2400 ) {
- var %kfactorwinner = 10 }
- else { var %kfactorwinner = 30 }
- if ( %losergamesplayed <= 30 ) {
- var %kfactorloser = 30 }
- elseif ( %%loser_elo_old >= 2400 ) {
- var %kfactorloser = 10 }
- else { var %kfactorloser = 15 }
- ;calcuate odds
- var %EaOddsa = $calc(1/(1 + 10^$calc((%winner_elo_old - %loser_elo_old) / 400)))
- var %EaOddsb = $calc(1/(1 + 10^$calc((%loser_elo_old - %winner_elo_old) / 400)))
- var %winner_elo_new = $calc(%winner_elo_old + (%kfactorwinner * (1- %EaOddsb)))
- var %loser_elo_new = $calc(%loser_elo_old + (%kfactorloser * (0 - %EaOddsa)))
- ;return $round(%winner_elo_new,0) $round(%loser_elo_new,0) Delta = $round($calc(%kfactorwinner * (1- %EaOddsb)),0)
- return $round($calc(%kfactorwinner * (1- %EaOddsb)),0)
- }
- ;syntax is eloReport winner loser game
- alias eloReport {
- if ($2 == $null) {
- echo -a not enough parameters
- return }
- elseif ( $count(%gamelist,$3) == 0 ) {
- echo -a Not a game
- msg #thebrett Not a valid game type.
- }
- else {
- ;setElo $calc( $getElo($1,$3) + $eloDelta($getElo($1,$3),$getTotalGames($1,$3),$getElo($2,$3),$getTotalGames($2,$3)) )
- /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))
- var %delta = $eloDelta($getElo($1,$3),$getTotalGames($1,$3),$getElo($2,$3),$getTotalGames($2,$3))
- /echo -a %delta
- ;set winners elo
- setElo $1 $3 $calc( $getElo($1,$3) + %delta )
- ;set losers elo
- setElo $2 $3 $calc( $getElo($2,$3) - %delta )
- ;set winners win +
- /incwin $1 $3
- ;set losers loss +
- /incloss $2 $3
- hsave -os ratingtable ratingtable.txt
- ;makeLeader $3
- }
- }
- ;syntax is eloTeamReport winner1 winner2 loser1 loser2 game
- alias eloTeamReport {
- if ($5 == $null) {
- echo -a not enough parameters
- return }
- elseif ( $count(%gamelist,$5) == 0 ) {
- echo -a Not a game
- msg #thebrett Not a valid game type.
- }
- else {
- ;setElo $calc( $getElo($1,$3) + $eloDelta($getElo($1,$3),$getTotalGames($1,$3),$getElo($2,$3),$getTotalGames($2,$3)) )
- ;/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))
- var %averageelowinner = $calc( ($getElo($1,$5) + $getElo($2,$5)) / 2)
- var %averageeloloser = $calc( ($getElo($3,$5) + $getElo($4,$5)) / 2)
- var %totalgameswinner = $calc( ($getTotalGames($1,$5) + $getTotalGames($2,$5)) / 2 )
- var %totalgamesloser = $calc( ($getTotalGames($3,$5) + $getTotalGames($4,$5)) / 2 )
- var %delta = $eloDelta(%averageelowinner,%totalgameswinner,%averageeloloser,%totalgamesloser)
- /echo -a winners average elo: %averageelowinner losers average elo: %averageeloloser
- /echo -a winners average games played %totalgameswinner losers average agmes played %totalgamesloser
- /echo -a delta is %delta
- ;set winners elo
- setElo $1 $5 $calc( $getElo($1,$5) + %delta )
- setElo $2 $5 $calc( $getElo($2,$5) + %delta )
- ;set losers elo
- setElo $3 $5 $calc( $getElo($3,$5) - %delta )
- setElo $4 $5 $calc( $getElo($4,$5) - %delta )
- ;set winners win +
- /incwin $1 $5
- /incwin $2 $5
- ;set losers loss +
- /incloss $3 $5
- /incloss $4 $5
- hsave -os ratingtable ratingtable.txt
- }
- }
- ;syntax is setElo(name,game,new elo)
- alias setElo {
- if ($3 == $null) {
- echo -a not enough parameters
- return }
- elseif ( $hget(ratingtable,$1) == $null ) {
- echo -a Player not registered
- }
- else {
- var %eloPos = $calc($findtok($hget(ratingtable,$1),$2,1,32) + 1)
- /echo -a position is %eloPos
- hadd ratingtable $1 $puttok($hget(ratingtable,$1),$3,%eloPos,32)
- hsave -os ratingtable ratingtable.txt
- }
- }
- ;syntax is name,game,amnt
- alias incElo {
- if ($3 == $null) {
- echo -a not enough parameters
- return }
- elseif ( $hget(ratingtable,$1) == $null ) {
- echo -a Player not registered
- }
- else {
- setelo $1 $2 $calc($getelo($1,$2) + $3)
- }
- }
- on *:TEXT:!bertbucks give *:#:{
- if ($nick == thebrett || $nick == kazukimutou || $nick == ubw_roach ) {
- msg # Awarding $3 $4 bertbucks
- /incElo $3 SaltyBrett $4
- }
- }
- on *:TEXT:!bertbucks take *:#:{
- if ($nick == thebrett || $nick == kazukimutou || $nick == ubw_roach) {
- msg # Taking away $4 bertbucks from $3
- /decElo $3 SaltyBrett $4
- }
- }
- alias decElo {
- if ($3 == $null) {
- echo -a not enough parameters
- return }
- elseif ( $hget(ratingtable,$1) == $null ) {
- echo -a Player not registered
- }
- else {
- setelo $1 $2 $calc($getelo($1,$2) - $3)
- }
- }
- ;syntax is setLoss(name,game,new loss)
- alias setLoss {
- if ($3 == $null) {
- echo -a not enough parameters
- return }
- elseif ( $hget(ratingtable,$1) == $null ) {
- echo -a Player not registered
- }
- else {
- var %lossPos = $calc($findtok($hget(ratingtable,$1),$2,1,32) + 3)
- /echo -a position is %lossPos
- hadd ratingtable $1 $puttok($hget(ratingtable,$1),$3,%lossPos,32)
- hsave -os ratingtable ratingtable.txt
- }
- }
- ;syntax is setWin(name,game,new win)
- alias setWin {
- if ($3 == $null) {
- echo -a not enough parameters
- return }
- elseif ( $hget(ratingtable,$1) == $null ) {
- echo -a Player not registered
- }
- else {
- var %winPos = $calc($findtok($hget(ratingtable,$1),$2,1,32) + 2)
- /echo -a position is %winPos
- hadd ratingtable $1 $puttok($hget(ratingtable,$1),$3,%winPos,32)
- hsave -os ratingtable ratingtable.txt
- }
- }
- ;syntax is incShame(name)
- alias incShame {
- if ($1 == $null) {
- echo -a not enough parameters
- return }
- elseif ( $hget(ratingtable,$1) == $null ) {
- echo -a Player not registered
- }
- else {
- var %winPos = $calc($findtok($hget(ratingtable,$1),SaltyBrett,1,32) + 4)
- /echo -a position is %winPos
- hadd ratingtable $1 $puttok($hget(ratingtable,$1),$calc($getShame($1) + 1),%winPos,32)
- hsave -os ratingtable ratingtable.txt
- }
- }
- ;syntax is incWin(name,game)
- alias incWin {
- if ($2 == $null) {
- echo -a not enough parameters
- return }
- elseif ( $hget(ratingtable,$1) == $null ) {
- echo -a Player not registered
- }
- else {
- var %winPos = $calc($findtok($hget(ratingtable,$1),$2,1,32) + 2)
- /echo -a position is %winPos
- hadd ratingtable $1 $puttok($hget(ratingtable,$1),$calc($getWins($1,$2) + 1),%winPos,32)
- hsave -os ratingtable ratingtable.txt
- }
- }
- ;syntax is incLoss(name,game)
- alias incLoss {
- if ($2 == $null) {
- echo -a not enough parameters
- return }
- elseif ( $hget(ratingtable,$1) == $null ) {
- echo -a Player not registered
- }
- else {
- var %lossPos = $calc($findtok($hget(ratingtable,$1),$2,1,32) + 3)
- ;/echo -a position is %lossPos
- echo -a increasing loss for $1
- hadd ratingtable $1 $puttok($hget(ratingtable,$1),$calc($getLosses($1,$2) + 1),%lossPos,32)
- hsave -os ratingtable ratingtable.txt
- }
- }
- alias eloRegister {
- if (!$hget(ratingtable,$1)) {
- echo -a registered name: $1
- 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
- ;msg $chan $nick <- You are now registered.
- ;write -a logforscores.txt $fulldate :: Register :: $nick
- }
- else {
- ;msg $chan $nick <- You are already registered.
- ;echo -ag hashtable entry for $remove($nick,-tk) $+ : $hget(ratingtable,$remove($nick,-tk))
- echo -a $1 was already found
- }
- hsave -os ratingtable ratingtable.txt
- }
- alias eloReset {
- if ($1 == $null) {
- echo error
- }
- else {
- eloRemove $1
- eloRegister $1
- }
- }
- ;syntax is getRank <name> <game>
- alias getRank {
- var %makeRank = testtest.txt
- var %rank = 0
- if ($2 == $null) {
- echo error no parameters
- return
- }
- elseif ( $gettotalgames($1, $2) == 0 ) {
- return Unranked
- }
- else {
- /hashsort $2
- var %max = $hget(ratingtable,0).item
- var %count = 1
- /write -c %makeRank Ranks for $upper($2) - updated $adate
- var %tiecount = 0
- while (%count < $calc( %max + 1 )) {
- var %rankname = $gettok($read(sorthash.txt,%count),1,61)
- if ( $gettotalgames(%rankname, $2) > 0) {
- if (%count > 1) {
- var %prevrankname = $gettok($read(sorthash.txt,$calc( %count - 1 )),1,61)
- }
- if ( $getelo(%rankname,$2) == $getelo(%prevrankname,$2) ) {
- ;TIE
- ;echo posting rank for %rankname
- if (%rankname == $1) {
- echo %rankname has a rank of %rank
- return %rank
- }
- inc %tiecount
- 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) $+ % $+ ) $+ .
- }
- else {
- ;not a time
- inc %rank
- inc %rank %tiecount
- %tiecount = 0
- ;echo posting rank for %rankname
- if (%rankname == $1) {
- echo %rankname has a rank of %rank
- return %rank
- }
- 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) $+ % $+ ) $+ .
- }
- ;write %makeRank %msg
- }
- inc %count
- }
- }
- ;return Unranked
- }
- /*
- ;syntax: /getRank(name,game)
- alias getRank {
- /*
- if ($2 == $null) {
- echo -a not enough parameters
- }
- elseif ( $hget(ratingtable,$1) == $null) {
- echo -a $1 is not registered
- }
- else {
- /echo hi
- top5 $2
- echo -a $read(makeRank.txt, s, $1)
- var %rank = $calc( $readn + 1 )
- echo -a %rank
- return %rank
- }
- */
- }
- */
- alias eloRemove {
- if ( $hget(ratingtable,$1) == $null ) {
- ;msg $chan $nick <- $3 is not registered.
- }
- else {
- }
- hdel ratingtable $1
- hsave -os ratingtable ratingtable.txt
- }
- ;syntax is $getElo(nick,game)
- alias getElo {
- return $gettok($matchtok($hget(ratingtable,$1),$2,1,59),2,32)
- }
- alias getWins {
- return $gettok($matchtok($hget(ratingtable,$1),$2,1,59),3,32)
- }
- alias getLosses {
- return $gettok($matchtok($hget(ratingtable,$1),$2,1,59),4,32)
- }
- ;syntax is Name
- alias getShame {
- return $gettok($matchtok($hget(ratingtable,$1),SaltyBrett,1,59),5,32)
- }
- alias getTotalGames {
- return $calc( $getWins($1,$2) + $getLosses($1,$2) )
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement