Advertisement
dekzeh

SPL Auction Bot

Dec 19th, 2014
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.17 KB | None | 0 0
  1. on *:TEXT:!*:%spl.chan: {
  2. if ($1 == !showteam) && ($findtok(%spl.teams,$2,1,32)) {
  3. msg $iif($chan,$chan,$nick) $getfullname($2) Credits: $getcredits($2) $chr(124) Bidders: $getbidders($2) $chr(124) Players: $getplayers($2)
  4. }
  5. if ($chan) {
  6. if (($1 == !withdraw) && (%spl.active == 1) && ($getbidderteam($nick) == $getcurrteam)) {
  7. if ($getnumplayers($getcurrteam) < 14) {
  8. msg $chan  $+ %colour $+ Team must have purchased 14 players before withdrawing.
  9. return
  10. }
  11. set %spl.skip $puttok(%spl.skip,0,$getteam($getcurrteam),32)
  12. msg $chan $getfullname($getcurrteam) have withdrawn from the auction.
  13. msg $chan $getfullname($getnext) up to nominate. Bidders: $getbidders($getcurrteam)
  14. }
  15. if (($1 == !nominate) && (%spl.active == 1) && ($getbidderteam($nick) == $getcurrteam)) {
  16. if ($read(spl.txt,s,$replace($2-,$chr(32),\))) {
  17. if ($findtok(%spl.bought,$replace($2-,$chr(32),\),1,58)) {
  18. msg $chan  $+ %colour $+  $+ $2- has already been sold.
  19. return
  20. }
  21. msg $chan  $+ %colour $+ $getplayerdata($replace($gettok($read(spl.txt,$readn),1,32),$chr(32),\))
  22. set %spl.nominated $gettok($read(spl.txt,$readn),1,32)
  23. set %spl.active 2
  24. set %spl.highbid 3000
  25. set %spl.highbidteam $getcurrteam
  26. msg $chan $getfullname($getbidderteam($nick)) $+ : 3000
  27. set %spl.bids $puttok(%spl.bids,%spl.highbid,$getteam($getbidderteam($nick)),32)
  28. .timerinitial 1 %spl.time lastten
  29. }
  30. else {
  31. msg $chan $getfullname($getbidderteam($nick)) $+ : Player " $+ $2- $+ " not found.
  32. }
  33. }
  34. if ((($left($right($1,-1),1) isnum) || ($left($right($1,-1),1) == +)) && (%spl.active == 2)) {
  35. if ($isbidder($nick)) {
  36. if (!$gettok(%spl.skip,$getteam($getbidderteam($nick)),32)) {
  37. return
  38. }
  39. var %bid $processbid($right($1,-1))
  40. if (!%bid) {
  41. msg $chan $getfullname($getbidderteam($nick)) $+ : Invalid bid amount.
  42. return
  43. }
  44. if (($right(%bid,3) != 000) && ($right(%bid,3) != 500)) {
  45. msg $chan $getfullname($getbidderteam($nick)) $+ : Only bids that are multiples of 500 are accepted.
  46. return
  47. }
  48. if (%bid > $getmaxbid($getbidderteam($nick))) {
  49. msg $chan $getfullname($getbidderteam($nick)) $+ : Bid exceeds max bid of $getmaxbid($getbidderteam($nick)) $+ .
  50. return
  51. }
  52. if (%bid < $calc(%spl.highbid + 500)) {
  53. msg $chan $getfullname($getbidderteam($nick)) $+ : Bid must be at least 500 above %spl.highbid $+ .
  54. return
  55. }
  56. set %spl.highbid %bid
  57. set %spl.highbidteam $getbidderteam($nick)
  58. set %spl.bids $puttok(%spl.bids,%bid,$getteam($getbidderteam($nick)),32)
  59. msg $chan $getfullname($getbidderteam($nick)) $+ : %bid
  60. if (%spl.10) {
  61. lastten
  62. }
  63. }
  64. }
  65. if (($address($nick,2) == *!*@D4F965F9.DDDCFEE7.18227545.IP) || ($address($nick,2) == *!*@F0898D27.5C5A20DE.754B15C0.IP)) {
  66. if ($1 == !showall) {
  67. var %i 1
  68. while (%i <= $numtok(%spl.teams,32)) {
  69. msg $chan $getfullname($gettok(%spl.teams,%i,32)) Credits: $getcredits($gettok(%spl.teams,%i,32))  $+ $chr(124) Bidders: $getbidders($gettok(%spl.teams,%i,32)) $chr(124) Players: $getplayers($gettok(%spl.teams,%i,32))
  70. inc %i
  71. }
  72. }
  73. if (($1 == !setchan) && ($2)) {
  74. join $2
  75. set %spl.chan $2
  76. msg $chan  $+ %colour $+ Commands will now function only in $2 $+ .
  77. }
  78. if (($1 == !addcredits) && ($findtok(%spl.teams,$2,1,32)) && ($3 isnum)) {
  79. set %spl.credits $puttok(%spl.credits,$calc($getcredits($2) + $3),$getteam($2),32)
  80. msg $chan  $+ %colour $+  $+ $3 credits addaed to $getfullname($2) $+ .
  81. }
  82. if (($1 == !addretainer) && ($findtok(%spl.teams,$2,1,32)) && ($3 isnum) && ($4-)) {
  83. if ($read(spl.txt,s,$replace($4-,$chr(32),\))) {
  84. set %spl.credits $puttok(%spl.credits,$calc($getcredits($2) - $3),$getteam($2),32)
  85. set %spl.players $puttok(%spl.players,$addtok($gettok(%spl.players,$getteam($2),32),$replace($4-,$chr(32),\),44),$getteam($2),32)
  86. set %spl.bought %spl.bought $+ : $+ $replace($4-,$chr(32),\)
  87. set %spl.prices %spl.prices $+ : $+ $3
  88. set %spl.crspndteam %spl.crspndteam $+ : $+ $2
  89. msg $chan  $+ %colour $+  $+ $replace($4-,\,$chr(32)) retained by $getfullname($2) for $3 $+ .
  90. }
  91. else {
  92. msg $chan $getfullname($2) $+ : Player " $+ $4- $+ " not found.
  93. }
  94. }
  95. if (($1 == !settimer) && ($2 isnum)) {
  96. set %spl.time $2
  97. msg $chan  $+ %colour $+ Initial timer changed to $2 seconds.
  98. }
  99. if ($1 == !undobid) {
  100. msg $chan  $+ %colour $+ The highest bid has been forcefully retracted.
  101. set %spl.highbid $gettok($sorttok(%spl.bids,32,nr),2,32)
  102. set %spl.highbidteam $gettok(%spl.teams,$findtok(%spl.bids,%spl.highbid,1,32),32)
  103. msg $chan $getfullname(%spl.highbidteam) $+ : %spl.highbid
  104. }
  105. if (($1 == !pause) && (%spl.active >= 1)) {
  106. turntimersoff
  107. msg $chan  $+ %colour $+ The auction has been paused.
  108. set %spl.active 4 %spl.active
  109. }
  110. if (($1 == !resume) && ($gettok(%spl.active,1,32) == 4)) {
  111. set %spl.active $gettok(%spl.active,2,32)
  112. msg $chan  $+ %colour $+ The auction has been resumed.
  113. if (%spl.active == 2) {
  114. .timerinitial 1 %spl.time lastten
  115. msg $chan $getfullname(%spl.highbidteam) $+ : %spl.highbid
  116. }
  117. else if (%spl.active == 3) {
  118. .timercont 1 3 nextbidding
  119. }
  120. }
  121. if (($1 == !start) && (!%spl.active)) {
  122. msg $chan $getfullname($getnext) up to nominate. Bidders: $getbidders($getcurrteam)
  123. set %spl.active 1
  124. }
  125. if (($1 == !next) && (%spl.active)) {
  126. msg $chan  $+ %colour $+ Skipping to next team.
  127. msg $chan $getfullname($getnext) up to nominate. Bidders: $getbidders($getcurrteam)
  128. set %spl.active 1
  129. turntimersoff
  130. }
  131. if ($1 == !reset) {
  132. unset %spl.*
  133. set %spl.teams sha cry wol con alp ind fal big cir rai
  134. set %spl.credits 140000 140000 140000 140000 140000 140000 140000 140000 140000 140000
  135. set %spl.bidders . . . . . . . . . .
  136. set %spl.players ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
  137. set %spl.bids 0 0 0 0 0 0 0 0 0 0
  138. set %spl.skip 1 1 1 1 1 1 1 1 1 1
  139. set %spl.currbid 0
  140. set %spl.currdir 1
  141. set %spl.time 20
  142. set %spl.chan $chan
  143. turntimersoff
  144. msg $chan  $+ %colour $+ All details have been reset.
  145. }
  146. if ((($1 == !setcolour) || ($1 == !setcolor)) && ($2 isnum)) {
  147. if ($len($2) == 2) {
  148. set %colour $2
  149. }
  150. else {
  151. set %colour 0 $+ $2
  152. }
  153. msg $chan  $+ %colour $+ Text colour changed.
  154. }
  155. if (($1 == !addbidder) && ($findtok(%spl.teams,$2,1,32)) && ($3)) {
  156. if ($isbidder($3)) {
  157. msg $chan  $+ %colour $+ $3 is already a bidder for $getfullname($getbidderteam($3)) $+ .
  158. return
  159. }
  160. set %spl.bidders $puttok(%spl.bidders,$addtok($gettok(%spl.bidders,$getteam($2),32),$3,44),$getteam($2),32)
  161. msg $chan  $+ %colour $+ $3 added to bidders for $getfullname($2) $+ . Bidders: $getbidders($2)
  162. }
  163. if (($1 == !removebidder) && ($findtok(%spl.teams,$2,1,32)) && ($3) && ($3 != .)) {
  164. if (!$findtok($gettok(%spl.bidders,$getteam($2),32),$3,1,44)) {
  165. msg $chan  $+ %colour $+ $3 is not a bidder for $getfullname($2) $+ . Bidders: $getbidders($2)
  166. return
  167. }
  168. set %spl.bidders $puttok(%spl.bidders,$remtok($gettok(%spl.bidders,$getteam($2),32),$3,1,44),$getteam($2),32)
  169. msg $chan  $+ %colour $+ $3 removed from bidders for $getfullname($2) $+ . Bidders: $getbidders($2)
  170. }
  171. }
  172. }
  173. }
  174.  
  175. alias getteam {
  176. return $findtok(%spl.teams,$1,1,32)
  177. }
  178.  
  179. alias getfullname {
  180. if ($1 == alp) { return 7The Alpha Ruiners $+ %colour }
  181. if ($1 == ind) { return 6The Indie Scooters $+ %colour }
  182. if ($1 == big) { return 12The Ever Grande BIGs $+ %colour }
  183. if ($1 == rai) { return 9The Team Raiders $+ %colour }
  184. if ($1 == con) { return 14The Congregation of the Classiest $+ %colour }
  185. if ($1 == cry) { return 11The Cryonicles $+ %colour }
  186. if ($1 == sha) { return 10The Stark Sharks $+ %colour }
  187. if ($1 == cir) { return 13The Circus Maximus Tigers $+ %colour }
  188. if ($1 == wol) { return 4The Wifi Wolfpack $+ %colour }
  189. if ($1 == fal) { return 5The Firebot Falcons $+ %colour }
  190. }
  191.  
  192. alias getbidders {
  193. return $replace($gettok(%spl.bidders,$getteam($1),32),. $+ $chr(44),$chr(32),.,$chr(32),$chr(44),$chr(32) / $chr(32))
  194. }
  195. alias getcredits {
  196. return $gettok(%spl.credits,$getteam($1),32)
  197. }
  198. alias getplayers {
  199. return $replace($gettok(%spl.players,$getteam($1),32),\,$chr(32),^ $+ $chr(44),$chr(32),^,$chr(32),$chr(44),$chr(32) / $chr(32))
  200. }
  201. alias getcurrteam {
  202. return $gettok(%spl.teams,%spl.currbid,32)
  203. }
  204.  
  205. alias getnext {
  206. set %spl.currbid $calc(%spl.currbid + %spl.currdir)
  207. if (%spl.currbid == 11) {
  208. set %spl.currbid 10
  209. set %spl.currdir -1
  210. }
  211. else if (%spl.currbid == 0) {
  212. set %spl.currbid 1
  213. set %spl.currdir 1
  214. }
  215. var %count 0
  216. while ($gettok(%spl.skip,$getteam($getcurrteam),32) == 0) {
  217. set %spl.currbid $calc(%spl.currbid + %spl.currdir)
  218. if (%spl.currbid == 11) {
  219. set %spl.currbid 10
  220. set %spl.currdir -1
  221. }
  222. else if (%spl.currbid == 0) {
  223. set %spl.currbid 1
  224. set %spl.currdir 1
  225. }
  226. inc %count
  227. if (%count == 20) {
  228. endauction
  229. halt
  230. }
  231. }
  232. return $gettok(%spl.teams,%spl.currbid,32)
  233. }
  234.  
  235. alias isbidder {
  236. var %i 1
  237. while (%i <= 10) {
  238. if ($findtok($gettok(%spl.bidders,%i,32),$1,1,44)) {
  239. return $true
  240. }
  241. inc %i
  242. }
  243. return $false
  244. }
  245.  
  246. alias processbid {
  247. ; if ($left($1,1) == +) {
  248. ; var %pbid $right($1,-1)
  249. ; var %pbid $processplusbid(%pbid)
  250. ; if (%pbid == 0) {
  251. ; return 0
  252. ; }
  253. ; var %mbid %spl.highbid
  254. ; }
  255. ; else {
  256. var %pbid 0
  257. var %mbid $1
  258. ; }
  259. if (%mbid isnum 3-94) {
  260. return $iif($numtok($calc(%mbid * 1000),46) == 1,$calc(%mbid * 1000 + %pbid),0)
  261. }
  262. else if (%mbid isnum 3000-94000) {
  263. return $iif($numtok(%mbid,46) == 1,$calc(%mbid + %pbid),0)
  264. }
  265. else if ($right(%mbid,1) == k) {
  266. var %kbid $left(%mbid,-1)
  267. if (%kbid isnum 3-94) {
  268. return $iif($numtok($calc(%kbid * 1000),46) == 1,$calc(%kbid * 1000 + %pbid),0)
  269. }
  270. }
  271. return 0
  272. }
  273.  
  274. alias processplusbid {
  275. if ($left($1,1) == +) {
  276. return 0
  277. }
  278. else {
  279. var %pbid 0
  280. var %mbid $1
  281. }
  282. if (%mbid isnum 0.5-94) {
  283. return $iif($numtok($calc(%mbid * 1000),46) == 1,$calc(%mbid * 1000 + %pbid),0)
  284. }
  285. else if (%mbid isnum 500-94000) {
  286. return $iif($numtok(%mbid,46) == 1,$calc(%mbid + %pbid),0)
  287. }
  288. else if ($right(%mbid,1) == k) {
  289. var %kbid $left(%mbid,-1)
  290. if (%kbid isnum 0.5-94) {
  291. return $iif($numtok($calc(%kbid * 1000),46) == 1,$calc(%kbid * 1000 + %pbid),0)
  292. }
  293. }
  294. return 0
  295. }
  296.  
  297. alias getbidderteam {
  298. var %i 1
  299. while (%i <= 10) {
  300. if ($findtok($gettok(%spl.bidders,%i,32),$1,1,44)) {
  301. return $gettok(%spl.teams,%i,32)
  302. }
  303. inc %i
  304. }
  305. }
  306.  
  307. alias getnumplayers {
  308. return $calc($numtok($gettok(%spl.players,$getteam($1),32),44) - 1)
  309. }
  310.  
  311. alias getmaxbid {
  312. return $calc($getcredits($1) - ($iif($calc(13 - $getnumplayers($1)) >= 0,$calc(13 - $getnumplayers($1)),0) * 3000))
  313. }
  314.  
  315. alias getplayerdata {
  316. var %metagames ORAS_OU ORAS_UBERS ORAS_UU ORAS_RU ORAS_NU DOUBLES BW2_OU DPP_OU ADV_OU GSC_OU RBY_OU
  317. var %i 1
  318. var %data $read(spl.txt,s,$1)
  319. while (%i <= 11) {
  320. if (y isin $gettok(%data,%i,58)) {
  321. var %mplayed %mplayed $replace($gettok(%metagames,%i,32),_,$chr(32)) /
  322. }
  323. inc %i
  324. }
  325. var %mplayed $deltok(%mplayed,$numtok(%mplayed,32),32)
  326. return  $+ $replace($1,\,$chr(32)) is up for auction. Metagames: %mplayed
  327. }
  328.  
  329. alias lastten {
  330. .timerfive off
  331. .timerten off
  332. set %spl.10 1
  333. .timerten 1 10 endbidding
  334. .timerfive 1 5 msg %spl.chan  $+ %colour $+ 5 seconds remaining.
  335. }
  336.  
  337. alias endbidding {
  338. msg %spl.chan  $+ %colour $+ SOLD: $replace(%spl.nominated,\,$chr(32)) to $getfullname(%spl.highbidteam) for %spl.highbid $+ .
  339. set %spl.credits $puttok(%spl.credits,$calc($getcredits(%spl.highbidteam) - %spl.highbid),$getteam(%spl.highbidteam),32)
  340. set %spl.players $puttok(%spl.players,$addtok($gettok(%spl.players,$getteam(%spl.highbidteam),32),$replace(%spl.nominated,$chr(32),\),44),$getteam(%spl.highbidteam),32)
  341. set %spl.active 3
  342. set %spl.bids 0 0 0 0 0 0 0 0 0 0
  343. unset %spl.10
  344. set %spl.bought %spl.bought $+ : $+ %spl.nominated
  345. set %spl.prices %spl.prices $+ : $+ %spl.highbid
  346. set %spl.crspndteam %spl.crspndteam $+ : $+ %spl.highbidteam
  347. if ($getcredits(%spl.highbidteam) < 3000) {
  348. set %spl.skip $puttok(%spl.skip,0,$getteam(%spl.highbidteam),32)
  349. }
  350. .timercont 1 8 nextbidding
  351. }
  352.  
  353. alias nextbidding {
  354. var %i 1
  355. while (%i <= $numtok(%spl.teams,32)) {
  356. msg %spl.chan $getfullname($gettok(%spl.teams,%i,32)) Credits: $getcredits($gettok(%spl.teams,%i,32))  $+ $chr(124) Players: $getplayers($gettok(%spl.teams,%i,32))
  357. inc %i
  358. }
  359. msg %spl.chan $getfullname($getnext) up to nominate. Bidders: $getbidders($getcurrteam)
  360. set %spl.active 1
  361. }
  362.  
  363. alias endauction {
  364. msg %spl.chan  $+ %colour $+ The auction has officially ended.
  365. turntimersoff
  366. outputtofile
  367. }
  368.  
  369. alias turntimersoff {
  370. .timercont off
  371. .timerten off
  372. .timerfive off
  373. .timerinitial off
  374. }
  375.  
  376. alias outputtofile {
  377. write splrecord.txt -----
  378. write splrecord.txt -----
  379. write splrecord.txt -----
  380. write splrecord.txt -----
  381. write splrecord.txt -----
  382. write splrecord.txt Log for auction that concluded at $fulldate in %spl.chan
  383. var %i 1
  384. var %num $numtok(%spl.bought,58)
  385. while (%i <= %num) {
  386. write splrecord.txt $replace($gettok(%spl.bought,%i,58),\,$chr(32)) $+ : $gettok(%spl.prices,%i,58) ( $+ $strip($getfullname($gettok(%spl.crspndteam,%i,58))) $+ )
  387. inc %i
  388. }
  389. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement