|
Joined: Jan 2003
Posts: 22
Ameglian cow
|
OP
Ameglian cow
Joined: Jan 2003
Posts: 22 |
the current code is outputting the data on the file like this: <? $ircnicks = " <b>@AM</b>, <b>@Ark</b>, <b>@Chris</b>, <b>@And_M</b>, "; $mostnicks = "14"; $totalnicks = "14 "; ?> this causes me an php error I need to mak ethis code appears like this to avoid it <? $ircnicks = "<b>@AM</b>,<b>@Ark</b>"; $mostnicks = "14"; $totalnicks = "14 "; ?> here is teh current code
/getnicks { var %x = 1
write -c nicks.php <? $chr(36) $+ ircnicks = "
while (%x <= $nick(#orange,0)) {
if ($nick(#orange,%x) isop #orange) {
write -a nicks.php <b>@ $+ $nick(#orange,%x) $+ </b> $+ , }
elseif ($nick(#orange,%x) ishop #orange) {
write -a nicks.php <b><i> $+ $chr(37) $+ $nick(#orange,%x) $+ </i></b> $+ , }
elseif ($nick(#orange,%x) isvoice #orange) {
write -a nicks.php <i> $+ $chr(43) $+ $nick(#orange,%x) $+ </i> $+ , }
else { write -a nicks.php $nick(#orange,%x) $+ , }
inc %x
}
set %lastnick $read(nicks.php,$lines(nicks.php))
write -d $+ $lines(nicks.php) nicks.php
set %lastnickchars $calc($len(%lastnick) - 1)
set %nocommanick $left(%lastnick,%lastnickchars)
write -a nicks.php %nocommanick
write -a nicks.php " $+ $chr(59)
set %totalnicks $calc($lines(nicks.php) - 2)
if (%record.users == $null) { set %record.users $nick(#orange,0) }
else {
if ($nick(#orange,0) > %record.users) {
set %record.users $nick(#orange,0)
}
}
write -a nicks.php $chr(36) $+ mostnicks = $chr(34) $+ %record.users $+ $chr(34) $+ $chr(59)
write -a nicks.php $chr(36) $+ totalnicks = $chr(34) $+ %totalnicks $chr(34) $+ $chr(59) ?>
Im new to this and any help I could get is appreciated ! Thanks in advance !
|
|
|
|
Joined: Jan 2003
Posts: 94
Babel fish
|
Babel fish
Joined: Jan 2003
Posts: 94 |
For the first part:
/getnicks {
var %x = 1,%f = nicks.php
while (%x <= $nick(#orange,0)) {
var %n = $nick(#orange,%x)
if (%n isop #orange) var %a = %a $+(<b>@,%n,</b>)
elseif (%n ishop #orange) var %b = %b $+(<b><i>,$chr(37),%n,</i></b>)
elseif (%n isvoice #orange) var %c = %c $+(<i>+,%n,</i>)
else var %d = %d %n
inc %x
}
var %abcd = $replace($+(%a,%b,%c,%d),$chr(32),$chr(44)
write -c %f $+(<? $chr(36),ircnicks = ",%abcd)
%abcd will give you all the names with commas seperating them... i couldnt make out the second part.
|
|
|
|
Joined: Jan 2003
Posts: 22
Ameglian cow
|
OP
Ameglian cow
Joined: Jan 2003
Posts: 22 |
thanks a lot
|
|
|
|
Joined: Dec 2002
Posts: 1,321
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 1,321 |
Just a simplification of Sabby's script. Both scripts will run into problems once you get enough people into #orange, though. Variables can only be ~940 characters or so, depending on the length of the variable name (max length: 943), which is why I made it a two-character (% + n) variable name, switching the rest of the variables to follow the minimalist style, but adding explanatory comments at the beginning.
getnicks {
[color:#006600]; %n = nicks list
; %f = filename
; %c = $chan
; %x = loop index[/color]
var %n, %f = nicks.php, %c = #orange, %i = 1
while ($nick(%c, %i).pnick) {
%n = $addtok(%n, $+(<b>,$ifmatch,</b>), 44)
inc %i
}
if ($nick(%c, 0) > %record.users) set %record.users $ifmatch
write -c %f <?
write %f $ $+ ircnicks = $+(",%n,";)
write %f $ $+ mostnicks = $+(",%record.users,";)
write %f $ $+ totalnicks = $+(",%$nick(%c,0),";)
write %f ?>
}
Variable maximum length is 946, including the %, the variable name, a space and the value. You can figure it more easily by subtracting the length of your variable name from 944. Thus, %[color:840017]nick[/color] is 4 characters, and can hold 940 maximum characters. %[color:840017]nicklist.for.channel.#orange[/color] is 28 characters long and can hold 916 characters. You are adding <b></b>, to each nick (8 characters) plus a possible 9th one for the @+% channel prefix. On EFnet, where there is a maximum of 9 characters per nick, you're talking about nick + prefix + <b></b>, = 9 + 1 + 8 = 18, which means that you can hold 52 nicks of maxed length in that variable before you are approaching the overflow point and start getting * /set: line too long. On DALnet, where the maximum length of a nick is 30 characters, you can only hold 24 nicks of maxed length (they won't all be, but the possibility exists that the first 25 nicks in #orange on DALnet might indeed have 30 characters apiece) before you're in danger of overflowing the variable.
DALnet: #HelpDesk and #m[color:#FF0000]IR[color:#EEEE00]C
|
|
|
|
Joined: Jan 2003
Posts: 22
Ameglian cow
|
OP
Ameglian cow
Joined: Jan 2003
Posts: 22 |
Thanks for the code Hammer it works pretty nice !
|
|
|
|
|