Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- on *:TEXT:!guess*:#: {
- if ($1 != !guess) halt
- ; ||-----|| This section is for mods only ||-----||
- ; Checks if user is operator (mod) on channel.
- if ($ismod()) {
- if ($2 == timer) {
- if ($3 == set) {
- if ($4 isnum) {
- if (($4 < 60) || ($4 > 3600)) {
- msg # Please select a time between 50 and 3600 seconds.
- halt
- }
- writeini $get_filename() Info Timer $4
- msg # New Timer set.
- if ($readini($get_filename(), n, Info, Running)) {
- timerHuntGuess off
- timerHuntGuess 0 $readini($get_filename(), n, Info, Timer) print_guess_message
- halt
- }
- halt
- }
- halt
- }
- halt
- }
- if ($2 == new) {
- if ($is_running) {
- msg # Guessing is already running. To stop it, use !guess stop.
- halt
- }
- var %old_winners 1
- var %old_prize €50 Cash
- var %old_timer 300
- var %text Couldn't find the previous guess-file. Creating a new with default settings.
- if ($isfile($get_filename())) {
- var %old_winners $readini($get_filename(), n, Info, Winners)
- var %old_prize $readini($get_filename(), n, Info, Prize)
- var %old_timer $readini($get_filename(), n, Info, Timer)
- var %text Archived the last Guess, copied the settings and created a new one. SeemsGood
- archive
- }
- writeini $get_filename() Info Winners %old_winners
- writeini $get_filename() Info Prize %old_prize
- writeini $get_filename() Info Timer %old_timer
- writeini $get_filename() Info Channel $chan
- msg # %text
- halt
- }
- if ($2 == avg) {
- msg # Average betsize: € $+ $round($get_avg_betsize(), 2)
- halt
- }
- if ($2 == rb) {
- if ($3 != $null) {
- var %restbalance $replace($3, $chr(44), $chr(46))
- if (%restbalance isnum) {
- writeini $get_filename() Info RestBalance %restbalance
- msg # Restbalance is now set to %restbalance $+ . It will be subtracted from the amount used in !guess pick.
- halt
- }
- msg # @ $+ $nick That's not a valid number.
- halt
- }
- var %restbalance $readini($get_filename(), n, Info, RestBalance)
- if (%restbalance == $null) var %restbalance 0
- msg # Restbalance is currently set to € $+ %restbalance $+ .
- halt
- }
- if ($2 == start) {
- if ($is_running) {
- msg # Guessing is already running. To stop it, use !guess stop.
- halt
- }
- if (!$readini(stats\channel_variables.ini, n, Bullet, Hunt)) {
- msg # Bonushunt bullet not set, aborting script. (!sethuntbullet <amount>)
- halt
- }
- if ($readini($get_filename(), n, Info, Start) != $null) {
- msg # This Guess is already tagged as "completed". If you want to start a new one, use "!guess new" first.
- halt
- }
- var %total_bonuses $ini(bonushunt.ini, Collected, 0)
- var %hunt_bullet $readini(stats\channel_variables.ini, n, Bullet, Hunt)
- var %avg_betsize $round($get_avg_betsize(), 2)
- var %topic Guess the outcome of the bonushunt! € $+ %hunt_bullet was invested with %total_bonuses bonuses in total. (€ $+ %avg_betsize average betsize)
- ; writing guess-info to file
- writeini $get_filename() Info Bullet %hunt_bullet
- writeini $get_filename() Info Topic %topic
- start_guess
- msg # /me What will the balance be after all the bonuses have been completed? Type "!guess <your guess>" to join. (Example: !guess $calc($get_hunt_bullet() - 500 + $rand(0, 2000)) $+ )
- timerHuntGuess 0 $readini($get_filename(), n, Info, Timer) print_guess_message $get_filename() $chan
- halt
- }
- ; stopping the guessing, denying more entries and writing an end time to file
- if ($2 == stop) {
- if (!$is_running) {
- msg # @ $+ $nick Stop what? The guessing isn't running at the moment. FailFish
- halt
- }
- stop_guess
- timerHuntGuess off
- writeini $get_filename() Info End $ctime
- var %entries $ini($get_filename(), Guess, 0)
- if (%entries == $null) var %entries 0
- msg # /me Guessing stopped! No more entries accepted. Total entries: %entries
- halt
- }
- ; Removing user from the list
- if ($2 == remove) {
- if ($3 == $null) {
- msg # @ $+ $nick $+ , To remove a user from the guessing list, type "!guess remove <user>"
- halt
- }
- var %user $readini($get_filename(), n, Guess, $3)
- if (%user != $null) {
- remini $get_filename() Guess $3
- remini $get_filename() Winners $3
- msg # $3 removed from list.
- halt
- }
- msg # Could not find $3 in the list.
- halt
- }
- if ($2 == pick) {
- if ($is_running) {
- msg # @ $+ $nick Guessing is currently running. To pick a winner, you need to stop it first. "!guess stop".
- halt
- }
- var %result $replace($3, $chr(44), $chr(46))
- if ($3 !isnum) {
- msg # @ $+ $nick That's not a valid number.
- halt
- }
- var %restbalance $readini($get_filename(), n, Info, RestBalance)
- if (%restbalance) {
- var %result $calc(%result - %restbalance)
- }
- writeini $get_filename() Info Result %result
- var %amount_winners $readini($get_filename(), n, Info, Winners)
- if ($ini($get_filename(), Winners, 0) == %amount_winners) {
- msg # Winners were already picked!
- halt
- }
- remini $get_filename Winners
- var %x 1
- while ((%x <= %amount_winners) && ($ini($get_filename(), Guess, 0) != 0)) {
- var %winner $find_winner(%result)
- var %guess $readini($get_filename(), n, Guess, %winner)
- writeini $get_filename() Winners %winner %guess
- inc %x
- }
- print_winners
- halt
- }
- if ($2 == setwinners) {
- if (($3 isnum) && ($3 > 0)) {
- var %winners $round($3, 0)
- msg # Total number of winners set to %winners
- writeini $get_filename Info Winners %winners
- }
- else msg # @ $+ $nick Please provide the number of winners to be picked for when the hunt is completed.
- halt
- }
- if ($2 == setprize) {
- msg # Setting prize to $3-
- writeini $get_filename Info Prize $3-
- halt
- }
- }
- ; ||-----|| This section is for everyone ||-----||
- if ($2 == help) {
- msg # If guessing is open, you can join by typing '!guess <your guess>' (Ex: !guess 7777). Use '!guess prize' to see what you can win. '!guess rules' to read the rules. '!guess check' to check your entry.
- halt
- }
- if ($2 == prize) {
- if ($readini($get_filename(), Info, Prize) == $null) writeini $get_filename Info Prize €50 Cash
- msg # The prize(s) of this contest: => $readini($get_filename(), Info, Prize) <= PogChamp
- halt
- }
- if ($2 == rules) {
- var %winners $readini($get_filename, n, Info, Winners)
- if (%winners > 1) {
- msg # /me The funds left in the account after all bonuses are played (minus the starting balance) will be the 'result' used to pick the winners. $chr(9679) YOU NEED TO BE A FOLLOWER of this channel to be able to win. $chr(9679) The %winners closest guesses will be the winners. $chr(9679) We reserve the rights to redistribute any prize at our own discretion.
- }
- else msg # /me The funds left in the account after all bonuses are played (minus the starting balance) will be the 'result' used to pick a winner. $chr(9679) YOU NEED TO BE A FOLLOWER of this channel to be able to win. $chr(9679) The closest guess will be the winner. $chr(9679) We reserve the rights to redistribute any prize at our own discretion.
- halt
- }
- if ($2 == check) {
- var %input $3
- var %input $remove(%input, @)
- if (%input == $null) var %input $nick
- if (%input !isnum) {
- var %value $readini($get_filename(), n, Guess, %input)
- if (%value != $null) {
- if (%input == $nick) {
- msg # @ $+ $nick $+ , You're in the list with the guess € $+ %value
- halt
- }
- msg # @ $+ $nick $+ , %input guessed € $+ %value for today.
- halt
- }
- if (%input == $nick) {
- msg # @ $+ $nick $+ , You didn't make a guess today.
- halt
- }
- msg # @ $+ $nick $+ , Couldn't find %input in todays list.
- halt
- }
- var %list $get_guess_list(%input)
- var %text $numtok(%list, 32)
- if (%text == $null) var %text 0
- msg # There are %text entries with the guess € $+ %input
- halt
- }
- if (!$is_running()) {
- if ($ini($get_filename(), Winners, 0)) print_winners
- elseif ($ini($get_filename(), Guess, 0)) msg # @ $+ $nick $+ , Guessing is currently closed. It ended $asctime($readini($get_filename(), Info, End), HH:nn) with $ini($get_filename(), Guess, 0) entries. The winners have not yet been revealed!
- else msg # Guessing is not open yet. It will start as soon as a moderator writes "!guess start".
- halt
- }
- ; Guess is running, but the user didn't add a guess. Same as above, if it was more than 5 second since the last displayed text, it will print this message.
- if ($2 == $null) {
- print_guess_message
- halt
- }
- var %guess $replace($2, $chr(44), $chr(46))
- var %guess $remove(%guess, €)
- if (%guess isnum) var %guess $round(%guess, 2)
- if ((%guess !isnum) || (%guess < 0)) {
- if ((%guess !isnum) && (@ isin %guess)) {
- halt
- }
- msg # @ $+ $nick Invalid guess. Only numbers above 0 accepted. You wrote $2 $+ .
- halt
- }
- if ((%guess !isnum) || (%guess > 99999)) {
- msg # @ $+ $nick Come on. Get real! It's just not going to happen. Guess denied! FailFish
- halt
- }
- var %is_guesser $false
- if ($readini($get_filename(), n, Guess, $nick) != $null) {
- var %is_guesser $true
- remini $get_filename() Guess $nick
- }
- writeini $get_filename() Guess $nick %guess
- if (%is_guesser) msg # Changing guess for $nick $+ . The new one is € $+ %guess $+ .
- else msg # Guess placed for $nick (€ $+ %guess $+ )
- halt
- }
- alias -l get_avg_betsize {
- var %totalbetsize 0
- var %x 1
- var %collected $ini(bonushunt.ini, Collected, 0)
- while (%x <= %collected) {
- var %item $ini(bonushunt.ini, Collected, %x)
- var %totalbetsize $calc( %totalbetsize + $readini(bonushunt.ini, n, Collected, %item) )
- inc %x
- }
- return $calc(%totalbetsize / %collected)
- }
- alias -l print_winners {
- var %result $readini($get_filename(), n, Info, Result)
- var %x 1
- var %text There were no winners. FeelsBadMan
- while (%x <= $ini($get_filename(), Winners, 0)) {
- var %user $ini($get_filename(), Winners, %x)
- var %guess $readini($get_filename(), n, Winners, %user)
- var %diff $calc($calc(%result - %guess) * -1)
- if (%diff > 0) var %diff + $+ %diff
- if (%x == 1) {
- if ($ini($get_filename(), Winners, 0) == 1) var %text %user (€ $+ %guess / %diff $+ )
- else var %text %x $+ . %user (€ $+ %guess / %diff $+ )
- }
- else {
- var %text %text $chr(9679) %x $+ . %user (€ $+ %guess / %diff $+ )
- }
- inc %x
- }
- var %time $asctime($readini($get_filename(), Info, End), dd.mm.yy HH:nn)
- if ($readini($get_filename(), n, Info, Announced)) {
- if ($ini($get_filename(), Winners, 0) == 1) msg # Final balance: € $+ %result $+ . The winner was: %text $+ . This contest ended %time $+ .
- else msg # Final balance: € $+ %result $+ . The winners: %text $+ . This contest ended %time $+ .
- }
- else {
- if ($ini($get_filename(), Winners, 0) == 1) msg # Final balance: € $+ %result $+ . The winner is: %text $+ . Congratulations! The prize: $readini($get_filename(), Info, Prize) FeelsAmazingMan
- else msg # Final balance: € $+ %result $+ . The winners: %text $+ . Congratulations! Here are the prizes: $readini($get_filename(), Info, Prize) FeelsAmazingMan
- writeini $get_filename() Info Announced $true
- }
- }
- alias -l get_filename {
- return bonushunt_guess.ini
- }
- alias -l start_guess {
- writeini $get_filename() Info Start $ctime
- writeini $get_filename() Info Running $true
- }
- alias -l stop_guess {
- writeini $get_filename() Info Running $false
- }
- alias -l is_running {
- if ($isfile($get_filename())) {
- if ($readini($get_filename(), n, Info, Running)) return $true
- }
- return $false
- }
- alias -l get_hunt_bullet {
- return $readini(stats\channel_variables.ini, n, Bullet, Hunt)
- }
- alias -l print_guess_message {
- var %chan $readini($get_filename(), n, Info, Channel)
- var %time $calc($ctime - $readini($get_filename(), Info, Start))
- var %minute $floor($calc(%time / 60))
- var %sec $calc(%time % 60)
- var %entries $ini($get_filename(), Guess, 0)
- if (%entries == $null) var %entries 0
- msg %chan /me $readini($get_filename(), Info, Topic) Type "!guess" followed by your number to join. (Example: !guess $calc($get_hunt_bullet() - 500 + $rand(0, 2000)) $+ ). Runtime: %minute $+ m %sec $+ s. %entries entries so far. Only followers can win. Type "!guess rules" to see the rules.
- }
- alias -l archive {
- if (!$isfile($get_filename())) return 0
- var %date $asctime($ctime, ddmmyyyy)
- var %new_file archive\bonushunt_guess $+ %date $+ .ini
- if ($exists(%new_file)) {
- var %x 2
- while ($exists(%new_file)) {
- var %new_file archive\bonushunt_guess $+ %date $+ _ $+ %x $+ .ini
- inc %x
- }
- }
- copy $get_filename() %new_file
- if ($exists(%new_file)) {
- remove $get_filename()
- return 1
- }
- else {
- return 0
- }
- }
- alias -l get_guess_list {
- var %x 1
- var %result
- var %length $ini($get_filename(), Guess, 0)
- while (%x <= %length) {
- var %item $ini($get_filename(), Guess, %x)
- if ($1 == all) {
- var %result $addtok(%result, $ini($get_filename(), Guess, %x), 32)
- }
- elseif ($readini($get_filename(), n, Guess, %item) == $1) {
- var %result $addtok(%result, $ini($get_filename(), Guess, %x), 32)
- }
- inc %x
- }
- return %result
- }
- alias -l is_winner {
- var %user $1
- var %result $readini($get_filename(), n, Winners, %user)
- if (%result != $null) return $true
- else return $ralse
- }
- alias -l find_winner {
- var %result $1
- var %x 1
- var %total $ini($get_filename(), Guess, 0)
- var %under 0
- var %over 1000000
- var %under_user
- var %over_user
- while (%x <= %total) {
- var %user $ini($get_filename(), Guess, %x)
- var %guess $readini($get_filename(), n, Guess, %user)
- if ($is_winner(%user)) {
- inc %x
- continue
- }
- if (%guess == %result) return %user
- if ((%guess >= %under) && (%guess <= %result)) {
- var %under %guess
- var %under_user %user
- }
- elseif ((%guess <= %over) && (%guess >= %result)) {
- var %over %guess
- var %over_user %user
- }
- inc %x
- }
- var %under_diff $calc(%result - %under)
- var %over_diff $calc(%over - %result)
- if (%under_diff < %over_diff) return %under_user
- else return %over_user
- }
- alias -l find_lowest_guess {
- var %x 1
- var %total $ini($get_filename(), Guess, 0)
- var %lowest
- var %lowest_user
- while (%x <= %total) {
- var %user $ini($get_filename(), Guess, %x)
- var %guess $readini($get_filename(), n, Guess, %user)
- if (%x == 1) {
- var %lowest %guess
- var %lowest_user %user
- }
- else {
- if (%guess < %lowest) {
- var %lowest %guess
- var %lowest_user %user
- }
- }
- inc %x
- }
- return %lowest
- }
- alias -l find_highest_guess {
- var %x 1
- var %total $ini($get_filename(), Guess, 0)
- var %highest 0
- var %highest_user
- while (%x <= %total) {
- var %user $ini($get_filename(), Guess, %x)
- var %guess $readini($get_filename(), n, Guess, %user)
- if (%x == 1) {
- var %highest %guess
- var %highest_user %user
- }
- else {
- if (%guess > %highest) {
- var %highest %guess
- var %highest_user %user
- }
- }
- inc %x
- }
- return %highest
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement