Advertisement
westor

Twitch Points System for patrick v1.0

Feb 7th, 2015
568
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 5.75 KB | None | 0 0
  1. alias points return 1
  2. alias points_per_secs return 60
  3.  
  4. ON *:PART:#: {
  5.   if ($nick == $me) { .timer[START_*] off | .timer[GIVE_POINTS_*] off }
  6.   elseif ($nick !== $me) { .timer[GIVE_POINTS_ $+ $chan $+ _TO_ $+ $nick $+ ] off }
  7. }
  8. ON *:JOIN:#: {
  9.   if ($nick == $me) { .timer[START_ $+ $chan $+ _GIVE_POINTS] 1 3 start_give_points $chan $points }
  10.   elseif ($nick !== $me) { .timer[GIVE_POINTS_ $+ $chan $+ _TO_ $+ $nick $+ ] 1 $points_per_secs give_points $nick $chan $points }
  11. }
  12.  
  13. ON *:TEXT:!*:#: {
  14.   tokenize 32 $strip($1-,burci)
  15.   if ($1 == !addpoints) {
  16.     if (!$2) { .msg $chan ( $+ $nick $+ ): Error, Please specify a nickname! | return }
  17.     if ($2 == $nick) { .msg $chan ( $+ $nick $+ ): Error, You cannot use this command to your self! | return }
  18.     if ($2 == $me) { .msg $chan ( $+ $nick $+ ): Error, You cannot use this command to the bot! | return }
  19.     if (!$3) { .msg $chan ( $+ $nick $+ ): Error, Please specify points! | return }
  20.     if ($3) && ($3 !isnum) { .msg $chan ( $+ $nick $+ ): Error, Please use only numbers on points! | return }
  21.     give_points $2 $chan $3
  22.     .msg $chan ( $+ $nick $+ ): You have just gave $qt($2) nickname $qt($3) points.
  23.   }
  24.   if ($1 == !delpoints) {
  25.     if (!$2) { .msg $chan ( $+ $nick $+ ): Error, Please specify a nickname! | return }
  26.     if ($2 == $nick) { .msg $chan ( $+ $nick $+ ): Error, You cannot use this command to your self! | return }
  27.     if ($2 == $me) { .msg $chan ( $+ $nick $+ ): Error, You cannot use this command to the bot! | return }
  28.     if (!$3) { .msg $chan ( $+ $nick $+ ): Error, Please specify points! | return }
  29.     if ($3) && ($3 !isnum) { .msg $chan ( $+ $nick $+ ): Error, Please use only numbers on points! | return }
  30.     take_points $2 $chan $3
  31.     .msg $chan ( $+ $nick $+ ): You have just took from $qt($2) nickname $qt($3) points.
  32.   }
  33.   if ($1 == !points) {
  34.     if (!$2) {
  35.       var %f = $mircdirpoints\ $+ $mkfn($chan) $+ .db
  36.       if (!$isfile(%f)) { .msg $chan ( $+ $nick $+ ): You have NOT any points yet! | return }
  37.       if (!$lines(%f)) { .msg $chan ( $+ $nick $+ ): You have NOT any points on the database yet! | return }
  38.       var %r = $gettok($read(%f,ntw,$nick *),2,32)
  39.       if (!%r) { .msg $chan ( $+ $nick $+ ): You have NOT earn any points yet! }
  40.       elseif (%r) { .msg $chan ( $+ $nick $+ ): You $iif(%r == 1,has,have) %r $iif(%r == 1,point,points) $+ . }
  41.     }
  42.     elseif ($2) {
  43.       if ($2 == $nick) { .msg $chan ( $+ $nick $+ ): Error, You cannot use this command to your self! | return }
  44.       if ($2 == $me) { .msg $chan ( $+ $nick $+ ): Error, You cannot use this command to the bot! | return }
  45.       var %f = $mircdirpoints\ $+ $mkfn($chan) $+ .db
  46.       if (!$isfile(%f)) { .msg $chan ( $+ $nick $+ ): The $qt($2) have NOT any points yet! | return }
  47.       if (!$lines(%f)) { .msg $chan ( $+ $nick $+ ): The $qt($2) have NOT any points on the database yet! | return }
  48.       var %r = $gettok($read(%f,ntw,$2 *),2,32)
  49.       if (!%r) { .msg $chan ( $+ $nick $+ ): The $qt($2) did NOT earn any points yet! }
  50.       elseif (%r) { .msg $chan ( $+ $nick $+ ): The $qt($2) $iif(%r == 1,has,have) %r $iif(%r == 1,point,points) $+ . }
  51.     }
  52.   }
  53.   if ($1 == !totalpoints) {
  54.     var %f = $mircdirpoints\ $+ $mkfn($chan) $+ .db
  55.     if (!$isfile(%f)) { .msg $chan ( $+ $nick $+ ): You have NOT any points yet! | return }
  56.     var %t = $lines(%f)
  57.     if (!%t) { .msg $chan ( $+ $nick $+ ): There is NOT any nickname on the database yet! }
  58.     elseif (%t) { .msg $chan ( $+ $nick $+ ): There are %t total nicknames on the points database. }
  59.   }
  60.   if (!top* iswm $1) {
  61.     var %f = $mircdirpoints\ $+ $mkfn($chan) $+ .db
  62.     var %com = $remove($1,!top)
  63.     if (%com !isnum) { .msg $chan ( $+ $nick $+ ): Error, Please use the correct top stats! | return }
  64.     if (!$isfile(%f)) { .msg $chan ( $+ $nick $+ ): There is NOT any points on my database yet! | return }
  65.     if (!$lines(%f)) { .msg $chan ( $+ $nick $+ ): There are NOT any points on the database yet! | return }
  66.     points_stats_top $chan $nick %com
  67.   }
  68. }
  69.  
  70. alias start_give_points {
  71.   if (!$1) { return }
  72.   if (!$isdir($mircdirpoints)) { mkdir points }
  73.   var %t = $nick($1,0)
  74.   var %i = 1
  75.   while (%i <= %t) {
  76.     var %n = $nick($1,%i)
  77.     if (%n) && (%n !== $me) { .timer[GIVE_POINTS_ $+ $1 $+ _TO_ $+ %n $+ ] 0 $points_per_secs give_points %n $1 $points }
  78.     inc %i
  79.   }
  80. }
  81.  
  82. alias take_points {
  83.   if (!$1) { return }
  84.   if (!$isdir($mircdirpoints)) { mkdir points }
  85.   var %f = $mircdirpoints\ $+ $mkfn($2) $+ .db
  86.   if (!$isfile(%f)) { return }
  87.   if (!$lines(%f)) { return }
  88.   var %r = $gettok($read(%f,ntw,$1 *),2,32)
  89.   var %rn = $readn
  90.   if (%r) { write -l $+ %rn $qt(%f) $1 $calc(%r - $3) }
  91.   elseif (!%r) { write $qt(%f) $1 $3 }
  92. }
  93.  
  94. alias give_points {
  95.   if (!$1) { return }
  96.   if (!$isdir($mircdirpoints)) { mkdir points }
  97.   var %f = $mircdirpoints\ $+ $mkfn($2) $+ .db
  98.   if (!$isfile(%f)) { write $qt(%f) $1 $3 | return }
  99.   if (!$lines(%f)) { write $qt(%f) $1 $3 | return }
  100.   var %r = $gettok($read(%f,ntw,$1 *),2,32)
  101.   var %rn = $readn
  102.   if (%r) { write -l $+ %rn $qt(%f) $1 $calc(%r + $3) }
  103.   elseif (!%r) { write $qt(%f) $1 $3 }
  104. }
  105.  
  106. alias points_stats_top {
  107.   if (!$1-) { return }
  108.   var %ch = $1
  109.   var %nick_for = $2
  110.   var %tt = $3
  111.   var %win = @top_ $+ %ch
  112.   var %db = $mircdirpoints\ $+ $mkfn(%ch) $+ .db
  113.   var %db_lines = $lines(%db)
  114.   if (!$isfile(%db)) { return }
  115.   if ($window(%win)) { window -c %win }
  116.   window -hj $+ %db_lines %win
  117.   loadbuf %win $qt(%db)
  118.   filter -ceutww 2 32 %win %win
  119.   var %ii 1
  120.   while (%ii <= %tt) {
  121.     var %list = $addtok(%list,$line(%win,%ii),44)
  122.     inc %ii
  123.   }
  124.   .msg $1 ( $+ %nick_for $+ ): TOP $+ %tt Stats (Points) are: $replace(%list,$chr(44),$+($chr(44),$chr(32)))
  125.   if ($window(%win)) { window -c %win }
  126. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement