mIRC Home    About    Download    Register    News    Help

Print Thread
#188274 20/10/07 08:48 AM
Joined: Feb 2003
Posts: 3,432
S
sparta Offline OP
Hoopy frood
OP Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
I using this code and it working fine:
Code:
alias chan_addlist {
  var %countcl = $chan(0)
  while (%countcl) {
    if ($chan isin %lchannel.list) { return }
    var %chan = $+($chan(%countcl),$chr(44))
    %lchannel.list = $instok(%lchannel.list,$chan(%countcl),1,44)
    dec %countcl
  }
}

The problem is that i cant get it to replace the last channel if i join one new channel, the script is triggered when i :join: a channel. someone that ether can explain or show me how i can solve this.. smile


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
Joined: Jun 2006
Posts: 508
D
Fjord artisan
Offline
Fjord artisan
D
Joined: Jun 2006
Posts: 508
In the code below, the # is added to the var, then the var is shortened to the first 9 items (after adding the new one). You can adjust the number of items in the list
here... $gettok($instok(%lchannel.list,#,1,44),1-9,44)
Code:
alias chan_addlist {
  if !$istok(%lchannel.list,#,44) { %lchannel.list = $gettok($instok(%lchannel.list,#,1,44),1-9,44) }
}


If you dont care how long the list grows (bearing in mind that you will sooner or later hit the 950 char limit) use this
Code:
alias chan_addlist {
  if !$istok(%lchannel.list,#,44) { %lchannel.list = $instok(%lchannel.list,#,1,44) }
}



Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
The code you posted in an alias which has to be called from within a script or manually activated (ie: you type /chan_addlist)

Since you state that it runs when you join a channel, you probably have a script (or part of a script) that looks like
Code:
on me:*:join:#: chan_addlist


If you can show us that part of the script or the script that calls the alias, I think that would be more helpful than the alias.

A bit off topic, but here's a re-write of the alias that I like the looks of better.
Code:
alias chan_addlist {
  var %countcl = $chan(0)
  while %countcl {
    set %lchannel.list $addtok(%lchannel.list,$chan(%countcl),44)
    dec %coundcl
  }
}


Joined: Jun 2006
Posts: 508
D
Fjord artisan
Offline
Fjord artisan
D
Joined: Jun 2006
Posts: 508
There shouldn't be any need to loop channels, as the others would have been handled in their own join event. wink

Joined: Feb 2003
Posts: 3,432
S
sparta Offline OP
Hoopy frood
OP Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
Code:
on ^*:join:#: {
  haltdef
  if ($nick == $me) {
    chan_addlist
    more code
   }
   else {
   other code
  }
}

the code that triggers it looks like this, and i use $submenu to grab the channels from the var, but i didnt post it since it's not that i have a problem to solve, and i only use the 6 first channels that are added to the list, so maybe it can be done in a way that dosent make the %var long since it only need to keep the 6 last channels.. smile


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
Joined: Feb 2003
Posts: 3,432
S
sparta Offline OP
Hoopy frood
OP Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
tested your code, it worked as it should. thnx for the help.. smile


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }

Link Copied to Clipboard