Guest User

Untitled

a guest
Mar 1st, 2015
421
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.15 KB | None | 0 0
  1. on *:text:!points:#: {
  2. var %points = $readini(%rosterFile, $findID($nick), points)
  3. msg $chan .me $nick has %points points.
  4. }
  5.  
  6. on *:JOIN:#: {
  7. $+(timer, $nick) 0 3 addTimerPoints $nick
  8. }
  9.  
  10. on *:PART:#: {
  11. $+(timer, $nick) off
  12. }
  13.  
  14. // This alias adds timer points to a user every so often. It looks for them in the %rosterFile. If they are not there,
  15. // it adds them to the list then starts adding their points.
  16. alias -l addTimerPoints {
  17. var %ID = $findID(%rosterFile, %rosterID, $1)
  18. if (%ID == 0) {
  19. // NOTE: The alias $addUser([name]) is not in the current pastebin.
  20. $addUser($1)
  21. %ID = $findID(%rosterFile, %rosterID, $1)
  22. }
  23. var %currentPoints = $readini(%rosterFile, %ID, points)
  24. writeini -n %rosterFile %ID points $calc(%currentPoints + 1)
  25. }
  26. // Format: $addUser([username])
  27. alias -l adduser {
  28. var %user = $1
  29. // You can optionally insert an alias here to check if the user already exists in the roster.
  30. writeini -n %rosterFile $calc(%rosterID + 1) name %user
  31. writeini -n %rosterFile $calc(%rosterID + 1) points 0
  32. // You can add any other writeini commands here if you want to add any other information.
  33. inc %rosterID
  34. // You have to increase the ID every time so you don't keep getting 0 when you add a new user
  35. }
  36.  
  37. // Example Format: var %userID = $findID([file], [fileID], [user])
  38. // This alias returns the section where the user is found. If the user is not found, it will return an ID of 0
  39. alias -l findID {
  40. var %file = $1
  41. var %ID = $2
  42. var %user = $3
  43. var %i = 1
  44. while (%i <= %ID) {
  45. if ($readini(%file, %i, name) == %user) {
  46. return %i
  47. }
  48. inc %i
  49. }
  50. return 0
  51. }
  52.  
  53.  
  54.  
  55. on *:JOIN:#: {
  56. if ($nick == bulld0g_tv) {
  57. // This timer sets the $switchBankheistOn alias every 30 minutes. The $ is not used for the alias when inside a timer command
  58. timerSwitchBankheist 0 1800 switchBankheistOn $chan %bankheistIsOn
  59. }
  60. }
  61.  
  62. // Format: !bankheist [bet]
  63. // This command goes through several checks before finally adding the player to the list %bankheistFile, an .ini file.
  64. on *:text:!bankheist*:#: {
  65. if (%bankheistIsOn == $false) {
  66. msg $chan /me The banks are currently closed!
  67. }
  68. else {
  69. var %pointsID = $findID(%rosterFile, $ini(%rosterFile, 0), $nick)
  70. var %currentPoints = $readini(%rosterFile, %pointsID, points)
  71. if (%pointsID == 0) {
  72. msg $chan /me $nick you have no points.
  73. }
  74. elseif ($0 == 1 || $2 !isnum) {
  75. msg $chan /me $nick you must enter a bet from your current points.
  76. }
  77. elseif ($2 > %currentPoints || $2 == 0) {
  78. msg $chan /me $nick you must enter a bet you can afford and is not 0 [Points available: $+(%currentpoints, ]).
  79. }
  80. else {
  81. var %ID = $findID(%bankheistFile, $ini(%bankheistFile, 0), $nick)
  82. if (%ID != 0) {
  83. var %bet = $readini(%bankheistFile, %ID, bet)
  84. msg $chan /me $nick you have already made a bet of %bet
  85. return
  86. }
  87. // msg $chan /me Now adding $nick to the bankheist list...
  88. writeini -n %bankheistFile $calc(%bankheistID + 1) name $nick
  89. writeini -n %bankheistFile $calc(%bankheistID + 1) bet $2
  90. inc %bankheistID
  91. }
  92. }
  93. }
  94.  
  95. // This alias is used every 30 minutes. It starts another timer command after 60 seconds have passed. Users can only enter the
  96. // bankheist within that 60 second time period.
  97. alias -l switchBankheistOn {
  98. %bankheistIsOn = $true
  99. write -c %bankheistFile
  100. msg $1 /me Come one, come all! The banks are open for the taking! Use !bankheist [points] to bet. 60 seconds remaining to join.
  101. timerBankheistDuration 1 60 processBankheist $1
  102. }
  103.  
  104.  
  105. // Your starting chances of winning are 35%. Every additional person increases the chances of winning by 1%. This caps
  106. // 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.
  107. alias -l processBankheist {
  108. if ($ini(%bankheistFile, 0) == 0) {
  109. %bankheistIsOn = $false
  110. msg $1 /me No one joined the Bankheist! The banks are safe for now.
  111. return
  112. }
  113. else {
  114. %bankheistIsOn = $false
  115. msg $1 /me The bankheist is now starting! Good luck folks!
  116.  
  117. var %people = $ini(%bankheistFile, 0)
  118. var %chances = 0
  119. var %winningsRatio = 1
  120. if (%people >= 31) {
  121. %chances = 66
  122. %winningsRatio = 1
  123. }
  124. elseif (%people < 31 && %people >= 20) {
  125. %chances = $calc(35 + %people)
  126. %winningsRatio = 1
  127. }
  128. else {
  129. %chances = $calc(35 + %people)
  130. if (%people < 20 && %people >= 10) {
  131. %winningsRatio = 2
  132. }
  133. elseif (%people < 10) {
  134. %winningsRatio = 3
  135. }
  136. }
  137. msg $1 /me the current chances of surviving: $+(%chances, %)
  138. var %winnersList = The survivors of the bankheist are:
  139. var %winnersListEmpty = $true
  140. var %i = 1
  141. msg $1 /me number of people in the bankheist: %people
  142. while (%i <= %people) {
  143. // Chooses a random number between 1 and 100. If the number is within our chances, then the bankheist will be a success.
  144. var %name = $readini(%bankheistFile, %i, name)
  145. var %bet = $readini(%bankheistFile, %i, bet)
  146. var %pointsID = $findID(%rosterFile, $ini(%rosterFile, 0), %name)
  147.  
  148. var %currentPoints = $readini(%rosterFile, %pointsID, points)
  149. var %randomNum = $rand(1, 100)
  150. if (%randomNum <= %chances) {
  151. writeini -n %rosterFile %pointsID points $calc(%currentPoints + %winningsRatio * %bet)
  152. %winnersList = $+(%winnersList, $chr(32), %name)
  153. %winnersListEmpty = $false
  154. }
  155. else {
  156. writeini -n %rosterFile %pointsID points $calc(%currentPoints - %bet)
  157. }
  158. inc %i
  159. }
  160. if (%winnersListEmpty == $true) {
  161. msg $1 /me No one survived the bankheist, everyone died!
  162. }
  163. else {
  164. msg $1 /me %winnersList
  165. }
  166. %bankheistID = 0
  167. }
  168. }
  169.  
  170. // Format: $findID([file], [fileID], [user])
  171. // Returns the ID of the user in the specified file, or 0 if the user is not in that file
  172. alias -l findID {
  173. var %file = $1
  174. var %ID = $2
  175. var %user = $3
  176. var %i = 1
  177.  
  178. while (%i <= %ID) {
  179. if ($readini(%file, %i, name) == %user) {
  180. return %i
  181. }
  182. inc %i
  183. }
  184. return 0
  185. }
Advertisement
Add Comment
Please, Sign In to add comment