dhm

By dhm on Mar 10, 2014

overloads only!

alias -l getAction {

  return %action [ $+ [ $1 ] ]

}

alias -l addGame {

  if ($1 == 1) {

    ; /addGame 1 <host> <player> <action> <min. die roll to player win> <multiplier if player win>

    set %gameID $+ $2 $1

    set %gameID $+ $3 $1

    set %host $+ $2 $2

    set %host $+ $3 $2

    set %players $+ $2 $3

    set %action $+ $2 $fromNumSuf($4)

    set %payout $+ $2 $getAction($2) * $6

    set %minDieRoll $+ $2 $5

    set %multiplier $+ $2 $6

    if ($getWhoRolls(1) == 0) {

      rollDice $2

    }

    elseif ($getWhoRolls(1) == 1) {

    }

  }

  elseif ($1 isnum 2-3) {

    var %gameName $iif($1 == 2,Dice duel,FFA)

    ; /addGame 3 <host> <player1 player2 ...> <action per player>

    var %i 2,%n $0

    while (%i < %n) {

      set %gameID $+ [ $gettok($1-,%i,32) ] $1

      set %host $+ [ $gettok($1-,%i,32) ] $2

      inc %i

    }

    set %players $+ $2 $3- [ $+ [ $calc($0 - 1) ] ]

    set %action $+ $2 $fromNumSuf($gettok($1-,$0,32))

    set %payout $+ $2 $calc($getAction($2) * $getPlayers($2,0))

    if ($isActivePlayer($2,$2) == $false) {

      set %payout $+ $2 $calc($getPayout($2) * (1 - $getCommission))

    }

    set %bestDiceSum $+ $2 0

    msg $getChan $+( 7[,$2,] 10 $toVersus($getPlayers($2)) 3 $chr(40),$toNumSuf($getPayout($2)),$chr(41) 1pot! 01[Type 04!roll] )

  }

}

alias -l addGiveaway {

  ; /addGiveaway <host> <item name> <mininum wager in num suf form> <required dice sum>

  ; Note giveaways are stored in the following format in Giveaways.txt: <host> <minAction> <reqDiceSum> <itemName>

  var %itemName $2- [ $+ [ $calc($0 - 2) ] ], %minAction $fromNumSuf( $ [ $+ [ $calc($0 - 1) ] ] ),%reqDiceSum $ [ $+ [ $0 ] ]

  write Giveaways.txt $1 %minAction %reqDiceSum %itemName

  msg $getChan [[ $color.gameName(GIVEAWAY) ][ Place your wagers with $color.hostName($1) for a chance to win a $color.itemName(%itemName) $+ ! ][ Min. wager: $color.money($toNumSuf(%minAction)) ][ Req. dice sum: $color.diceRoll(%reqDiceSum) ]

}

alias -l cleanupDrawnGame {

  ; /cleanupDrawnGame <host>

  if (($getGameID($1) isnum 2-4) || ($getGameID($1) == 10)) {

    var %players $getBestDiceSum($1).players

    var %i 1,%n $getPlayers($1,0)

    while (%i <= %n) {

      if ($istok(%players,$getPlayers($1,%i),32) == $false) {

        updateStats -l $getPlayers($1,%i)

        unset %gameID $+ [ $getPlayers($1,%i) ] %host $+ [ $getPlayers($1,%i) ]

      }

      unset %diceSum $+ [ $getPlayers($1,%i) ]

      inc %i

    }

    set %players $+ $1 %players

    set %bestDiceSum $+ $1 0

    unset %totalDiceSums $+ $1 %bestDiceSum.players $+ $1

  }

}

alias -l clearGiveaways {

  if ($1 == -q) {

    set %show $false

    tokenize 32 $2-

  }

  if (%show != $false) {

    msg $getChan [[ $color.gameName(GIVEAWAY) ][ All items have been withdrawn from the giveaway. ]

  }

  .remove Giveaways.txt

}

alias -l color.diceRoll {

  return $+($chr(3), 04,$1,$chr(15))

}

alias -l color.gameName {

  return $+($chr(3),13,$1,$chr(15))

}

alias -l color.hostName {

  return $+($chr(3), 07,$1,$chr(15))

}

alias -l color.itemName {

  return $+($chr(3), 14,$1,$chr(15))

}

alias -l color.money {

  return $+($chr(3), 03,$1,$chr(15))

}

alias -l color.playerName {

  return $+($chr(3), 10,$1,$chr(15))

}

alias -l color.stats {

  if (($isNegStat($1) == $true) || ($2 < 0)) {

    return $+($chr(3),04,$2,$chr(15))

  }

  return $+($chr(3), 03,$2,$chr(15))

}

alias -l delGame {

  ; /delGame <host>

  if ($1 == -q) {

    var %show $false

    tokenize 32 $2-

  }

  if (%show != $false) {

    msg $getChan [[ NOTICE ]] The game hosted by $color.hostName($1) has been canceled.

  }

  if ($getGameID($1) == 1) {

    unset %gameID $+ $1 %gameID $+ $getPlayers($1) %host $+ $1 %host $+ $getPlayers($1) %players $+ $1 %action $+ $1 %payout $+ $1 %minDieRoll $+ $1 %multiplier $+ $1

  }

  if (($getGameID($1) == 2) || ($getGameID($1) == 3)) {

    var %i 1,%n $getPlayers($1,0)

    while (%i <= %n) {

      unset %gameID $+ [ $getPlayers($1,%i) ] %host $+ [ $getPlayers($1,%i) ] %diceSum $+ [ $getPlayers($1,%i) ]

      inc %i

    }

    unset %gameID $+ $1 %host $+ $1 %players $+ $1 %action $+ $1 %payout $+ $1 %totalDiceSums $+ $1 %bestDiceSum $+ $1 %bestDiceSum.players $+ $1

    unset %targetDiceSum $+ $1

  }

}

alias -l delGiveaway {

  ; /delGiveaway <host>

  if ($1 == -q) {

    var %show $false

    tokenize 32 $2

  }

  if (%show != $false) {

    msg $getChan [[ $color.gameName(GIVEAWAY) ][ The $color.itemName($getGiveaway($1).itemName) donated by $color.hostName($getGiveaway($1).hostName) has been withdrawn from the giveaway. ]

  }

  write -ds $+ $getGiveaway($1).hostName Giveaways.txt

}

alias -l fromNumSuf {

  return $regsubex($1,/([\d.]+)([kmb])/i,$calc(\1 * 10 ^ $calc(3 * $pos(kmb,\2)))))

}

alias -l getBestDiceSum {

  return $eval($+(%,bestDiceSum,$iif($prop == players,.players),$1),2)

}

alias -l getCommission {

  return .10

}

alias -l getChan {

  return #dhm

}

alias -l getDiceSum {

  return %diceSum [ $+ [ $1 ] ]

}

alias -l getGameID {

  return %gameID [ $+ [ $1 ] ]

}

alias getGiveaway {

  ; $getGiveaway( host/num )

  if (($1 == 0) && ($lines(Giveaways.txt) != 0)) {

    var %giveaway $lines(Giveaways.txt)

  }

  elseif ($1 isnum 1-) {

    var %giveaway $read(Giveaways.txt,$1)

  }

  elseif ($read(Giveaways.txt,s,$1) != $null) {

    var %giveaway $1 $read(Giveaways.txt,s,$1)

  }

  if ($prop == hostName) {

    return $gettok(%giveaway,1,32)

  }

  if ($prop == minAction) {

    return $gettok(%giveaway,2,32)

  }

  if ($prop == reqDiceSum) {

    return $gettok(%giveaway,3,32)

  }

  if ($prop == itemName) {

    return $gettok(%giveaway,4-,32)

  }

  return %giveaway

}

alias -l getHost {

  return %host [ $+ [ $1 ] ]

}

alias -l getMinDieRoll {

  return %minDieRoll [ $+ [ $1 ] ]

}

alias -l getMultiplier {

  return %multiplier [ $+ [ $1 ] ]

}

alias -l getOpponents {

  return $remtok($getPlayers($getHost($1)),$1,1,32)

}

alias -l getPayout {

  return %payout [ $+ [ $1 ] ]

}

alias -l getPlayers {

  if ($2 == $null) {

    return %players [ $+ [ $1 ] ]

  }

  return $gettok(%players [ $+ [ $1 ] ] ,$2,32)

}

alias -l getStat {

  ; $getStat( player , category )

  ; TotalGames, TotalBet, HighestBet, HighestLost, TotalLosses, TotalLost, LosingStreak, WinningStreak, HighestWon, TotalWins, TotalWon, HighestWinningStreak, HighestLosingStreak

  ; W/L Ratio, W/L Spread

  if ($2 == Ratio) {

    var %stat $calc($readini(Dhm.ini,$1,TotalWins) / $readini(Dhm.ini,$1,TotalLosses))

  }

  elseif ($2 == Spread) {

    var %stat $calc($readini(Dhm.ini,$1,TotalWins) - $readini(Dhm.ini,$1,TotalLosses))

  }

  elseif ($2 == TotalProfit) {

    var %stat $calc($readini(Dhm.ini,$1,TotalWon) - $readini(Dhm.ini,$1,TotalBet))

  }

  else {

    var %stat $iif($readini(Dhm.ini,$1,$2),$v1,0)

  }

  if ($prop == color) {

    return $color.stats($2,%stat)

  }

  return %stat

}

alias -l getStats {

  return TotalBet TotalProfit TotalWon TotalLost TotalGames TotalWins TotalLosses Ratio Spread HighestWinningStreak HighestLosingStreak

}

alias -l getWhoRolls {

  ; $getWhoRolls(gameID) = 0 if host rolls, 1 if player rolls

  if ($1 == 1) {

    return 0

  }

  return 1

}

alias -l giveaway {

  ; /giveaway -l <output method> <target> <optional number/host>

  if ($1 == -l) {

    tokenize 32 $2-

    if ($3 == $null) {

      var %i 1,%n $lines(Giveaways.txt)

      while (%i <= %n) {

        $1-2 [[ $color.gameName(GIVEAWAY $chr(35) $+ %i) ][ Item: $color.itemName($getGiveaway(%i).itemName) ][ Min. wager: $color.money($toNumSuf($getGiveaway(%i).minAction)) ][ Required dice sum: $color.diceRoll($getGiveaway(%i).reqDiceSum) ][ Host: $color.hostName($getGiveaway(%i).hostName) ]

        inc %i

      }

    }

    else {

      $1-2 [[ $color.gameName(GIVEAWAY $iif($3 isnum,$chr(35) $+ $3)) ][ Item: $color.itemName($getGiveaway($3).itemName) ][ Min. wager: $color.money($toNumSuf($getGiveaway($3).minAction)) ][ Required dice sum: $color.diceRoll($getGiveaway($3).reqDiceSum) ][ Host: $color.hostName($getGiveaway($3).hostName) ]

    }

    .timerGiveaway $+ $iif($2 != $getChan,$2) 1 60 noop

  }

}

alias -l incStat {

  writeini Dhm.ini $1-2 $calc($getStat($1,$2) + $iif($3,$3,1))

}

alias -l isActivePlayer {

  ; isActivePlayer(player,host)

  return $istok($getPlayers($2),$1,32)

}

alias -l isBarred {

  return $istok(Highscores,$1,32)

}

alias -l isBotStaff {

  if ($nick($getChan,$1,ohv) != $null) {

    return $true

  }

}

alias -l isGiveawayEligible {

  ; $isGiveawayEligible( player , optional player dice sum )

  var %host $getHost($1),%action $getAction(%host),%diceSum $iif($2 == $null,$getDiceSum($1),$2)

  if (($1 != %host) && (%action >= $getGiveaway(%host).minAction) && ($isNumInRange(%diceSum,$getGiveaway(%host).reqDiceSum) == $true)) {

    return $true

  }

}

alias -l isHost {

  if ($nick($getChan,$1,ohv) != $null) {

    return $true

  }

}

alias -l isNegStat {

  return $istok(HighestLost TotalLosses TotalLost LosingStreak HighestLosingStreak,$1,32)

}

alias -l isNeutralStat {

  return $istok(TotalGames TotalBet HighestBet,$1,32)

}

alias -l isNumInRange {

  ; $isNumInRange(num,range)

  var %i 1,%n $numtok($2,44)

  while (%i <= %n) {

    if ($1 isnum $gettok($2,%i,44)) {

      return $true

    }

    inc %i

  }

  return $false

}

alias -l isPosStat {

  return $istok(Ratio WinningStreak HighestWon TotalWins TotalWon HighestWinningStreak,$1,32)

}

alias -l rollDice {

  ; /rollDice <player>

  var %host $getHost($1),%player $1

  if ($getGameID($1) == 1) {

    var %dieRoll $rand(1,100)

    var %gameName $+($getMinDieRoll(%host),x,$getMultiplier(%host))

    if ($getWhoRolls(1) == 0) {

      var %player $getPlayers($1)

      msg $getChan $+( 7[,%gameName,] 10 %gameName for4 %player 10with a 3 $toNumSuf($getPayout(%host)) pot!)

      msg $getChan 10The host has 7rolled %dieRoll 10on the percentile die!

    }

    if (%dieRoll < $getMinDieRoll(%host)) {

      if ($getWhoRolls(1) == 0) {

        msg $getChan 7 $+ %player has 4lost 7the7 $toNumSuf($getPayout(%host)) pot!

      }

      elseif ($getWhoRolls(1) == 1) {

        msg $getChan [[ Game: $color.gameName(%gameName) ][ $color.playerName($1) rolled a $color.diceRoll(%dieRoll) on the percentile die, losing against $color.hostName($getHost($1)) $+ ! ][ Payout: $color.money($toNumSuf($getPayout(%host))) ][ Host: $color.hostName(%host) ]

      }

      updateStats -l %player

      delGame -q %host

    }

    else {

      if ($getWhoRolls(1) == 0) {

        msg $getChan 7 $+ %player has 3won 7the7 $toNumSuf($getPayout(%host)) pot!

      }

      elseif ($getWhoRolls(1) == 1) {

        msg $getChan [[ Game: $color.gameName(%gameName) ][ $color.playerName($1) rolled a $color.diceRoll(%dieRoll) on the percentile die, winning against $color.hostName($getHost($1)) $+ ! ][ Payout: $color.money($toNumSuf($getPayout(%host))) ][ Host: $color.hostName(%host) ]

      }

      updateStats -w %player

      delGame -q %host

    }

  }

  elseif ($getGameID($1) isnum 2-3) {

    var %gameName $iif($getGameID($1) == 2,Dice duel,FFA)

    var %dieRoll_1 $rand(1,6),%dieRoll_2 $rand(1,6)

    set %diceSum $+ $1 %dieRoll_1 + %dieRoll_2

    msg $getChan $+( 10,$1 1rolled a  $getDiceSum($1) 1on Two-Six-Sided Dice! )

    if ($isGiveawayEligible(%player) == $true) {

      msg $getChan [[ $color.gameName(GIVEAWAY) ][ $color.playerName($1) won a $color.itemName($getGiveaway(%host).itemName) from $color.hostName(%host) $+ ! ][ Min. wager: $color.money($toNumSuf($getGiveaway(%host).minAction)) ][ Required dice sum: $color.diceRoll($getGiveaway(%host).reqDiceSum) ]]

      delGiveaway -q %host

    }

    if ($getDiceSum($1) == $getBestDiceSum(%host)) {

      set %bestDiceSum.players $+ [ %host ] $getBestDiceSum(%host).players $1

    }

    elseif ($getDiceSum($1) > $getBestDiceSum(%host)) {

      set %BestDiceSum $+ [ %host ] $getDiceSum($1)

      set %BestDiceSum.players $+ [ %host ] $1

    }

    inc %totalDiceSums $+ [ %host ]

    if (%totalDiceSums [ $+ [ %host ] ] == $getPlayers(%host,0)) {

      var %diceSum $getBestDiceSum(%host),%players $getBestDiceSum(%host).players

      if ($numtok(%players,32) == 1) {

        msg $getChan $+( 7[,%gameName,] 10 %players 1wins the 3 $chr(40),$toNumSuf($getPayout(%host)),$chr(41) 1pot! )

        updateStats -w %players

        var %i 1,%n $getPlayers(%host,0)

        while (%i <= %n) {

          if ($getPlayers(%host,%i) != %players) {

            updateStats -l $getPlayers(%host,%i)

          }

          inc %i

        }

        delGame -q %host

      }

      else {

        msg $getChan $+( 7[,%gameName,] 10 $chr(40),%diceSum,-,%diceSum,$chr(41) 1 Tie! Reroll! $iif(%gameName == FFA,%players))

        cleanupDrawnGame %host

      }

    }

  }

}

alias -l setHighscore {

  ; /setHighscore <category> <nick> <score>

  hadd -m Highscores $1-

}

alias -l setStat {

  ; /setStat <player> <category> <value>

  writeini Dhm.ini $1-

}

alias -l toNumSuf {

  var %len $len($int($1))

  if (%len isnum 4-6) return $calc($1 / 10^3) $+ k

  if (%len isnum 7-9) return $calc($1 / 10^6) $+ m

  if (%len isnum 10-12) return $calc($1 / 10^9) $+ b

  return $calc($1)

}

alias -l toVersus {

  return $replace($1,$chr(32),$chr(32) v. $chr(32))

}

alias -l updateStats {

  var %host $getHost($2),%action $getAction(%host), %payout $getPayout(%host)

  ; /updateStats -lw <nick>

  incStat $2 TotalGames

  incStat $2 TotalBet %action

  if (%action > $getStat($2,HighestBet)) {

    writeini Dhm.ini $2 HighestBet %action

    if (%action > $getHighscore(HighestBet)) {

      setHighscore HighestBet $2 %action

    }

  }

  if ($1 == -l) {

    if (%action > $getStat($2,HighestLost)) {

      writeini Dhm.ini $2 HighestLost %action

      if (%action > $getHighscore(HighestLost)) {

        setHighscore HighestLost $2 %action

      }

    }

    incStat $2 TotalLosses

    incStat $2 TotalLost %action

    incStat $2 LosingStreak

    setStat $2 WinningStreak 0

  }

  elseif ($1 == -w) {

    if (%payout > $getStat($2,HighestWon)) {

      writeini Dhm.ini $2 HighestWon %payout

      if (%payout > $getHighscore(HighestWoon)) {

        setHighscore HighestWon $2 %payout

      }

    }

    incStat $2 TotalWins

    incStat $2 TotalWon %payout

    incStat $2 WinningStreak

    setStat $2 LosingStreak 0

  }

}

on *:EXIT:{

  hsave Highscores Highscores.txt

}

on *:START:{

  if ($hget(Highscores) == $null) {

    hmake Highscores 100

  }

  hload Highscores Highscores.txt

}

on $*:TEXT:/^[!@.](50|51|52|53|54|55|56|57|58|59|60)x(2)/i:$($getChan):{

  var %minDieRoll $regml(1),%multiplier $regml(2)

  if ($isHost($nick) == $true) {

    if ($getGameID($nick) == $null) {

      if ($3 == $null) {

        .notice $nick You specified too few parameters. The syntax is $1 <player> <wager>.

      }

      elseif ($2 == $nick) {

        .notice $nick The player you specified is yourself. You cannot host this game for yourself. The syntax is $1 <player> <wager>.

      }

      elseif ($2 ison #) {

        if ($isBarred($2) == $true) {

          .notice $nick The player you specified is barred from playing here. Please check the player name and try again. The syntax is $1 <player> <wager>.

        }

        elseif ($getGameID($2) == $null) {

          if ($fromNumSuf($3) isnum 0-) {

            addGame 1 $nick $2-3 %minDieRoll %multiplier

          }

          else {

            .notice $nick The wager you specified is invalid. Please check the wager and try again. The syntax is $1 <player> <wager>.

          }

        }

        else {

          .notice $nick The player you specified already is playing in a game. Please check the player name and try again. The syntax is $1 <player> <wager>.

        }

      }

      else {

        .notice $nick The player you specified is not here. Please check the player name and try again. The syntax is $1 <player> <wager>.

      }

    }

    elseif ($getHost($nick) == $nick) {

      .notice $nick You already are hosting a game. Please complete your current game and then try again.

    }

    else {

      .notice $nick You currently are playing in a game. You cannot host a game while playing in another game. Please complete your current game and then try again.

    }

  }

}

on $*:TEXT:/^[!@.](ffa|(new)?d(ice)?d(uel)?)/i:$($getChan):{

  var %gameID $iif($regml(1) == ffa,3,2)

  if ($isHost($nick) == $true) {

    if ($getGameID($nick) == $null) {

      if ($4 == $null) {

        .notice $nick You specified too few parameters. The syntax is $1 <player1 player2 ...> <wager>.

      }

      else {

        var %error $false,%i 2,%n $0

        while (%i < %n) {

          if ($ [ $+ [ %i ] ] !ison #) {

            .notice $nick One or more of the players you specified is not here. Please check the player names and try again. The syntax is $1 <player1 player2 ...> <wager>.

            var %error $true

            break

          }

          elseif ($isBarred($ [ $+ [ %i ] ] ) == $true) {

            .notice $nick One or more of the players you specified is barred from playing here. Please check the player names and try again. The syntax is $1 <player1 player2 ...> <wager>.

            var %error $true

            break

          }

          elseif ($getGameID($ [ $+ [ %i ] ] ) != $null) {

            .notice $nick One or more of the players you specified already is in a game. Please check the player names and try again. The syntax is $1 <player1 player2 ...> <wager>.

            var %error $true

            break

          }

          inc %i

        }

        if (%error == $false) {

          if ($fromNumSuf($ [ $+ [ $0 ] ] ) isnum 0-) {

            addGame %gameID $nick $2-

          }

          else {

            .notice $nick The wager you specified is invalid. Please check the wager and try again. The syntax is $1 <player1 player2 ...> <wager>.

          }

        }

      }

    }

    elseif ($getHost($nick) == $nick) {

      .notice $nick You already are hosting a game. Please complete your current game and then try again.

    }

    else {

      .notice $nick You currently are playing in a game. You cannot host a game while playing in another game. Please complete your current game and then try again.

    }

  }

}

on $*:TEXT:/^[!@.]roll/i:$($getChan):{

  if ($getGameID($nick) == $null) {

    .notice $nick You currently are not in a game.

  }

  elseif ($getHost($nick) == $nick) && ($isActivePlayer($nick,$nick) == $false) {

    .notice $nick You are not a player in the game you are hosting. Please wait for the player(s) to roll.

  }

  elseif ($getWhoRolls($getGameID($nick)) == 0) {

    .notice $nick The host rolls in the game in which you currently are playing. Please for the host to roll.

  }

  elseif ($getDiceSum($nick) == $null) {

    if ($getGameID($nick) == 10) {

      if ($2 == $null) {

        .notice $nick The game you are playing requires you to specify a number of dice to roll. The syntax is $1 <number of dice>.

      }

      elseif (($2 isnum 1-15) && ($int($2) == $2)) {

        rollDice $nick $2

      }

      else {

        .notice $nick The number of dice you specified is not an integer between 1 and 15, inclusive. Please check the number of dice and try again. The syntax is $1 <number of dice>.

      }

    }

    else {

      rollDice $nick

    }

  }

  else {

    .notice $nick You already rolled your dice. Please wait for the other player(s) in your game to roll.

  }

}

on $*:TEXT:/^[!@.](cancel|delete|end|remove)(d(ice)?d(uel)?)?/i:$($getChan):{

  if ($isHost($nick) == $true) {

    if ($2 == $null) {

      if ($getGameID($nick) == $null) {

        .notice $nick You currently are not hosting a game to cancel. The syntax is $1 <host>.

      }

      else {

        delGame $nick

      }

    }

    elseif ($2 == $nick) {

      if ($getGameID($nick) == $null) {

        .notice $nick You currently are not hosting a game to cancel. The syntax is $1 <host>.

      }

      else {

        delGame $nick

      }

    }

    elseif ($isBotStaff($nick) == $true) {

      if ($getHost($2) == $2) {

        delGame $2

      }

      elseif ($isHost($2) == $true) {

        .notice $nick The host you specified currently is not hosting a game. The syntax is $1 <host>.

      }

      else {

        .notice $nick The name you specified is not the name of a host. Please check your name and try again. The syntax is $1 <host>.

      }

    }

    else {

      .notice $nick You are permitted to cancel only your own games. Please contact a member of the staff for assistance.

    }

  }

}

on $*:TEXT:/^[!@.]addgiveaway/i:$($getChan):{

  ; !addgiveaway <item name> <minimum wager> <required dice sum>

  if ($isHost($nick) == $true) {

    if ($getGiveaway($nick) == $null) {

      var %itemName $2- [ $+ [ $calc($0 - 2) ] ], %minAction $fromNumSuf( $ [ $+ [ $calc($0 - 1) ] ] ), %reqDiceSum $ [ $+ [ $0 ] ]

      if (%minAction isnum 1-) {

        if (%reqDiceSum isnum 2-12) {

          addGiveaway $nick $2-

        }

        else {

          .notice $nick The required dice sum you specified is not an integer between 2 and 12, inclusive. Please check the required dice sum and try again. The syntax is $1 <item name> <wager> <dice sum>.

        }

      }

      else {

        .notice $nick The minimum wager you specified is invalid. Please check the minimum wager and try again. The syntax is $1 <item name> <min. wager> <req. dice sum>

      }

    }

    else {

      .notice $nick You already are hosting a giveaway. You cannot host more than one giveaway at a time. Please try again later.

    }

  }

}

on $*:TEXT:/^[!@.]giveaways?/i:$($getChan):{

  if (($left($1,1) == @) && ($isHost($nick) == $true)) {

    var %return msg #

  }

  else {

    var %return .notice $nick

    var %timerName $nick

  }

  if ($timer(Giveaway $+ %timerName) == $null) {

    if ($2 == $null) {

      if ($getGiveaway(0) == $null) {

        .notice $nick There currently are not any giveaways. Please check back later.

      }

      else {

        giveaway -l %return

      }

    }

    elseif ($getGiveaway(0) == $null) {

      .notice $nick There currently are not any giveaways. Please check back later.

    }

    elseif ($getGiveaway($2) == $null) {

      if ($2 isnum) {

        .notice $nick The giveaway number you specified is invalid. There currently are only $getGiveaway(0) giveaways. Please check the giveaway number and try again. The syntax is $1 <giveaway number>.

      }

      else {

        .notice $nick There currently is not a giveaway hosted by $2 $+ . Please check back later.

      }

    }

    else {

      giveaway -l %return $2

    }

  }

  else {

    .notice $nick The $1 command cannot be used more than once per minute $iif(%timerName == $null,in the channel) $+ . Please wait $duration($timer(Giveaway $+ %timerName).secs) and then try again.

  }

}

on $*:TEXT:/^[!@.]delgiveaway/i:$($getChan):{

  if ($isHost($nick) == $true) {

    if ($getGiveaway(0) == $null) {

      .notice $nick There currently aren't any giveaways. Please check back later.

    }

    elseif (($2 == $null) || ($2 == $nick)) {

      if ($getGiveaway($nick) == $null) {

        .notice $nick You currently are not hosting a giveaway.

      }

      else {

        delGiveaway $nick

      }

    }

    elseif ($isBotStaff($nick) == $true) {

      if ($getGiveaway($2) == $null) {

        if ($2 isnum) {

          .notice $nick There currently is not a giveaway $chr(35) $+ $2 $+ . Please check the giveaway number and try again. The syntax is $1 <giveaway number>.

        }

        else {

          .notice $nick There currently is not a giveaway hosted by $2 $+ . Please check the giveaway host and try again. The syntax is $1 <giveaway host>.

        }

      }

      else {

        delGiveaway $2

      }

    }

  }

}

on $*:TEXT:/^[!@.]cleargiveaways?/i:#:{

  if ($isBotStaff($nick) == $true) {

    if ($getGiveaway(0) == $null) {

      .notice $nick There currently are not any giveaways.

    }

    else {

      clearGiveaways

    }

  }

}

on $*:TEXT:/^[!@.]stats/i:$($getChan):{

  var %return msg #

  var %lookup $iif($2,$2,$nick)

  if ($ini(Dhm.ini,%lookup,0) == $null) {

    .notice $nick There aren't any stats for $color.playerName(%lookup) on record.

  }

  else {

    var %i 1,%n $numtok($getStats,32)

    while (%i <= %n) {

      var %item $gettok($getStats,%i,32)

      if ($getStats(%lookup,%item) != $null) {

        var %categoryName $regsubex(%item,/(.)([A-Z])/g,\1 $chr(32) $lower(\2))

        var %y %y %categoryName $+ : $color.stats(%item,$toNumSuf($getStat(%lookup,%item))) $iif(%i != %n,$chr(124))

      }

      inc %i

    }

    %return Stats: $color.playerName(%lookup) $chr(124) %y

  }

}

on $*:TEXT:/^[!@]preroll/Si:#dhm: {
  var %num2 $calc($rand(1, 6) + $rand(1, 6))
  notice $nick 01 You Rolled 05 %num2 01On Two-Six-Sided Dice.
}

on $*:TEXT:/^[!@]promo/Si:#: {
  if ($nick isop $chan) || ($nick ishop $chan) || ($nick isvoice $chan) {
    if ($2 ison $chan) && ($3 != $null) {
      msg $chan 12[ $+ $nick $+ ] 04 [ANNOUCEMENT] 10 $2 01has been selected to win: 07 $3
      msg $chan 01 Please trade 10 $nick 01at our dicing spot to claim your pize!
    }
  }
}

on $*:TEXT:/^[!@]commands(rmation)?\b/Si:#dhm: {
  if ($nick isop $chan) || ($nick ishop $chan) || ($nick isvoice $chan) {
    notice $nick 5 For 06 60x2 05do !60x2 NAME TOTALBET
    notice $nick 05 For 07 Dice Duels 05do !newdd NAME1 NAME2 INITALWAGER
    notice $nick 5 For Giveaways do !addgiveaway AMOUNT MINWAGER DICESUM
    notice $nick 5 for stats type !Stats NAME
    notice $nick 05 To clear a duel to !clear HOSTNAME (only put one of the names of the person in a duel)
  }
}

on $*:TEXT:/^[!@]clear/Si:#: {
  if ($nick isop $chan) || ($nick ishop $chan) || ($nick isvoice $chan) {
    if ($getGameID($2) != $null) {
      delGame $getHost($2)
    }
  }
}

on $*:TEXT:/^[!@](records|reset) (\S+)$/Si:#: {
  if ($nick isop $chan) || ($nick ishop $chan) {
    if ($2) {
      if ($regml(1) == records) {
        notice $nick 05 This user has made $sn(%bling [ $+ [ $regml(2) ] ]) profit from dice duel comission.
        notice $nick 05 This user owes $sn(%profit [ $+ [ $regml(2) ] ]) in admin commission.
        notice $nick 05 To refresh records for this user type !reset NAME
      }
      else {
        unset %profit [ $+ [ $regml(2) ] ]
        unset %bling [ $+ [ $regml(2) ] ]
        notice $nick 05 You have reset the specified users profit back to zero
      }
    }
  }
}

alias -l sn {
  if ($remove($$1,$chr(44)) isnum) {
    var %a $gettok($bytes($v1,b),0,44)
    var %b $bytes($v1,b)
    var %c $+($gettok(%b,1,44),$iif(%a != 1,.),$iif($mid($gettok(%b,2,44),1,2) == 0,0,$v1),$replace(%a,1,$null,2,k,3,m,4,b,5,t))
    return $iif(%c >= 1000 || $regex(%c,/[kmbt]/),$iif($prop,%c,$+($chr(40),%c,$chr(41))))
  }
}

;### Turns 1k into 1000 and such###
alias rp {
  var %a $remove($1,$chr(44))
  return $calc($regsubex(%a, /(\d+\.?\d+?|\d+)([kmbt])/g,$chr(40)\1*1 $+ $str(000,$pos(kmbt,\2)) $+ $chr(41)))

Comments

Sign in to comment.
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.