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.

Help with this array

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
d
darton
Op
Posts: 155
Joined: Sat Jan 21, 2006 11:03 am

Help with this array

Post by darton »

Hello!
I need a script which can do the following:
With a command e.g. !mods I want to check the online status of saved nicks. Maybe it is possible to save these nicks in an array(?). Then my eggdrop should write "Online: nick1, nick2, nick3" or "nobody is online".
Last edited by darton on Tue May 30, 2006 9:11 am, edited 1 time in total.
d
darton
Op
Posts: 155
Joined: Sat Jan 21, 2006 11:03 am

Post by darton »

Code: Select all

bind pub - !mods mods
proc mods {nick uhost hand chan arg} {
array set modnames {
 					nick1
 					nick2
 					nick3
}
 foreach {mod} [array get modnames] { 
  if {[onchan $mod $chan]} {    
   putquick "PRIVMSG $chan :The following mods are online at IRC: $mod"   
  }
 }
}
I have already begun with making this script. There is only one problem. With this script I made, the bot writes the following:
The following mods are online at IRC: nick1
The following mods are online at IRC: nick2
But it should write these nicks in just one line like this: "The following mods are online at IRC: nick1, nick2"
What do I have to change so that a new line is not made each time?
And the second problem is that I dont know what I must add that my bot writes "Nobody is online" when there is no user at IRC. Please help me.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Code: Select all

set modnames { 
"nick1"
"nick2" 
"nick3"
}

bind pub - !mods mods 

proc mods {nick uhost hand chan txt} {
  global modnames
  foreach user $modnames { 
    if {![onchan $user $chan]} continue    
    lappend mod($chan) $user
  }
  if {[info exists mod($chan)]} {
    putquick "PRIVMSG $chan :The following mods are online an IRC: $mod($chan)"
    } else {
    putquick "PRIVMSG $chan :Nobody is online"
  }
}
Should do.
Last edited by caesar on Tue May 30, 2006 4:42 pm, edited 1 time in total.
Once the game is over, the king and the pawn go back in the same box.
d
darton
Op
Posts: 155
Joined: Sat Jan 21, 2006 11:03 am

Post by darton »

No, there must be something wrong. My bot writes "The following mods are online on IRC: mod(#channel)".
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Aghh! Forgot an $, sorry. Copy again the code, I've fixed it.
Once the game is over, the king and the pawn go back in the same box.
d
darton
Op
Posts: 155
Joined: Sat Jan 21, 2006 11:03 am

Post by darton »

Thank you very much. Now it works.
Post Reply