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.

ozh addme pickup bot needs small edit (please)

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
t
totalnewb
Voice
Posts: 4
Joined: Tue Mar 24, 2009 7:20 am

ozh addme pickup bot needs small edit (please)

Post by totalnewb »

Hello all,

Im using ozh's addme script http://www.egghelp.org/cgi-bin/tcl_arch ... oad&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: Select all

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.
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

Code: Select all

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
}
t
totalnewb
Voice
Posts: 4
Joined: Tue Mar 24, 2009 7:20 am

Post by totalnewb »

Thanks speechless, very much appreciated. I sent you a PM, please let me know if you are interested.
Post Reply