mIRC Home    About    Download    Register    News    Help

Print Thread
#106068 23/12/04 11:20 PM
S
Stranger_Lv
Stranger_Lv
S
hi all, I have next trouble,
that is, i have in my script:
Code:
    var %chansOn $numtok($hget(onchans,$2),2)
    while (%chansOn > 0) {
    echo -s cur channel number: %chansOn
    echo -s channels user are on: $hget(onchans,$2) 
    echo -s current chan: $gettok($hget(onchans,$2),%chansOn,2)


    var %cur_chan $gettok($hget(onchans,$2),%chansOn,2)


    var %usersONchan $numtok($hget(chanusers,%cur_chan),58)
    while (%usersONchan > 0) {
      if ($gettok($hget(chanusers,%cur_chan),%usersONchan,58) != $2) { sockwrite -n $gettok($hget(chanusers,%cur_chan),%usersONchan,58) : $+ $1 NICK : $+ $2 }
      dec %usersONchan 1
    }
    dec %chansOn 1
  }

it is piece of a code from my irc server based on mirc script, i think it`s difficult to understand so i`ll explain what means each row:
Code:
 
;this performs the operation of nickchange (announces to all channels which user are on of nickchange)
;$1 nickname
;$2 new_nickname

  var %chansOn $numtok($hget(onchans,$2),2)
;sets variable to a number of channels user are on

  while (%chansOn > 0) {

;;;;;;;;this doesn`t return any error;;;;;;;;;;;
    echo -s cur channel number: %chansOn 
    echo -s channels user are on: $hget(onchans,$2) ;full list of a channels in format #chan1<$chr(2)>#chan2<$chr(2)>...
    echo -s current chan: $gettok($hget(onchans,$2),%chansOn,2) ;current channel name
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

    var %cur_chan $gettok($hget(onchans,$2),%chansOn,2)
;;;;;must set the channel name but returns error.;;;;;;

    var %usersONchan $numtok($hget(chanusers,%cur_chan),58)
;number of total users in a channel

    while (%usersONchan > 0) {
      if ($gettok($hget(chanusers,%cur_chan),%usersONchan,58) != $2)
;if that isn`t same user who change nick
{ sockwrite -n $gettok($hget(chanusers,%cur_chan),%usersONchan,58) : $+ $1 NICK : $+ $2
;tell him about nickchange
 }
      dec %usersONchan 1
;set next user`s number to tell about n\c
    }
    dec %chansOn 1
;switches to the next channel
  }
 


problem is that the
var %cur_chan $gettok($hget(onchans,$2),%chansOn,2)
;;;;;must set the channel name but returns error.;;;;;;
but one row higher 'echo' with the same code works properly.
Any ideas?

#106069 23/12/04 11:24 PM
Joined: Dec 2002
Posts: 2,884
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,884
I didn't read the script throroughly, but one thing that stood out as likely to be the source of bugs is that you're using the incorrect format for the var command. You should be using var %variable = value, the = is important to prevent errors in many situations.

#106070 23/12/04 11:40 PM
S
Stranger_Lv
Stranger_Lv
S
You're a genius!
I got tired reading this and searching for errors, but it was in spelling blush
Thank you very much!


Link Copied to Clipboard