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 

ACRO script needs a !stop command

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Support & Releases
View previous topic :: View next topic  
Author Message
cache
Master


Joined: 10 Jan 2006
Posts: 306
Location: Mass

PostPosted: Mon Mar 12, 2007 10:13 am    Post subject: ACRO script needs a !stop command Reply with quote

This is Souperman's acro script and I like for someone to add a command to turn game off please.

Code:
######################################
# Edit these settings to your liking #
######################################

#Channel where game is played.
set acrochan "#chan"

#Command which will start the game.
set acrostartcmd "!acro"

#Minimum number of letters for acros.
set acromin 3

#Maximum number of letters for acros.
set acromax 5

#Letters to select from when generating an acro.
set acroletters "abcdefghijklmnopqrstuvwxyz"

#Number of rounds to play.
set acrorounds 1

#Number of seconds to give players for submitting an acro.
set acrotime 60

#Number of seconds to give players to vote for an acro.
set acrovotetime 60

#Number of seconds between rounds.
set acrogaptime 15

#Text to use in, e.g. "Nobody played the round. Are you guys going to play? :-("
set acrodisgust [list "Pathetic!" "Disgusting!" "Terrible!" "Sheesh!!"]


# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#                                                                   #
#    Any editing done beyond this point is done at your own risk!   #
#                                                                   #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
set acrover "1.0.1"
set acrorel "release"
putlog "Loading acro.tcl $acrover ($acrorel) by Souperman..."
putlog " Visit \037http://www.eggdrop.za.net/\037 for updates and other Tcl scripts."
if {![info exists alltools_loaded]||$allt_version<204} {
 putlog "\002[file tail [info script]]\002 failed to load: please load alltools.tcl v1.6 or higher before attempting to load this script."
 return
}
if {[llength [split $acrochan]]!=1} {
 putlog "\002[file tail [info script]]\002 failed to load: too many channels specified."
 return
}
if {![info exists acroplaying]} {set acroplaying 0}

bind pub -|- $acrostartcmd acrostart

proc acrostart {nick host hand chan text} {
 global acrochan acroplaying acrorounds acroround acroroundscores acrorealnames
 if {[strlwr $acrochan]==[strlwr $chan]} {
  if {$acroplaying==0} {
  putmsg $acrochan "===== ACRO Game started by $nick! ====="
   set acroplaying 1
   set acroround 1
   array unset acroroundscores
   array set acroroundscores {}
   array unset acrorealnames
   array set acrorealnames {}
   acrosel
  }
 }
}

proc acrosel {} {
 global acromin acromax acrochan acrocurrent acroletters acroround acrorounds
 global botnick acrosbynum acrosbyname acrorealnames acronumsbyname acrotime
 global acroroundscores acroplaying acrodisgust acroplayedbyhost acrovotedbyhost
 global acrostartcmd
 if {$acroround>$acrorounds} {
  if {[array size acroroundscores]==0} {
   putmsg $acrochan "Nobody scored any points for this game! [lindex $acrodisgust [rand [llength $acrodisgust]]]"
  } else {
   putmsg $acrochan "Final scores for this game:"
   set _final {}
   set _search [array startsearch acroroundscores]
   while {[set _current [array get acroroundscores [array nextelement acroroundscores $_search]]]!=""} {
    lappend _final "[lindex $_current 1],[lindex $_current 0]"
   }
   foreach _score [lsort -decreasing $_final] {
    putmsg $acrochan "$acrorealnames([lindex [split $_score ,] 1]) [lindex [split $_score ,] 0]"
   }
  }
  putmsg $acrochan "===== Game Over! Type $acrostartcmd to play again. ====="
  set acroplaying 0
 } else {
  set acrocurrent ""
  array unset acrosbynum
  array unset acrosbyname
# array unset acrorealnames
  array unset acronumsbyname
  array unset acronamesbynum
  array unset acroplayedbyhost
  array unset acrovotedbyhost
  array set acrosbynum {}
  array set acrosbyname {}
# array set acrorealnames {}
  array set acronumsbyname {}
  array set acronamesbynum {}
  array set acroplayedbyhost {}
  array set acrovotedbyhost {}
  set _len [expr $acromin+[rand [expr $acromax-[expr $acromin-1]]]]
  set _i 1
  while {$_i<=$_len} {
   append acrocurrent "[string index $acroletters [rand 26]]"
   incr _i
  }
  putmsg $acrochan "Round $acroround/$acrorounds: The ACRO is: \"[strupr $acrocurrent]\"."
  putmsg $acrochan "You have $acrotime seconds! /msg $botnick ACRO <your-phrase>"
  utimer $acrotime acrostartvoting
  bind msg -|- ACRO acrocheck
  incr acroround
 }
}

proc acrocheck {nick host hand text} {
 global acrochan acrosbynum acrosbyname acrorealnames acronumsbyname acrocurrent acronamesbynum
 global acroplayedbyhost
 if {[onchan $nick $acrochan]} {
  if {[info exists acroplayedbyhost([strlwr $host])]} {
   putnotc $nick "You've already played this round."
  } else {
   set _err ""
   if {[llength [split $text]]!=[strlen $acrocurrent]} {
    if {[llength [split $text]]<[strlen $acrocurrent]} {
     set _err "not enough words"
    } else {
     set _err "too many words"
    }
   } else {
    set _i 1
    while {$_i<=[strlen $acrocurrent]} {
     if {[strlwr [stridx $acrocurrent [expr $_i-1]]]==[strlwr [stridx [join [lindex [split $text] [expr $_i-1]]] 0]]} {
      incr _i
     } else {
      set _err "character's mismatched"
      break
     }
    }
   }
   if {$_err!=""} {
    putnotc $nick "There are $_err in your acro. Try again."
   } else {
    set acrosbynum([expr [array size acrosbynum]+1]) $text
    set acrosbyname([strlwr $nick]) $text
    set acrorealnames([strlwr $nick]) $nick
    set acronumsbyname([strlwr $nick]) [array size acrosbynum]
    set acronamesbynum([array size acrosbynum]) [strlwr $nick]
    set acroplayedbyhost([strlwr $host]) 1
    putnotc $nick "You are player #$acronumsbyname([strlwr $nick]) for this round."
   }
  }
 }
}

proc acrostartvoting {} {
 global acrochan acrosbynum botnick acrovotetime acrovotes acrogaptime acrovoted
 global acrodisgust
 unbind msg -|- ACRO acrocheck
 if {[array size acrosbynum]==0} {
  putmsg $acrochan "Time's up! Not a single one of you played that round! [lindex $acrodisgust [rand [llength $acrodisgust]]]"
  utimer $acrogaptime acrosel
 } else {
  putmsg $acrochan "Time's up! Here are the acros:"
  array unset acrovotes
  array set acrovotes {}
  array unset acrovoted
  array set acrovoted {}
  set _i 1
  while {$_i<=[array size acrosbynum]} {
   putmsg $acrochan "$_i. $acrosbynum($_i)"
   set acrovotes($_i) 0
   incr _i
  }
  putmsg $acrochan "Let the voting begin! You have $acrovotetime seconds! /msg $botnick VOTE <number>"
  utimer $acrovotetime acrostopvoting
  bind msg -|- VOTE acrocheckvote
 }
}

proc acrocheckvote {nick host hand text} {
 global acrochan acrosbynum acrovoted acrovotes acrovotedbyhost
 if {[onchan $nick $acrochan]} {
  if {[info exists acrovotedbyhost([strlwr $host])]} {
   putnotc $nick "You've already voted."
  } else {
   set _vote [join [lindex [split $text] 0]]
   if {![string is integer $_vote]||$_vote<1||$_vote>[array size acrosbynum]} {
    putnotc $nick "Invalid vote."
   } else {
    set acrovotes($_vote) [expr $acrovotes($_vote)+1]
    set acrovoted([strlwr $nick]) 1
    set acrovotedbyhost([strlwr $host]) 1
    putnotc $nick "Your vote has been counted."
   }
  }
 }
}

proc acrostopvoting {} {
 global acrochan acrogaptime acrovoted acroroundscores acrosbynum acros acronamesbynum
 global acrorealnames acrovotes acrodisgust
 unbind msg -|- VOTE acrocheckvote
 if {[array size acrovoted]==0} {
  putmsg $acrochan "Time's up! Not a single one of you voted! [lindex $acrodisgust [rand [llength $acrodisgust]]]"
  utimer $acrogaptime acrosel
 } else {
  putmsg $acrochan "Time's up! Here are the scores for this round:"
  set _i 1
  while {$_i<=[array size acrosbynum]} {
   putmsg $acrochan "$_i. $acrorealnames($acronamesbynum($_i)) $acrovotes($_i)"
   if {[info exists acroroundscores($acronamesbynum($_i))]} {
    set acroroundscores($acronamesbynum($_i)) [expr $acroroundscores($acronamesbynum($_i))+$acrovotes($_i)]
   } else {
    set acroroundscores($acronamesbynum($_i)) $acrovotes($_i)
   }
   incr _i
  }
  utimer $acrogaptime acrosel
 }
}

putlog "Successfully loaded acro.tcl $acrover!"
Back to top
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Mon Mar 12, 2007 6:00 pm    Post subject: Reply with quote

Try adding:
Code:
bind pub n|n !stopacro {acrostopvoting;#}

_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
cache
Master


Joined: 10 Jan 2006
Posts: 306
Location: Mass

PostPosted: Mon Mar 12, 2007 6:25 pm    Post subject: Reply with quote

I put it under start bind like...
bind pub -|- $acrostartcmd acrostart
bind pub -|- !stopacro {acrostopvoting;#}

Got this error:
Code:
[18:19] Tcl error [acrostopvoting;#]: no such binding


Code:
[18:23] Tcl error in script for 'timer904':
[18:23] no such binding
Back to top
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Mon Mar 12, 2007 6:43 pm    Post subject: Reply with quote

That error probably occurs when the proc tries to [unbind msg -|- VOTE acrocheckvote]; that was one proposed solution... I suggest contacting the author unless someone would like to go through the whole code and figure this one out for you Wink
_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
cache
Master


Joined: 10 Jan 2006
Posts: 306
Location: Mass

PostPosted: Mon Mar 12, 2007 7:14 pm    Post subject: Reply with quote

I like how that one runs but I'll just switch to be_acro since 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 Support & Releases 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