mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Feb 2015
Posts: 243
O
Fjord artisan
OP Offline
Fjord artisan
O
Joined: Feb 2015
Posts: 243
Hello!! My bot's points system is based on variables. Because there is no point of keeping points of users that havent played for a cretain time I have written an alias that deletes their score after more than 10 days have pased.
The variables that are checked/deleted are the following:
%w~network~nick numeric value ; this one is the wins of the user
%l~network~nick numeric value ; this one is the loses
%lastplay~network~nick $ctime ; this one is set when the user plays
%gfplayers~network user1~user2~user3~user4~user5 ;this one contains the users that have played
%networksnames net1~net2~net3~net4 ;list of networks
and here's the alias
Code:
alias scangflist {
  var %g = 1
  while (%g <= $numtok(%networksnames,126)) {
    inc %scannednets 1
    var %u = 1
    while (%u <= $numtok($($+(%,gfplayers,~,$gettok(%networksnames,%g,126)),2),126)) {
      inc %scannedplayers 1
      var %n = $gettok(%networksnames,%g,126)
      var %p = $gettok($($+(%,gfplayers,~,%n),2),%u,126)
      if ($calc($ctime - $($+(%,lastplay,~,%n,~,%p),2)) > 864000) {
        unset $+(%,lastplay,~,%n,~,$gettok($($+(%,gfplayers,~,%n),2),%u,126))
        unset $+(%,w,~,%n,~,$gettok($($+(%,gfplayers,~,%n),2),%u,126))
        unset $+(%,l,~,%n,~,$gettok($($+(%,gfplayers,~,%n),2),%u,126))
        set $+(%,gfplayers,~,%n) $remtok($($+(%,gfplayers,~,%n),2),$gettok($($+(%,gfplayers,~,%n),2),%u,126),1,126)
        inc %delscangf 1
      }
      inc %u
    }
    inc %g
  }
  scangfresults
}
;;the following one just echos the results of the scan
alias scangfresults { .timer 1 10 echo -at 14[7Timed GunFight-Score & Game Points14] 6Scan 3Completed14: 7Scanned3 %scannednets 7NetWorks And 4Deleted14: $iif(%delscangf, $v1, 0) 7From:3 %scannedplayers 7Total Players | .timer 1 11 unset %scannednets | .timer 1 13 unset %scannedplayers | .timer 1 14 unset %delscangf }

The end of the script is to check if each user that is on %gfplayers~network variable hadnt played for more than 10 days and if he/she hadn't it unsets his wins, loses and lastplay variable and removes him/he from the %gfplayers~network . Because i'm using the %gfplayers~network var for sorting the players for top N requests (where N is the number requested by the user. e.g OrFeAsGr: !top 10 or !top 30 ) i would like someone to try and fix this alias (and because for some unknown reason i hate hashtables). If it's too complicated though ill accept any alternative way smile Thanks in advance!
-OrFeAsGr-


P.S the sorting system works fine, and is not in this alias

Last edited by OrFeAsGr; 21/02/15 10:40 PM.
Joined: Jun 2014
Posts: 248
B
Fjord artisan
Offline
Fjord artisan
B
Joined: Jun 2014
Posts: 248
what needs to be fixed?

Joined: Feb 2015
Posts: 243
O
Fjord artisan
OP Offline
Fjord artisan
O
Joined: Feb 2015
Posts: 243
sorry i was upset for a personal matter last night .. and i forgot to mention what's the problem..
for some reason i cant find out it only removes most of the tokens from %gfplayers~network and lets all the other vars untouched

Joined: Dec 2008
Posts: 1,515
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,515
Try use this code:

Code:
alias scangflist {
  var %scannedplayers, %scannednets, %delscangf
  var %t = $numtok(%networksnames,126)
  var %g = 1
  while (%g <= %t) {
    var %net = $gettok(%networksnames,%g,126)
    var %tot = $numtok(%gfplayers~ [ $+ [ %net ] ],126)
    inc %scannednets 1
    var %u = 1
    while (%u <= %tot) {
      :again
      inc %scannedplayers 1
      var %nick = $gettok(%gfplayers~ [ $+ [ %net ] ],%u,126)
      if (!%nick) { goto next_net }
      var %last = %lastplay~ [ $+ [ %net ] $+ ] ~ [ $+ [ %nick ] ]
      var %last_calc = $calc(%last + 864000)
      var %10_day = $calc($ctime + 864000)
      if (%last_calc < %10_day) {
        unset %lastplay~ [ $+ [ %net ] $+ ] ~ [ $+ [ %nick ] ]
        unset %w~ [ $+ [ %net ] $+ ] ~ [ $+ [ %nick ] ]
        unset %l~ [ $+ [ %net ] $+ ] ~ [ $+ [ %nick ] ]
        var %fn = $findtok(%gfplayers~ [ $+ [ %net ] ],%nick,1,126)
        if (%fn) { 
          set %gfplayers~ [ $+ [ %net ] ] $deltok(%gfplayers~ [ $+ [ %net ] ],%fn,126)
          if (!%gfplayers~ [ $+ [ %net ] ]) { unset %gfplayers~ [ $+ [ %net ] ] }
          inc %delscangf 1
          goto again 
        }
      }
      inc %u
    }
    :next_net
    inc %g
  }
  echo -at 14[7Timed GunFight-Score & Game Points14] 6Scan 3Completed14: 7Scanned3 %scannednets 7NetWorks And 4Deleted14: $iif(%delscangf,$v1,0) 7From:3 %scannedplayers 7Total Players
}


Need Online mIRC help or an mIRC Scripting Freelancer? -> https://irc.chathub.org <-

Link Copied to Clipboard