mIRC Home    About    Download    Register    News    Help

Print Thread
Invite script #202187 17/07/08 08:47 AM
Joined: Feb 2006
Posts: 97
O
ots654685 Offline OP
Babel fish
OP Offline
Babel fish
O
Joined: Feb 2006
Posts: 97
I have moddified an excisting invite script for using ini file.
Code:
alias invite.lchan {
  var %channels = $readini($scriptdir $+ settings.ini,invite,chan)
  if ($1 != begin && $1 != end) return $+($gettok(%channels,$1,44),:,invite.me $+ $chr(32),$gettok(%channels,$1,44)) | return
}

alias invite.me {
  some code
}

alias invite.all {
  var %channels = $readini($scriptdir $+ settings.ini,invite,chan)
  var %num = $numtok(%channels,44) , %lcv = 1
  while (%lcv <= %num) { 
    .timer 1 %lcv invite.me $gettok(%channels,%lcv,44)
    inc %lcv
  }
}

menu * {
  invite
  .All { invite.all $me }
  Single
  ..$submenu($invite.lchan($1))
}

settings.ini
Code:
[invite]
chan=channel1,channel2,channel3,channel4

What i trying to accomplish is splitting it up for different networks.

menu function "..$submenu($invite.lchan($1))" now shows a list with all channels but i would like to have it list it with networks.

wanted menu output
Single
- network1
* channel1
* channel2
- network2
* channel3
- network3
* channel4

ini should look like this then
settings.ini
Code:
[invite]
network1=channel1,channel2
network2=channel3
network3=channel4

Anyone that can help me out or put me on track to make it fit my needs?

Re: Invite script [Re: ots654685] #202201 17/07/08 03:48 PM
Joined: Nov 2006
Posts: 1,559
H
Horstl Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
As you cannot create "nested submenus", it's a bit long winded... You'd have to build some initial "list" in the submenu begin event, and return the items of that list in the main submenu procedure.

In the following example, I used global vars "%invite.item.<N>" for the "list" (unsetting right after the submenu has finished).
Code:
menu channel,status {
  invite me to...
  .$submenu($testinvite.submenu($1))
}

alias -l testinvite.submenu {
  if ($1 == begin) {

    ; set your inifile
    var %inifile = $scriptdir $+ settings.ini

    var %netN = 1, %count = 1

    ; loop the networks = items of ini
    while ($ini(%inifile,invite,%netN)) {
      var %net = $v1, %chanN = 1

      ; put a line to the list containing the network to be some kind of "header"
      set -u $+(%,invite.item.,%count) --- network %net --- : noop
      inc %count

      ; loop the channels of that network = data of ini
      while ($gettok($readini(%inifile,invite,%net),%chanN,44)) {

        ; put a line to the list including the invite command this chan
        set -u $+(%,invite.item.,%count) chan $v1 : invite.me $v1
        inc %chanN
        inc %count
      }
      inc %netN
    }
  }

  ; return the list of items 
  elseif ($($+(%,invite.item.,$1),2)) { return $v1 }

}
...that's the basic idea.
But note that - for the moment - mIRC will NOT know which server connection is associated with this or that net, and will perform the invite command at the CURRENT connection. you may send the network name "%net" as a second parameter to your invite.me alias and perform a loop of scons there...
...or (and I'd prefer it): you could show ONLY channels set for the current network in the invite submenu. This will look like:
Code:
menu channel,status {
  invite me to...
  .$submenu($testinvite.submenu2($1))
}

alias -l testinvite.submenu2 {
  if (($1 isnum) && ($gettok($readini($scriptdir $+ settings.ini,invite,$network),$1,44))) {
    return $v1 : invite.me $v1
  }
}


Last edited by Horstl; 17/07/08 04:11 PM.
Re: Invite script [Re: Horstl] #202247 18/07/08 06:28 PM
Joined: Feb 2006
Posts: 97
O
ots654685 Offline OP
Babel fish
OP Offline
Babel fish
O
Joined: Feb 2006
Posts: 97
Thanks for the detailed explanation Horstl.
This will help me getting it perfect and understand how to use ini files.