mIRC Home    About    Download    Register    News    Help

Print Thread
#197660 11/04/08 10:31 PM
I
ix007
ix007
I
For some reason in the 2ndline of the while loop the Variable won't set, I have tried alot of alternatives of this but still no dice. Thanks ahead
Code:
 if ($1 == schedule) {
      if (!$regd) {
        msg $nick Must Register to use this system. Type '.register'
        return 0
      }
      if ($banned) {
        msg $nick Sorry $nick $+ , but you have been banned from using this service. Reason:4,0 $readini(banned.ini,banned,$address($nick,2)) $+ .
        return 0
      }
      elseif (!$2) {
        msg $nick To schedule use this format: .schedule <map> <rcon> <location>
        msg $nick We are in BETA-Testing. Please read our agreement policy before proceeding.
        var %x = 3
        while (%x <= $lines(servlist.ini)) {
          var %servertest = $gettok($read(servlist.ini,%x),1,61)
          if ($readini(servloc.ini,inuse,%servertest)) {
            set %changerble $+(%changerble,$chr(44)) $+($gettok($read(servlist.ini,%x),1,61),(4,1In Use1,0))
            inc %x
          }
          else {
            set %changerble $+(%changerble,$chr(44)) $gettok($read(servlist.ini,%x),1,61)
            inc %x
          }
        }
        msg $nick Current Servers: $gettok($read(servlist.ini,2),1,61) $+ %changerble $+ .
        unset %changerble
      }

#197663 11/04/08 10:56 PM
Joined: Aug 2004
Posts: 7,168
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,168
You should use $readini not $read for an ini file, and $readini requires more parameters than $read.

I see from the 3rd line in your while loop that you are using $readini, so I don't know why you aren't using it in the 2nd line... and other locations in the script.


#197664 11/04/08 10:56 PM
Joined: Sep 2007
Posts: 109
K
Vogon poet
Offline
Vogon poet
K
Joined: Sep 2007
Posts: 109
Ahi ???

Code:
    var %x = 3
    while (%x <= $lines(servlist.ini)) {
      var %servertest = $gettok($read(servlist.ini,%x),1,61)
      if ($readini(servloc.ini,inuse,%servertest)) {
        set %changerble $+(%changerble,$chr(44)) $+($gettok($read(servlist.ini,%x),1,61),(4,1In Use1,0))
        inc %x
      }
      else {
        set %changerble $+(%changerble,$chr(44)) $gettok($read(servlist.ini,%x),1,61)
      }
      inc %x
    }
  }

Last edited by kwell; 11/04/08 11:07 PM.
kwell #197666 11/04/08 11:04 PM
I
ix007
ix007
I
I am trying to grab certain things so I just used a $read, I guess I could have used $readini, but the problem is that it wont set a variable in the 2nd line of the while loop.

#197669 12/04/08 03:02 AM
Joined: Aug 2004
Posts: 7,168
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,168
I'll need to see an example of the line(s) that are in the servlist.ini file to make a better determination. As I said, you should use $readini for ini files, as that's what it's designed for. If your entire script isn't too big, and you'd like some suggestions as to how it could be made better (eg: proper use of the ini file), please post it and I'll be happy to see what I can do to make it better.

kwell #197686 12/04/08 12:16 PM
Joined: Oct 2004
Posts: 8,061
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Oct 2004
Posts: 8,061
Also, rather than adding a comma in there like that, you can use $addtok. It's better suited for that sort of thing.

I
ix007
ix007
I
Alright well the ini setup is like this

Code:
servlist.ini
[servers]
dallas=127.0.0.1


Code:
servloc.ini
[servers]
dallas=person who used it, time date.

#197709 13/04/08 12:06 AM
Joined: Aug 2004
Posts: 7,168
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,168
And with that information, here's my recommendation for a re-write of the section of code that you supplied
Code:
if ($1 == schedule) {
  if (!$regd) {
    msg $nick Must Register to use this system. Type '.register'
    return 0
  }
  if ($banned) {
    msg $nick Sorry $nick $+ , but you have been banned from using this service. Reason:4,0 $readini(banned.ini,banned,$address($nick,2)) $+ .
    return 0
  }
  if (!$4) {
    msg $nick To schedule use this format: .schedule <map> <rcon> <location>
    msg $nick We are in BETA-Testing. Please read our agreement policy before proceeding.
  }
  else {
    var %x = 1, %y = $ini(servlist.ini,0)
    while %x <= %y {
      var %a = 1, %b = $ini(servlist.ini,%x,0)
      while %a <= %b {
        if $readini(servloc.ini,servers,$ini(servlist.ini,%y,%a)) {
          var %inuse = $addtok(%inuse,$ini(servlist.ini,%y,%a),44)        
        }
        var %servers = $addtok(%servers,$ini(servlist.ini,%y,%a),44)
      }
      inc %a
    }
    inc %x
  }
  var %a = 1, %b = $numtok(%inuse,44)
  while %a <= %b {
    var %servers = $reptok(%servers,$gettok(%inuse,%a,44),$+($gettok(%inuse,%a,44),4,1In Use1,0),1,44)
    inc %a
  }
  msg $nick Current Servers: %servers $+ .



Link Copied to Clipboard