Advertisement
Logikos

familyfeud not working right after I messed with it :(

Feb 16th, 2014
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.09 KB | None | 0 0
  1. /*
  2. Commands:
  3. !ff number
  4. -------------
  5. Starts the game
  6. "!ff 1" starts a 1 round game, "!ff unlimited or !ff" starts an unlimited game
  7. -------------
  8. !ffstop
  9. -------------
  10. Stops the game
  11. -------------
  12. !ffscore
  13. -------------
  14. Notices a user his/her score
  15. -------------
  16. !ffscores
  17. -------------
  18. Messages the scores to the channel (Also messaged at the end of each round)
  19. */
  20.  
  21. ;Reads from a text file and grabs a random line's Question and answers in the format: Question*Answer1-Answer2-Answer3-Answer4-Answer5-Answer6-Answer7-Answer8
  22.  
  23. on *:LOAD:/FFsetchan $?="Type the name of the channel you would like Family Feud to be active in (Including #)"
  24.  
  25. menu nicklist,channel,status,menubar,query {
  26. Family Feud
  27. .$iif(%FF.on != 2,Start):/FFStart $me $chan $?="How many rounds? For unlimited rounds say unlimited."
  28. .$iif(%FF.on == 2,Stop):/FFStop $me $chan
  29. .Set Family Feud Channel:/FFsetchan $?="Type the name of the channel you would like Family Feud to be active in (Including #)"
  30. }
  31.  
  32. alias FFsetchan { set %chanFF $1
  33. set %chanFF $chan
  34. }
  35. on $*:TEXT:/^[!]f(f|fstart)(\s|$)/Si:#:{
  36. if ($nick isop $chan) {
  37. if ($2 != $null) { FFstart $nick $chan $2 }
  38. else { FFstart $nick $chan 1 }
  39. }
  40. else {
  41. msg $chan Sorry $nick $+ , you need to be an op to start Family Feud.
  42. }
  43. }
  44.  
  45. alias FFstart {
  46. if ( %FF.on != 2 ) {
  47. msg %chanFF A game of Family Feud has been started!
  48. set %FF.answerz 0
  49. set %FF.on 2
  50. set %FF.roundsplayed 1
  51. set %FF.rounds $3
  52. game
  53. }
  54. else { msg $chan $1 The game's already going, maybe you should try answering some questions now. }
  55. }
  56. alias question {
  57. set %FF.line $read(FamFeud.txt)
  58. set %FF.num $pos(%FF.line, *, 1)
  59. set %FF.length $len(%FF.line)
  60. set %FF.numA %FF.length - %FF.num
  61. set %FF.numQ %FF.num - 1
  62. set %FF.dashes $count(%FF.line, -)
  63.  
  64. set %FF.answers $right(%FF.line, %FF.numA)
  65. set %FF.question $left(%FF.line, %FF.numQ)
  66.  
  67. set %FF.numcom $pos(%FF.answers, -, 1) - 1
  68. set %FF.numcom2 $len(%FF.answers) - $pos(%FF.answers, -, 1)
  69. set %FF.a1 $left(%FF.answers, %FF.numcom)
  70. set %FF.answers $right(%FF.answers, %FF.numcom2)
  71. if ( %FF.dashes > 0 ) {
  72. set %FF.numcom $pos(%FF.answers, -, 1) - 1
  73. set %FF.numcom2 $len(%FF.answers) - $pos(%FF.answers, -, 1)
  74. set %FF.a2 $left(%FF.answers, %FF.numcom)
  75. set %FF.answers $right(%FF.answers, %FF.numcom2)
  76. }
  77. if ( %FF.dashes > 1 ) {
  78. set %FF.numcom $pos(%FF.answers, -, 1) - 1
  79. set %FF.numcom2 $len(%FF.answers) - $pos(%FF.answers, -, 1)
  80. set %FF.a3 $left(%FF.answers, %FF.numcom)
  81. set %FF.answers $right(%FF.answers, %FF.numcom2)
  82. }
  83. if ( %FF.dashes > 2 ) {
  84. set %FF.numcom $pos(%FF.answers, -, 1) - 1
  85. set %FF.numcom2 $len(%FF.answers) - $pos(%FF.answers, -, 1)
  86. set %FF.a4 $left(%FF.answers, %FF.numcom)
  87. set %FF.answers $right(%FF.answers, %FF.numcom2)
  88. }
  89. if ( %FF.dashes > 3 ) {
  90. set %FF.numcom $pos(%FF.answers, -, 1) - 1
  91. set %FF.numcom2 $len(%FF.answers) - $pos(%FF.answers, -, 1)
  92. set %FF.a5 $left(%FF.answers, %FF.numcom)
  93. set %FF.answers $right(%FF.answers, %FF.numcom2)
  94. }
  95. if ( %FF.dashes > 4 ) {
  96. set %FF.numcom $pos(%FF.answers, -, 1) - 1
  97. set %FF.numcom2 $len(%FF.answers) - $pos(%FF.answers, -, 1)
  98. set %FF.a6 $left(%FF.answers, %FF.numcom)
  99. set %FF.answers $right(%FF.answers, %FF.numcom2)
  100. }
  101. if ( %FF.dashes > 5 ) {
  102. set %FF.numcom $pos(%FF.answers, -, 1) - 1
  103. set %FF.numcom2 $len(%FF.answers) - $pos(%FF.answers, -, 1)
  104. set %FF.a7 $left(%FF.answers, %FF.numcom)
  105. set %FF.answers $right(%FF.answers, %FF.numcom2)
  106. }
  107.  
  108. if ( %FF.dashes == 0 ) { set %FF.a1 %FF.answers }
  109. if ( %FF.dashes == 1 ) { set %FF.a2 %FF.answers }
  110. if ( %FF.dashes == 2 ) { set %FF.a3 %FF.answers }
  111. if ( %FF.dashes == 3 ) { set %FF.a4 %FF.answers }
  112. if ( %FF.dashes == 4 ) { set %FF.a5 %FF.answers }
  113. if ( %FF.dashes == 5 ) { set %FF.a6 %FF.answers }
  114. if ( %FF.dashes == 6 ) { set %FF.a7 %FF.answers }
  115. if ( %FF.dashes == 7 ) { set %FF.a8 %FF.answers }
  116. if ( %FF.dashes > 7 ) {
  117. set %FF.numcom $pos(%FF.answers, -, 1) - 1
  118. set %FF.numcom2 $len(%FF.answers) - $pos(%FF.answers, -, 1)
  119. set %FF.a8 $left(%FF.answers, %FF.numcom)
  120. set %FF.answers $right(%FF.answers, %FF.numcom2)
  121. }
  122.  
  123. inc %FF.dashes
  124.  
  125. ;I was having issues with my other answer variables and timers so I just made a second set for the check alias.
  126. set %FF.answerz 0
  127. set %FF.a12 %FF.a1
  128. set %FF.a22 %FF.a2
  129. set %FF.a32 %FF.a3
  130. set %FF.a42 %FF.a4
  131. set %FF.a52 %FF.a5
  132. set %FF.a62 %FF.a6
  133. set %FF.a72 %FF.a7
  134. set %FF.a82 %FF.a8
  135. if (%FF.roundsplayed != $null) { msg %chanFF Round %FF.roundsplayed / %FF.rounds $+ $chr(124) $+ $chr(124) Question ( $+ $readn $+ / $+ $lines(FamFeud.txt) $+ ): %FF.question }
  136. else { msg %chanFF Question ( $+ $readn $+ / $+ $lines(FamFeud.txt) $+ ): %FF.question }
  137. msg %chanFF There are %FF.dashes answers!
  138. }
  139.  
  140. alias game {
  141. if (%FF.roundsplayed == $null || %FF.roundsplayed <= %FF.rounds) {
  142. question
  143. .timer1 1 60 game2
  144. .timer3 1 40 remaining
  145. }
  146. else { FFstop }
  147. }
  148.  
  149. alias game2 {
  150. if ( %FF.dashes == 1 ) { msg %chanFF That's it! The answer was: %FF.a12 }
  151. if ( %FF.dashes == 2 ) { msg %chanFF That's it! The answers were (in order): %FF.a12 and %FF.a22 }
  152. if ( %FF.dashes == 3 ) { msg %chanFF That's it! The answers were (in order): %FF.a12 $+ , %FF.a22 $+ , and %FF.a32 }
  153. if ( %FF.dashes == 4 ) { msg %chanFF That's it! The answers were (in order): %FF.a12 $+ , %FF.a22 $+ , %FF.a32 $+ , and %FF.a42 }
  154. if ( %FF.dashes == 5 ) { msg %chanFF That's it! The answers were (in order): %FF.a12 $+ , %FF.a22 $+ , %FF.a32 $+ , %FF.a42 $+ , and %FF.a52 }
  155. if ( %FF.dashes == 6 ) { msg %chanFF That's it! The answers were (in order): %FF.a12 $+ , %FF.a22 $+ , %FF.a32 $+ , %FF.a42 $+ , %FF.a52 $+ , and %FF.a62 }
  156. if ( %FF.dashes == 7 ) { msg %chanFF That's it! The answers were (in order): %FF.a12 $+ , %FF.a22 $+ , %FF.a32 $+ , %FF.a42 $+ , %FF.a52 $+ , %FF.a62 $+ , and %FF.a72 }
  157. if ( %FF.dashes == 8 ) { msg %chanFF That's it! The answers were (in order): %FF.a12 $+ , %FF.a22 $+ , %FF.a32 $+ , %FF.a42 $+ , %FF.a52 $+ , %FF.a62 $+ , %FF.a72 $+ , and %FF.a82 }
  158. buildscores
  159. if (%FF.roundsplayed != $null) { inc %FF.roundsplayed }
  160. unset %FF.a*
  161. if (%FF.roundsplayed > %FF.rounds) { FFstop }
  162. if (%FF.on == 2) { msg $chan %FF.scoreoutput }
  163. if (%FF.on == 2) { .timer2 1 10 game }
  164. ;7 second delay between questions.
  165. }
  166.  
  167. alias remaining {
  168. set %FF.remain The remaining answers are:
  169. if ( %FF.a1 != $null ) { set %FF.remain %FF.remain #1 }
  170. if ( %FF.a2 != $null ) { set %FF.remain %FF.remain #2 }
  171. if ( %FF.a3 != $null ) { set %FF.remain %FF.remain #3 }
  172. if ( %FF.a4 != $null ) { set %FF.remain %FF.remain #4 }
  173. if ( %FF.a5 != $null ) { set %FF.remain %FF.remain #5 }
  174. if ( %FF.a6 != $null ) { set %FF.remain %FF.remain #6 }
  175. if ( %FF.a7 != $null ) { set %FF.remain %FF.remain #7 }
  176. if ( %FF.a8 != $null ) { set %FF.remain %FF.remain #8 }
  177. msg %chanFF %FF.remain
  178. }
  179.  
  180. on *:TEXT:!ffstop:#:{
  181. if ($nick isop $chan) {
  182. FFstop $nick $chan
  183. }
  184. else {
  185. msg $chan Sorry $nick $+ , you need to be a Moderator to Stop Family Feud.
  186. }
  187. }
  188. on *:TEXT:!fftop:#:{
  189. var %x 1
  190. while (%x <= $ini(feud.ini,Totals,0)) {
  191. var %nick $ini(feud.ini,Totals,%x)
  192. var %scores $addtok(%scores,$+($readini(feud.ini,Totals,%nick),.,%nick),32)
  193. inc %x
  194. }
  195. var %scores $sorttok(%scores,32,nr)
  196. var %scores $gettok(%scores,1-10,32)
  197. var %scores $mid($regsubex(%scores,/(\d+)\.(\S+)/g,\2: \1$chr(44)),1,-1)
  198. msg $chan [Family Feud - Top Ten] %scores
  199. }
  200.  
  201. alias fftopten {
  202. var %x 1
  203. while (%x <= $ini(feud.ini,Totals,0)) {
  204. var %nick $ini(feud.ini,Totals,%x)
  205. var %scores $addtok(%scores,$+($readini(feud.ini,Totals,%nick),.,%nick),32)
  206. inc %x
  207. }
  208. var %scores $sorttok(%scores,32,nr)
  209. var %scores $gettok(%scores,1-10,32)
  210. var %scores $mid($regsubex(%scores,/(\d+)\.(\S+)/g,\2: \1$chr(44)),1,-1)
  211. /set var %finalscores1 = %scores
  212. ;msg $chan [Family Feud - Top Ten] %scores
  213. }
  214.  
  215. alias FFstop {
  216. if ( %FF.on == 2 ) {
  217. if ($1 != $null) { msg $chan Game stopped by $1 $+ .
  218. buildscores
  219. msg $chan %FF.scoreoutput
  220. .timer1 off
  221. .timer2 off
  222. .timer3 off
  223. unset %FF.*
  224. remini feud.ini Current
  225. }
  226. elseif ($1 == $null) { msg $chan Game over!
  227. buildscores
  228. .timer1 off
  229. .timer2 off
  230. .timer3 off
  231. unset %FF.*
  232. remini feud.ini Current
  233. }
  234. else { msg $chan Family Feud is not currently running. }
  235. }
  236.  
  237. on *:TEXT:!ffscore:#:{
  238. msg $chan $nick $+ , your current score is $iif($readini(feud.ini,n,Current,$nick) == $null,[zero],$v1) $&
  239. - your all time score is $iif($readini(feud.ini,n,Totals,$nick) == $null,[zero],$v1)
  240. }
  241.  
  242. ;Text events for all 8 answers
  243.  
  244. on *:TEXT:%FF.a1:%chanFF:{
  245. msg %chanFF Survey says, 3 points! $nick got the #1 answer, %FF.a1 $+ !
  246. inc %FF.score. [ $+ [ $nick ] ] 3
  247. writeini -n feud.ini Current $nick $calc($readini(feud.ini,n,Current,$nick) + 3)
  248. writeini -n feud.ini Totals $nick $calc($readini(feud.ini,n,Totals,$nick) + 3)
  249. unset %FF.a1
  250. set %FF.answerz %FF.answerz + 1
  251. check %FF.answerz
  252. }
  253.  
  254. on *:TEXT:%FF.a2:%chanFF:{
  255. msg %chanFF Survey says, 2 points! $nick got the #2 answer, %FF.a2 $+ !
  256. inc %FF.score. [ $+ [ $nick ] ] 2
  257. writeini -n feud.ini Current $nick $calc($readini(feud.ini,n,Current,$nick) + 2)
  258. writeini -n feud.ini Totals $nick $calc($readini(feud.ini,n,Totals,$nick) + 2)
  259. unset %FF.a2
  260. set %FF.answerz %FF.answerz + 1
  261. check %FF.answerz
  262. }
  263.  
  264. on *:TEXT:%FF.a3:%chanFF:{
  265. msg %chanFF Survey says, 2 points! $nick got the #3 answer, %FF.a3 $+ !
  266. inc %FF.score. [ $+ [ $nick ] ] 2
  267. writeini -n feud.ini Current $nick $calc($readini(feud.ini,n,Current,$nick) + 2)
  268. writeini -n feud.ini Totals $nick $calc($readini(feud.ini,n,Totals,$nick) + 2)
  269. unset %FF.a3
  270. set %FF.answerz %FF.answerz + 1
  271. check %FF.answerz
  272. }
  273.  
  274. on *:TEXT:%FF.a4:%chanFF:{
  275. msg %chanFF Survey says, 1 points! $nick got the #4 answer, %FF.a4 $+ !
  276. inc %FF.score. [ $+ [ $nick ] ] 1
  277. writeini -n feud.ini Current $nick $calc($readini(feud.ini,n,Current,$nick) + 1)
  278. writeini -n feud.ini Totals $nick $calc($readini(feud.ini,n,Totals,$nick) + 1)
  279. unset %FF.a4
  280. set %FF.answerz %FF.answerz + 1
  281. check %FF.answerz
  282. }
  283.  
  284. on *:TEXT:%FF.a5:%chanFF:{
  285. msg %chanFF Survey says, 1 points! $nick got the #5 answer, %FF.a5 $+ !
  286. inc %FF.score. [ $+ [ $nick ] ] 1
  287. writeini -n feud.ini Current $nick $calc($readini(feud.ini,n,Current,$nick) + 1)
  288. writeini -n feud.ini Totals $nick $calc($readini(feud.ini,n,Totals,$nick) + 1)
  289. /unset %FF.a5
  290. set %FF.answerz %FF.answerz + 1
  291. check %FF.answerz
  292. }
  293.  
  294. on *:TEXT:%FF.a6:%chanFF:{
  295. msg %chanFF Survey says, 1 points! $nick got the #6 answer, %FF.a6 $+ !
  296. inc %FF.score. [ $+ [ $nick ] ] 1
  297. writeini -n feud.ini Current $nick $calc($readini(feud.ini,n,Current,$nick) + 1)
  298. writeini -n feud.ini Totals $nick $calc($readini(feud.ini,n,Totals,$nick) + 1)
  299. unset %FF.a6
  300. set %FF.answerz %FF.answerz + 1
  301. check %FF.answerz
  302. }
  303.  
  304. on *:TEXT:%FF.a7:%chanFF:{
  305. msg %chanFF Survey says, 1 points! $nick got the #7 answer, %FF.a7 $+ !
  306. inc %FF.score. [ $+ [ $nick ] ] 1
  307. writeini -n feud.ini Current $nick $calc($readini(feud.ini,n,Current,$nick) + 1)
  308. writeini -n feud.ini Totals $nick $calc($readini(feud.ini,n,Totals,$nick) + 1)
  309. unset %FF.a7
  310. set %FF.answerz %FF.answerz + 1
  311. check %FF.answerz
  312. }
  313.  
  314. on *:TEXT:%FF.a8:%chanFF:{
  315. msg %chanFF Survey says, 1 points! $nick got the #8 answer, %FF.a8 $+ !
  316. inc %FF.score. [ $+ [ $nick ] ] 1
  317. writeini -n feud.ini Current $nick $calc($readini(feud.ini,n,Current,$nick) + 1)
  318. writeini -n feud.ini Totals $nick $calc($readini(feud.ini,n,Totals,$nick) + 1)
  319. unset %FF.a8
  320. set %FF.answerz %FF.answerz + 1
  321. check %FF.answerz
  322. }
  323.  
  324.  
  325. alias buildscores {
  326. var %x 1
  327. while (%x <= $ini(feud.ini,Current,0)) {
  328. var %nick $ini(feud.ini,Current,%x)
  329. var %scores %scores $+(%nick,:) $readini(feud.ini,Current,%nick)
  330. inc %x
  331. }
  332. set %FF.scoreoutput [Game scores] %scores
  333. }
  334. }
  335.  
  336. ;Checks to see if all answers have been said before time limit is up
  337. alias check {
  338. if ( $1 == %FF.dashes ) {
  339. .timer1 off
  340. .timer3 off
  341. game2
  342. }
  343. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement