|
Joined: Jan 2008
Posts: 22
Ameglian cow
|
OP
Ameglian cow
Joined: Jan 2008
Posts: 22 |
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 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
}
|
|
|
|
Joined: Aug 2004
Posts: 7,252
Hoopy frood
|
Hoopy frood
Joined: Aug 2004
Posts: 7,252 |
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.
|
|
|
|
Joined: Sep 2007
Posts: 109
Vogon poet
|
Vogon poet
Joined: Sep 2007
Posts: 109 |
Ahi ??? 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.
|
|
|
|
Joined: Jan 2008
Posts: 22
Ameglian cow
|
OP
Ameglian cow
Joined: Jan 2008
Posts: 22 |
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.
|
|
|
|
Joined: Aug 2004
Posts: 7,252
Hoopy frood
|
Hoopy frood
Joined: Aug 2004
Posts: 7,252 |
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.
|
|
|
|
Joined: Oct 2004
Posts: 8,330
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,330 |
Also, rather than adding a comma in there like that, you can use $addtok. It's better suited for that sort of thing.
Invision Support #Invision on irc.irchighway.net
|
|
|
|
Joined: Jan 2008
Posts: 22
Ameglian cow
|
OP
Ameglian cow
Joined: Jan 2008
Posts: 22 |
Alright well the ini setup is like this servlist.ini
[servers]
dallas=127.0.0.1
servloc.ini
[servers]
dallas=person who used it, time date.
|
|
|
|
Joined: Aug 2004
Posts: 7,252
Hoopy frood
|
Hoopy frood
Joined: Aug 2004
Posts: 7,252 |
And with that information, here's my recommendation for a re-write of the section of code that you supplied 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 $+ .
|
|
|
|
|