Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- on *:text:!points:#: {
- var %points = $readini(%rosterFile, $findID($nick), points)
- msg $chan .me $nick has %points points.
- }
- on *:JOIN:#: {
- $+(timer, $nick) 0 3 addTimerPoints $nick
- }
- on *:PART:#: {
- $+(timer, $nick) off
- }
- // This alias adds timer points to a user every so often. It looks for them in the %rosterFile. If they are not there,
- // it adds them to the list then starts adding their points.
- alias -l addTimerPoints {
- var %ID = $findID(%rosterFile, %rosterID, $1)
- if (%ID == 0) {
- // NOTE: The alias $addUser([name]) is not in the current pastebin.
- $addUser($1)
- %ID = $findID(%rosterFile, %rosterID, $1)
- }
- var %currentPoints = $readini(%rosterFile, %ID, points)
- writeini -n %rosterFile %ID points $calc(%currentPoints + 1)
- }
- // Format: $addUser([username])
- alias -l adduser {
- var %user = $1
- // You can optionally insert an alias here to check if the user already exists in the roster.
- writeini -n %rosterFile $calc(%rosterID + 1) name %user
- writeini -n %rosterFile $calc(%rosterID + 1) points 0
- // You can add any other writeini commands here if you want to add any other information.
- inc %rosterID
- // You have to increase the ID every time so you don't keep getting 0 when you add a new user
- }
- // Example Format: var %userID = $findID([file], [fileID], [user])
- // This alias returns the section where the user is found. If the user is not found, it will return an ID of 0
- alias -l findID {
- var %file = $1
- var %ID = $2
- var %user = $3
- var %i = 1
- while (%i <= %ID) {
- if ($readini(%file, %i, name) == %user) {
- return %i
- }
- inc %i
- }
- return 0
- }
- on *:JOIN:#: {
- if ($nick == bulld0g_tv) {
- // This timer sets the $switchBankheistOn alias every 30 minutes. The $ is not used for the alias when inside a timer command
- timerSwitchBankheist 0 1800 switchBankheistOn $chan %bankheistIsOn
- }
- }
- // Format: !bankheist [bet]
- // This command goes through several checks before finally adding the player to the list %bankheistFile, an .ini file.
- on *:text:!bankheist*:#: {
- if (%bankheistIsOn == $false) {
- msg $chan /me The banks are currently closed!
- }
- else {
- var %pointsID = $findID(%rosterFile, $ini(%rosterFile, 0), $nick)
- var %currentPoints = $readini(%rosterFile, %pointsID, points)
- if (%pointsID == 0) {
- msg $chan /me $nick you have no points.
- }
- elseif ($0 == 1 || $2 !isnum) {
- msg $chan /me $nick you must enter a bet from your current points.
- }
- elseif ($2 > %currentPoints || $2 == 0) {
- msg $chan /me $nick you must enter a bet you can afford and is not 0 [Points available: $+(%currentpoints, ]).
- }
- else {
- var %ID = $findID(%bankheistFile, $ini(%bankheistFile, 0), $nick)
- if (%ID != 0) {
- var %bet = $readini(%bankheistFile, %ID, bet)
- msg $chan /me $nick you have already made a bet of %bet
- return
- }
- // msg $chan /me Now adding $nick to the bankheist list...
- writeini -n %bankheistFile $calc(%bankheistID + 1) name $nick
- writeini -n %bankheistFile $calc(%bankheistID + 1) bet $2
- inc %bankheistID
- }
- }
- }
- // This alias is used every 30 minutes. It starts another timer command after 60 seconds have passed. Users can only enter the
- // bankheist within that 60 second time period.
- alias -l switchBankheistOn {
- %bankheistIsOn = $true
- write -c %bankheistFile
- msg $1 /me Come one, come all! The banks are open for the taking! Use !bankheist [points] to bet. 60 seconds remaining to join.
- timerBankheistDuration 1 60 processBankheist $1
- }
- // Your starting chances of winning are 35%. Every additional person increases the chances of winning by 1%. This caps
- // off at 66%. The starting winnings start at 3:1. Every additional 10 people decrease the ratio by 1. This caps off at 1:1.
- alias -l processBankheist {
- if ($ini(%bankheistFile, 0) == 0) {
- %bankheistIsOn = $false
- msg $1 /me No one joined the Bankheist! The banks are safe for now.
- return
- }
- else {
- %bankheistIsOn = $false
- msg $1 /me The bankheist is now starting! Good luck folks!
- var %people = $ini(%bankheistFile, 0)
- var %chances = 0
- var %winningsRatio = 1
- if (%people >= 31) {
- %chances = 66
- %winningsRatio = 1
- }
- elseif (%people < 31 && %people >= 20) {
- %chances = $calc(35 + %people)
- %winningsRatio = 1
- }
- else {
- %chances = $calc(35 + %people)
- if (%people < 20 && %people >= 10) {
- %winningsRatio = 2
- }
- elseif (%people < 10) {
- %winningsRatio = 3
- }
- }
- msg $1 /me the current chances of surviving: $+(%chances, %)
- var %winnersList = The survivors of the bankheist are:
- var %winnersListEmpty = $true
- var %i = 1
- msg $1 /me number of people in the bankheist: %people
- while (%i <= %people) {
- // Chooses a random number between 1 and 100. If the number is within our chances, then the bankheist will be a success.
- var %name = $readini(%bankheistFile, %i, name)
- var %bet = $readini(%bankheistFile, %i, bet)
- var %pointsID = $findID(%rosterFile, $ini(%rosterFile, 0), %name)
- var %currentPoints = $readini(%rosterFile, %pointsID, points)
- var %randomNum = $rand(1, 100)
- if (%randomNum <= %chances) {
- writeini -n %rosterFile %pointsID points $calc(%currentPoints + %winningsRatio * %bet)
- %winnersList = $+(%winnersList, $chr(32), %name)
- %winnersListEmpty = $false
- }
- else {
- writeini -n %rosterFile %pointsID points $calc(%currentPoints - %bet)
- }
- inc %i
- }
- if (%winnersListEmpty == $true) {
- msg $1 /me No one survived the bankheist, everyone died!
- }
- else {
- msg $1 /me %winnersList
- }
- %bankheistID = 0
- }
- }
- // Format: $findID([file], [fileID], [user])
- // Returns the ID of the user in the specified file, or 0 if the user is not in that file
- alias -l findID {
- var %file = $1
- var %ID = $2
- var %user = $3
- var %i = 1
- while (%i <= %ID) {
- if ($readini(%file, %i, name) == %user) {
- return %i
- }
- inc %i
- }
- return 0
- }
Advertisement
Add Comment
Please, Sign In to add comment