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 

ozh addme pickup bot needs small edit (please)

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


Joined: 24 Mar 2009
Posts: 4

PostPosted: Tue Mar 24, 2009 9:12 am    Post subject: ozh addme pickup bot needs small edit (please) Reply with quote

Hello all,

Im using ozh's addme script http://www.egghelp.org/cgi-bin/tcl_archive.tcl?mode=download&id=823 and i pretty much love how it works except for one thing. The game community is used to random teams. Could someone fix this so it randomly picks 8 people (without repeating the people)

i tried
Code:
proc addme_2leaders {chan} {
# Internal proc (no output printed) selecting 2 leaders from topic list, if supposed to do so

   global addme_list
   global addme_leaders
   global addme_pick2players

   if {$addme_pick2players($chan) == 0} {
      set addme_leaders($chan) " "
      return 2leaders:no_leader_picking
   }
   
  set nicklist [split $addme_list($chan) "/"]
  set pif1 [rand [llength $nicklist]]
  set pif2 [rand [llength $nicklist]]
  set pif3 [rand [llength $nicklist]]
  set pif4 [rand [llength $nicklist]]
  set pif5 [rand [llength $nicklist]]
  set pif6 [rand [llength $nicklist]]
  set pif7 [rand [llength $nicklist]]
  set pif8 [rand [llength $nicklist]]
  while {$pif1 == $pif8} {set pif8 [rand [llength $nicklist]]}
  set leader1 [lindex $nicklist $pif1]
  set leader2 [lindex $nicklist $pif2]
  set leader3 [lindex $nicklist $pif3]
  set leader4 [lindex $nicklist $pif4]
  set leader5 [lindex $nicklist $pif5]
  set leader6 [lindex $nicklist $pif6]
  set leader7 [lindex $nicklist $pif7]
  set leader7 [lindex $nicklist $pif8]
  set addme_leaders($chan) "(Human: $leader1 $leader2 $leader3 $leader4 Infected: $leader5 $leader6 $leader7 $leader8)"
}


Unfortunately that dont work as the scripts picks the same name more than once instead of using all 8 names it generates in the topic. If someone could give me a fix i would love you for life. Thank you very much in advance.
Back to top
View user's profile Send private message
speechles
Revered One


Joined: 26 Aug 2006
Posts: 1398
Location: emerald triangle, california (coastal redwoods)

PostPosted: Wed Mar 25, 2009 6:11 pm    Post subject: Reply with quote

Code:
proc addme_2leaders {chan} {
# Internal proc (no output printed) selecting 2 leaders from topic list, if supposed to do so

   global addme_list
   global addme_leaders
   global addme_pick2players

   if {$addme_pick2players($chan) == 0} {
      set addme_leaders($chan) " "
      return 2leaders:no_leader_picking
   }
   
  set ::add_nicklist [split $addme_list($chan) "/"]
  set leader1 [giveAnick $::add_nicklist]
  set leader2 [giveAnick $::add_nicklist]
  set leader3 [giveAnick $::add_nicklist]
  set leader4 [giveAnick $::add_nicklist]
  set leader5 [giveAnick $::add_nicklist]
  set leader6 [giveAnick $::add_nicklist]
  set leader7 [giveAnick $::add_nicklist]
  set leader8 [giveAnick $::add_nicklist]
  set addme_leaders($chan) "(Human: $leader1 $leader2 $leader3 $leader4 Infected: $leader5 $leader6 $leader7 $leader8)"
}

############################################
# add this proc somewhere in the script
# this will randomly pick a nickname, and remove it from
# the list so two nicknames can never be the same
proc giveAnick {nicks} {
  set name [lindex $nicks [set nick [rand [llength $nicks]]]]
  set ::add_nicklist [lreplace $nicks $nick $nick]
  return $name
}

_________________
speechles' eggdrop tcl archive
Back to top
View user's profile Send private message
totalnewb
Voice


Joined: 24 Mar 2009
Posts: 4

PostPosted: Thu Mar 26, 2009 2:50 pm    Post subject: Reply with quote

Thanks speechless, very much appreciated. I sent you a PM, please let me know if you are interested.
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