This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Userlist script with total counter

Old posts that have not been replied to for several years.
W
Winters
Voice
Posts: 29
Joined: Sat Jul 09, 2005 12:24 pm

Post by Winters »

Yeah now its perfect thx @ all :)
W
Winters
Voice
Posts: 29
Joined: Sat Jul 09, 2005 12:24 pm

Post by Winters »

Hey now I loaded into my eggdrop on root and now he post it 5 times here:
[18:58:03] -Thompson- Users for channel #gfkkg:
[18:58:03] -Thompson- [[GS]Winters Flags: +n ]
[18:58:04] -Thompson- Total: 1 (owner: 1, master: 0, op: 0, voice: 0, ban: 0).
[18:58:06] -Thompson- Total: 1 (owner: 1, master: 0, op: 0, voice: 0, ban: 0).
[18:58:08] -Thompson- Total: 1 (owner: 1, master: 0, op: 0, voice: 0, ban: 0).
[18:58:10] -Thompson- Total: 1 (owner: 1, master: 0, op: 0, voice: 0, ban: 0).
[18:58:12] -Thompson- Total: 1 (owner: 1, master: 0, op: 0, voice: 0, ban: 0).
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

That's because you illogically edited the script, use:

Code: Select all

proc list:users {nick uhost hand chan arg} { 
 putserv "notice $nick :Users for channel $chan:"
 set total(Total) 0
 set total(owner) 0 
 set total(master) 0 
 set total(operator) 0 
 set total(voice) 0 
 set total(ban) 0 
 foreach user [userlist] { 
  incr total(Total) 
  if {[matchattr $user |n $chan]} { 
   lappend users "\{\User: $user Flags: +n\}\ " 
   incr total(owner) 
  } elseif {[matchattr $user |m $chan]} { 
   lappend users "\{\User: $user Flags: +m\}\ ," 
   incr total(master) 
  } elseif {[matchattr $user |o $chan]} { 
   lappend users "\{\User: $user Flags: +o\}\ ," 
   incr total(operator) 
  } elseif {[matchattr $user |v $chan]} { 
   lappend users "\{\User: $user Flags: +v\}\ ," 
   incr total(voice) 
  } elseif {[matchattr $user |k $chan]} { 
   lappend users "\{\User: $user Flags: +k\}\ ," 
   incr total(ban) 
  } 
 } 
 if {[llength $users]} { 
  foreach {u1 u2 u3 u4 u5} $users { 
   putserv "notice $nick :$u1, $u2, $u3, $u4, $u5" 
  } 
 } 
 foreach ann [array names total] { 
  putserv "notice $nick :\[$ann: total($ann)\]"
 } 
}
W
Winters
Voice
Posts: 29
Joined: Sat Jul 09, 2005 12:24 pm

Post by Winters »

Ok thx :)
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

And if you want the totals to be displayed on the same line, then use:

Code: Select all

proc list:users {nick uhost hand chan arg} { 
 putserv "notice $nick :Users for channel $chan:" 
 set total(Total) 0 
 set total(owner) 0 
 set total(master) 0 
 set total(operator) 0 
 set total(voice) 0 
 set total(ban) 0 
 foreach user [userlist] { 
  incr total(Total) 
  if {[matchattr $user |n $chan]} { 
   lappend users "\{User: $user Flags: +n\}" 
   incr total(owner) 
  } elseif {[matchattr $user |m $chan]} { 
   lappend users "\{User: $user Flags: +m\}" 
   incr total(master) 
  } elseif {[matchattr $user |o $chan]} { 
   lappend users "\{User: $user Flags: +o\}" 
   incr total(operator) 
  } elseif {[matchattr $user |v $chan]} { 
   lappend users "\{User: $user Flags: +v\}" 
   incr total(voice) 
  } elseif {[matchattr $user |k $chan]} { 
   lappend users "\{User: $user Flags: +k\}" 
   incr total(ban) 
  } 
 } 
 if {[llength $users]} { 
  foreach {u1 u2 u3 u4 u5} $users { 
   putserv "notice $nick :$u1, $u2, $u3, $u4, $u5" 
  } 
 } 
 foreach ann [array names total] { 
  lappend totals "($ann: total($ann))"
 }
 putserv "notice $nick :$totals"
}
W
Winters
Voice
Posts: 29
Joined: Sat Jul 09, 2005 12:24 pm

Post by Winters »

ehm could you add if there are no users that he answer No users found on my userlist for chan ? :D
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Code: Select all

 if {[llength $users]} { 
  foreach {u1 u2 u3 u4 u5} $users { 
   putserv "notice $nick :$u1, $u2, $u3, $u4, $u5" 
  } 
  foreach ann [array names total] { 
   lappend totals "($ann: total($ann))" 
  } 
  putserv "notice $nick :$totals"
 } {
  putserv "notice $nick :There are no users on me for $chan."
 }
Locked