egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Help with this array

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
darton
Op


Joined: 21 Jan 2006
Posts: 155

PostPosted: Mon May 29, 2006 6:40 am    Post subject: Help with this array Reply with quote

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
Back to top
View user's profile Send private message
darton
Op


Joined: 21 Jan 2006
Posts: 155

PostPosted: Mon May 29, 2006 3:22 pm    Post subject: Reply with quote

Code:
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:
Quote:
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.
Back to top
View user's profile Send private message
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Tue May 30, 2006 12:14 pm    Post subject: Reply with quote

Code:

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.
_________________
Once the game is over, the king and the pawn go back in the same box.


Last edited by caesar on Tue May 30, 2006 4:42 pm; edited 1 time in total
Back to top
View user's profile Send private message
darton
Op


Joined: 21 Jan 2006
Posts: 155

PostPosted: Tue May 30, 2006 4:34 pm    Post subject: Reply with quote

No, there must be something wrong. My bot writes "The following mods are online on IRC: mod(#channel)".
Back to top
View user's profile Send private message
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Tue May 30, 2006 4:41 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
darton
Op


Joined: 21 Jan 2006
Posts: 155

PostPosted: Wed May 31, 2006 11:30 am    Post subject: Reply with quote

Thank you very much. Now it works.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber