omgword script

Paste Your code(s) here, and state your problem.

omgword script

Postby jonlar » Mon Jan 12, 2009 1:42 am

Hi there. I have a very old omgword script here and its not working well.
After finishing a word, JUST the first time it counts doubled.
Outputs a omgword - User solves it
and the bot output looks like that

OMG-Word: <OMGWORD> wurde von USER1 richtig erraten. USER hat 1 Punkte
OMG-Word: <OMGWORD> wurde von USER1 richtig erraten. USER1 hat 2 Punkte

Means OMG-Word: <OMGWORD> has been solved by USER1 . USER 1 got 1/2 Points

The TCL error is Tcl error [omgfertig]: invalid timerID

and this is the Script
#############
### Binds ###
#############

bind PUB -|- .omg omgword


set count "0"
set omgwoerter "scripts/priv/db/omg.txt"

#################
### FloodProt ###
#################

proc noflood { type channel } {
if {[string equal -nocase "check" $type]} {
if {[info exists ::noflood($channel)] && [expr [unixtime] - $::noflood($channel)] < 30} {
return 1
}
return 0
} elseif {[string equal -nocase "set" $type]} {
set ::noflood($channel) [unixtime]
}
}

#############
### Procs ###
#############

####################
### UmdrehenProc ###
####################

proc umdrehen { wort } {
set wort2 "[string toupper [lindex [split $wort ""] 0]][join [lrange [split $wort ""] 1 end] ""]"
set n $wort2
while { $wort2 == $n } {
set n ""
foreach b [split $wort2 ""] { if { [rand 2] != "1" } { set n "$n$b" } { set n "$b$n" } }
}
return $n
}

############
### Main ###
############

proc omgword { nick host hand chan args } {
global count
if {[noflood check $chan]} {
putquick "NOTICE $nick : Mit flooden kannst du nix bezwingen!"
return
}
set ::norm(wort) [lindex [set fileList [split [read [set fs [open "$::omgwoerter" r]]] \n]] [rand [llength $fileList]]][close $fs]
set count [expr $count + 1]
putquick "PRIVMSG $chan :\002OMG-Word\002: nr: \002$count\002 Okay dann fangt mal an zu raten, wir suchen: \037[umdrehen $::norm(wort)]\037, ihr habt 30s Zeit."
bind pubm - "$chan $::norm(wort)" omgfertig
set ::timer [utimer 30 [list putquick "PRIVMSG $chan :\002OMG-Word\002: nr: \002$count\002 Leider hat keiner das Wort erraten, wir haben \037$::norm(wort)\037 gesucht."]]
set ::timermoney [utimer 29 [list unbind pubm - "$chan $::norm(wort)" omgfertig]]

noflood set $chan
}

##################
### OMG-Fertig ###
##################

proc omgfertig {nick host hand chan arg} {
global counter
if {![info exists counter($nick)]} {
set counter($nick) 1
putquick "PRIVMSG $chan : \002OMG-Word\002: \037$::norm(wort)\037 wurde von \002$nick\002 richtig erraten. $nick hat $counter($nick) Punkte"
killutimer $::timer
killutimer $::timermoney
unbind pubm - "$chan $::norm(wort)" omgfertig
}
if {[info exists counter($nick)]} {
set counter($nick) [expr $counter($nick) +1]
global counter($nick)
putquick "PRIVMSG $chan : \002OMG-Word\002: \037$::norm(wort)\037 wurde von \002$nick\002 richtig erraten. $nick hat $counter($nick) Punkte"
killutimer $::timer
killutimer $::timermoney
unbind pubm - "$chan $::norm(wort)" omgfertig
}
}


Thanks for helping me ;)

Ahhh btw. maybe somebody has a better omgword script. Thx in advance
jonlar
 

Re: omgword script

Postby Cristian » Sat Jan 24, 2009 4:00 pm

just giving you some hope, I will take a look at it, no promises given.
Cristian
proof of advance
proof of advance
 
Posts: 282
Joined: Sun Nov 04, 2007 3:02 pm
Location: Denmark
Authnick: Sumsar

Re: omgword script

Postby Cristian » Sat Jan 24, 2009 5:58 pm

well, I do not get any errors, the script works on eggdrop1.6.19

perhaps another script is interfering with this one :|
Cristian
proof of advance
proof of advance
 
Posts: 282
Joined: Sun Nov 04, 2007 3:02 pm
Location: Denmark
Authnick: Sumsar

Re: omgword script

Postby jonlar » Sun Jan 25, 2009 6:31 pm

Hmm tried everything. still have the error.
jonlar
 

Re: omgword script

Postby r0t3n » Wed Jan 28, 2009 7:06 pm

Replace the 'omgfertig' proc with:

Code: Select all
proc omgfertig {nick host hand chan arg} {
global counter
if {![info exists counter($nick)]} {
set counter($nick) 1
putquick "PRIVMSG $chan : \002OMG-Word\002: \037$::norm(wort)\037 wurde von \002$nick\002 richtig erraten. $nick hat $counter($nick) Punkte"
catch {killutimer $::timer}
catch {killutimer $::timermoney}
unbind pubm - "$chan $::norm(wort)" omgfertig
}
if {[info exists counter($nick)]} {
set counter($nick) [expr $counter($nick) +1]
global counter($nick)
putquick "PRIVMSG $chan : \002OMG-Word\002: \037$::norm(wort)\037 wurde von \002$nick\002 richtig erraten. $nick hat $counter($nick) Punkte"
catch {killutimer $::timer}
catch {killutimer $::timermoney}
unbind pubm - "$chan $::norm(wort)" omgfertig
}
}
r0t3n
 

Re: omgword script

Postby jonlar » Fri Jan 30, 2009 12:23 pm

Thank you ;)
jonlar
 


Return to TCL Scripting Help

Who is online

Users browsing this forum: No registered users and 0 guests

cron