CLubber | 24 Şubat 2012 22:30 | Cevap: Yardim lütfen PHP- Kodu: set tgqdb "scripts/kelime.txt" set tgscf "scripts/kelimepuan.txt" set tgerrfil "scripts/kelimehata.txt" set tgchan "#kelime" set tgpointsperanswer 15 set tgmaxhint 1 set tgstreakmin 3 set tgmaxmissed 0 set tghintchar "*" set tgtimehint 20 set tgtimenext 10 set tgcongrats[list "Harikasin" "Soruyu Bildin"] set tgnobodygotit[list ".."] set tgtrythenextone[list ".."] set tgshowanswer 1 set tgpriv2msg 1 set tgcmdhelp "?" set tgcmdstart "basla" set tgflagsstart -|- set tgcmdstop "!dur" set tgflagsstop -|- set tgcmdhint "ipucu" set tgflagshint -|- set tgcmdskip "atlkllka" set tgflagsskip -|- set tgcmdreset "resklklet" set tgflagsreset -|- set tgcmdlookup "skor" set tgcmdtarget "hedef" set tgcmderror "hata" set tgcmdrules "kural" set tgrules "Kanal Kuralımız : Size Yapılmasını İstemediğiniz Davranışı Başkasına Yapmamanız...!" set tgerrremindtime 5 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # Burdan Sonrasini Degismeniz Riske Sebeb Olur :):): # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #Misc checks & var initialisations if {![file exists $tgqdb]} { putlog "\002[file tail [info script]]\002 failed to load: $tgqdb does not exist." return } 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 use this script." return } if {[llength [split $tgchan]]!=1} { putlog "\002[file tail [info script]]\002 failed to load: too many channels specified." return } if {![info exists tgplaying]} {set tgplaying 0} if {![info exists tghintnum]} {set tghintnum 0} if {![info exists tgmissed]} {set tgmissed 0} #Binds bind pub $tgflagsstart $tgcmdstart tgstart bind pub $tgflagsstop $tgcmdstop tgstop bind pub $tgflagshint $tgcmdhint tgforcehint bind pub $tgflagsskip $tgcmdskip tgskip bind join -|- "$tgchan *" tgjoinmsg bind msg - $tgcmdhelp tggivehelp bind msg - $tgcmdlookup tgscorelookup bind msg - $tgcmdtarget tgtargetlookup bind msg - $tgcmderror tgerror bind msg - $tgcmdrules tgrulesmsg bind msg $tgflagsreset "$tgcmdreset" tgresetscores bind kick - "$tgchan $botnick" tgbotgotkicked bind evnt - disconnect-server tgbotgotdisconnected #starts the game if it isn't running. proc tgstart {nick host hand chan text} { global tgplaying tgstreak tgchan tgerrremindtime tgerrremindtimer tgmissed if {[strlwr $tgchan]==[strlwr $chan]} { if {$tgplaying==0} { tggamemsg "4Kelime Oyun'u Baslatildi!.." tgnext set tgplaying 1 set tgstreak 0 set tgmissed 0 set tgerrremindtimer [timer $tgerrremindtime tgerrremind] } return 1 } } #stops the game if it's running. proc tgstop {nick host hand chan text} { global tghinttimer tgnexttimer tgplaying tgchan tgcurrentanswer tgstreak tgstreakmin global tgerrremindtimer if {[strlwr $tgchan]==[strlwr $chan]} { if {$tgplaying==1} { tggamemsg "Oyunu Durduran $nick!" if {$tgstreakmin>0&&[lindex [split $tgstreak ,] 1]>=$tgstreakmin} { tgstreakend } set tgstreak 0 set tgplaying 0 catch {unbind pubm -|- "$tgchan $tgcurrentanswer" tgcorrectanswer} if {[utimerexists tghint]!=""} {killutimer $tghinttimer} if {[utimerexists tgnext]!=""} {killutimer $tgnexttimer} if {[timerexists tgerrremind]!=""} {killtimer $tgerrremindtimer} } return 1 } } #gives a hint if there is currently a question to answer. proc tgforcehint {nick host hand chan text} { global tghinttimer tgnexttimer tgplaying tgchan tgcurrentanswer tgstreak tgstreakmin global tgtempnohint tghintmax tghintnum if {[strlwr $tgchan]==[strlwr $chan]} { if {$tgplaying==1&&[utimerexists tghint]!=""} { killutimer $tghinttimer tghint } return 1 } } #skips the current question if one has been asked. proc tgskip {nick host hand chan text} { global tghinttimer tgnexttimer tgplaying tgchan tgcurrentanswer tgstreak tgstreakmin tgtimenext if {[strlwr $tgchan]==[strlwr $chan]} { if {$tgplaying==1&&[utimerexists tghint]!=""} { tggamemsg "4Soru 2$nick Tarafından Direkt Olarak Geçildi!" if {$tgstreakmin>0&&[lindex [split $tgstreak ,] 1]>=$tgstreakmin} { tgstreakend } set tgstreak 0 unbind pubm -|- "$tgchan $tgcurrentanswer" tgcorrectanswer killutimer $tghinttimer set tgnexttimer [utimer $tgtimenext tgnext] } return 1 } } #reminds channel how to report errors in questions/answers proc tgerrremind {} { global tgerrremindtimer tgerrremindtime botnick tgcmderror tggamemsg "Unutmayın!: Kelimelerdeki Hataları Bize Bildirmek İçin, Lütfen 4#Operhelp Kanalındaki Yetkililerle İrtibata Geçin" set tgerrremindtimer [timer $tgerrremindtime tgerrremind] } #bot got kicked. stop the game. proc tgbotgotkicked {nick host hand chan targ text} { tgquietstop } #bot got disconnected. stop the game. proc tgbotgotdisconnected {disconnect-server} { tgquietstop } #stops the game without telling the channel. proc tgquietstop {} { global tgplaying tgstreak tgchan tgcurrentanswer tghinttimer tgnexttimer tgerrremindtimer if {$tgplaying==1} { set tgstreak 0 set tgplaying 0 catch {unbind pubm -|- "$tgchan $tgcurrentanswer" tgcorrectanswer} if {[utimerexists tghint]!=""} {killutimer $tghinttimer} if {[utimerexists tgnext]!=""} {killutimer $tgnexttimer} if {[timerexists tgerrremind]!=""} {killtimer $tgerrremindtimer} } } #reads the question database. proc tgreadqdb {} { global tgqdb tgquestionstotal tgquestionslist set tgquestionstotal 0 set tgquestionslist "" set qfile [open $tgqdb r] while {![eof $qfile]} { lappend tgquestionslist [gets $qfile] incr tgquestionstotal } close $qfile } #selects the next question. proc tgnext {} { global tgqdb tgcurrentquestion tgcurrentanswer tgquestionnumber tgquestionstotal global tghintnum tgchan tgquestionslist tgreadqdb set tgquestionnumber [rand [llength $tgquestionslist]] set tgquestionselected [lindex $tgquestionslist $tgquestionnumber] set tgcurrentquestion [lindex [split $tgquestionselected |] 1] set tgcurrentanswer [strlwr [lindex [split $tgquestionselected |] 0]] unset tghintnum tghint bind pubm -|- "$tgchan $tgcurrentanswer" tgcorrectanswer return } #shows timed hints. proc tghint {} { global tgmaxhint tghintnum tgcurrentanswer tghinttimer tgchan global tgtimehint tghintchar tgquestionnumber tgquestionstotal global tgcurrentquestion tghintcharsused tgnexttimer tgtimenext tgstreak tgstreakmin global tgnobodygotit tgtrythenextone tgmissed tgmaxmissed tgcmdstart tgshowanswer global tgtimestart if {[catch {incr tghintnum}]!=0} {set tghintnum 0} if {$tghintnum >= [expr $tgmaxhint+1]} { incr tgmissed set _msg "" append _msg "0,6Zaman Doldu!0,7 Bir Sonraki Kelime İçin Hazırlanın" if {$tgmaxmissed>0&&$tgmissed>=$tgmaxmissed} { append _msg " 0,6Kelime Çözmeye Niyetiniz Yoksa Dinleniyim Biraz :)!" } else { append _msg " [lindex $tgtrythenextone [rand [llength $tgtrythenextone]]]" } tggamemsg "$_msg" if {$tgstreakmin>0&&[lindex [split $tgstreak ,] 1]>=$tgstreakmin} { tgstreakend } set tgstreak 0 catch {unbind pubm -|- "$tgchan $tgcurrentanswer" tgcorrectanswer} if {$tgmaxmissed==0||$tgmissed<$tgmaxmissed} { set tgnexttimer [utimer $tgtimenext tgnext] } return } elseif {$tghintnum == 0} { set i 0 set _hint {} set tghintcharsused {} regsub -all -- "\[A-Za-z0-9\]" $tgcurrentanswer $tghintchar _hint set tgtimestart [clock clicks -milliseconds] } elseif {$tghintnum == 1} { set i 0 set _hint {} while {$i<[llength [split $tgcurrentanswer]]} { set _word [lindex [split $tgcurrentanswer] $i] set j 0 set _newword {} while {$j<[strlen $_word]} { if {$j==0} { append _newword [stridx $_word $j] lappend tghintcharsused $i,$j } else { if {[string is alnum [stridx $_word $j]]} { append _newword $tghintchar } else { append _newword [stridx $_word $j] lappend tghintcharsused $i,$j } } incr j } lappend _hint $_newword incr i } } else { set i 0 set _hint {} while {$i<[llength [split $tgcurrentanswer]]} { set _word [lindex [split $tgcurrentanswer] $i] set j 0 set _newword {} set _selected [rand [strlen $_word]] regsub -all -- "\[^A-Za-z0-9\]" $_word "" _wordalnum if {[strlen $_wordalnum]>=$tghintnum} { while {[lsearch $tghintcharsused $i,$_selected]!=-1||[string is alnum [stridx $_word $_selected]]==0} { set _selected [rand [strlen $_word]] } } lappend tghintcharsused $i,$_selected while {$j<[strlen $_word]} { if {[lsearch $tghintcharsused $i,$j]!=-1||[string is alnum [stridx $_word $j]]==0} { append _newword [stridx $_word $j] } else { if {[string is alnum [stridx $_word $j]]} { append _newword $tghintchar } } incr j } lappend _hint $_newword incr i } } tggamemsg "xx-x-13x-x-x--x-x-4x-x-4-x--12x-x-x-x-7x-x-x-x-x-x->" tggamemsg "2İşte Kelimeniz Düzenleyin: 3 [strupr $tgcurrentquestion] " tggamemsg "5(5Bu Harflerin Hepsinin Oldugu Bir Kelime Bulun5)" tggamemsg "xx-x-13x-x-x--x-x-4x-x-4-x--12x-x-x-x-7x-x-x-x-x-x->" set tghinttimer [utimer $tgtimehint tghint] } #triggered when someone says the correct answer. proc tgcorrectanswer {nick host hand chan text} { global tgcurrentanswer tghinttimer tgtimenext tgchan tgnexttimer tgstreak tgstreakmin global tgscoresbyname tgranksbyname tgranksbynum tgcongrats tgscorestotal tgmissed global tgtimestart tggetscores if {![info exists tgranksbyname([strlwr $nick])]} { set _oldrank 0 } else { set _oldrank [lindex [split $tgranksbyname([strlwr $nick]) ,] 0] } tgincrscore $nick tggetscores set _newrank [lindex [split $tgranksbyname([strlwr $nick]) ,] 0] set _timetoanswer [expr [expr [clock clicks -milliseconds]-$tgtimestart]/1000.00] set _msg "5Tebrikler6 $nick 5Doğru Cevap 6 [strupr $tgcurrentanswer] 0415 Puan Kazandınız." if {$_newrank<$_oldrank} { if {$_newrank==1} { append _msg " Tebrikler " } else { append _msg "" } } tggamemsg "$_msg" if {$tgstreak!=0} { if {[lindex [split $tgstreak ,] 0]==[strlwr $nick]} { set tgstreak [strlwr $nick],[expr [lindex [split $tgstreak ,] 1]+1] if {$tgstreakmin>0&&[lindex [split $tgstreak ,] 1]>=$tgstreakmin} { tggamemsg "4Bravo 2$nick 4Kelimeyi Ard Arda Siz Bildiniz! Diğerleriyle Aranızda Fark Oluşmaya Başladı!" } } else { if {$tgstreakmin>0&&[lindex [split $tgstreak ,] 1]>=$tgstreakmin} { tgstreakend } set tgstreak [strlwr $nick],1 } } else { set tgstreak [strlwr $nick],1 } set tgmissed 0 tgshowscores unbind pubm -|- "$tgchan $tgcurrentanswer" tgcorrectanswer killutimer $tghinttimer set tgnexttimer [utimer $tgtimenext tgnext] return 1 } #read current scores from file, sort and store in variable. proc tggetscores {} { global tgscf tgscorestotal tgscores tgscoresbyname tgranksbyname tgranksbynum tgrealnames if {[file exists $tgscf]&&[file size $tgscf]>2} { set _sfile [open $tgscf r] set tgscores [lsort -dict -decreasing [split [gets $_sfile]]] close $_sfile set tgscorestotal [llength $tgscores] } else { set tgscores "" set tgscorestotal 0 } if {[info exists tgscoresbyname]} {unset tgscoresbyname} if {[info exists tgranksbyname]} {unset tgranksbyname} if {[info exists tgrealnames]} {unset tgrealnames} if {[info exists tgranksbynum]} {unset tgranksbynum} set i 0 while {$i<[llength $tgscores]} { set _item [lindex $tgscores $i] set _nick [lindex [split $_item ,] 2] set _lwrnick [lindex [split $_item ,] 3] set _score [lindex [split $_item ,] 0] set tgscoresbyname($_lwrnick) $_score set tgrealnames($_lwrnick) $_nick set tgranksbyname($_lwrnick) [expr $i+1],$_score set tgranksbynum([expr $i+1]) $_lwrnick,$_score incr i } return } #increment someone's score. proc tgincrscore {who} { global tgscores tgscf tgpointsperanswer tgscorestotal tgscoresbyname tggetscores if {$tgscorestotal>0} { set i 0 if {![info exists tgscoresbyname([strlwr $who])]} { append _newscores "1,[expr 1000000000000.0/[unixtime]],$who,[strlwr $who] " } while {$i<[llength $tgscores]} { set _item [lindex $tgscores $i] set _nick [lindex [split $_item ,] 2] set _time [lindex [split $_item ,] 1] set _score [lindex [split $_item ,] 0] if {[strlwr $who]==[strlwr $_nick]} { append _newscores "[expr $_score+$tgpointsperanswer],[expr 1000000000000.0/[unixtime]],$who,[strlwr $who][expr [expr [llength $tgscores]-$i]==1?"":"\ "]" } else { append _newscores "$_score,$_time,$_nick,[strlwr $_nick][expr [expr [llength $tgscores]-$i]==1?"":"\ "]" } incr i } } else { append _newscores "1,[expr 1000000000000.0/[unixtime]],$who,[strlwr $who]" } set _sfile [open $tgscf w] puts $_sfile "$_newscores" close $_sfile return } #shows the current scores on channel. proc tgshowscores {} { global tgscores tgchan tgscorestotal tggetscores set i 0 while {$i<[llength $tgscores]} { set _item [lindex $tgscores $i] set _nick [lindex [split $_item ,] 2] set _score [lindex [split $_item ,] 0] if {$i==0} { append _scores "2$_nick $_score" } elseif {$i==1} { append _scores ", 12$_nick $_score" } elseif {$i==2} { append _scores ", 4$_nick $_score" } elseif {[onchan $_nick $tgchan]} { append _scores ",4$_nick $_score" } incr i } tggamemsg "5Sonuclar: $_scores" } #reset current scores. proc tgresetscores {nick host hand text} { global tgscf tgscorestotal tgscores if {[file exists $tgscf]&&[file size $tgscf]>2} { set _sfile [open $tgscf w] puts $_sfile "" close $_sfile set tgscores "" set tgscorestotal 0 } tggamemsg "4===== Skor Tablosu $nick! Tarafından Resetlendi =====" return 1 } #triggered when a winning streak ends. proc tgstreakend {} { global tgstreak tgrealnames tggamemsg "4Bravo $tgrealnames([lindex [split $tgstreak ,] 0]) Çok Fazla Strike ye Sahipsiniz... Tebrikler!" return } #triggered when someone joins trivia chan. proc tgjoinmsg {nick host hand chan} { global botnick tgplaying tgcmdhelp tgcmdstart tgflagsstart tgcmdstop tgflagsstop tgchan if {$nick != $botnick} { set _msg "" append _msg "Welcome to $botnick's Trivia Channel. Trivia Oyunu Şuanda" if {$tgplaying==1} { append _msg " \002on\002." } else { append _msg " \002off\002." } if {[matchattr $hand $tgflagsstart $tgchan]&&$tgplaying==0} { append _msg " Oyunu Başlatmak İçin, Lütfen \002$tgcmdstart\002 Yazınız" } append _msg " Yardıma İhtiyacınız Olursa \002/MSG $botnick [strupr $tgcmdhelp]\002 Yazınız! :-) (info[MENTION=78666]EglenceKeyfi[/MENTION].com)" [tgpriv] $nick "$_msg" } } #triggered when someone /msgs the bot with the score lookup command. proc tgscorelookup {nick host hand text} { global tgscoresbyname tgranksbyname tgscorestotal tgrealnames if {$text==""} { set text $nick } else { set text [lindex [split $text] 0] } tggetscores if {![info exists tgscoresbyname([strlwr $text])]} { if {[strlwr $text]==[strlwr $nick]} { set _who "4Siz" } else { set _who "4$text 4is" } [tgpriv] $nick "Skor Tablosunda Yoksunuz!" } else { if {[strlwr $text]==[strlwr $nick]} { set _who "4Siz" } else { set _who "4$tgrealnames([strlwr $text]) 4is" } [tgpriv] $nick "$tgscoresbyname([strlwr $text]) Soru Bildiniz , Ranked 4[tgordnum [lindex [split $tgranksbyname([strlwr $text]) ,] 0]] of 4$tgscorestotal." } return 1 } #triggered when someone /msgs the bot with the target lookup command. proc tgtargetlookup {nick host hand text} { global tgscoresbyname tgranksbyname tgscorestotal tgranksbynum tgrealnames tggetscores if {![info exists tgscoresbyname([strlwr $nick])]} { [tgpriv] $nick "Siz Skor Tablosunda Yoksunuz!" } else { set _myrank [lindex [split $tgranksbyname([strlwr $nick]) ,] 0] set _myscore [lindex [split $tgscoresbyname([strlwr $nick]) ,] 0] set _tgtrank [expr [lindex [split $tgranksbyname([strlwr $nick]) ,] 0]-1] set _tgtnick [lindex [split $tgranksbynum($_tgtrank) ,] 0] set _tgtscore [lindex [split $tgranksbynum($_tgtrank) ,] 1] [tgpriv] $nick "Şuandaki Bildiğiniz Soru Sayısı \00304$_myscore\00306. " } return 1 } #triggered when someone /msgs the bot with the error reporting command. proc tgerror {nick host hand text} { global tgquestionstotal tgquestionslist tgerrfil if {$text==""||![string is int [lindex $text 0]]} { [tgpriv] $nick "Soru Numarasını belirtmelisiniz...!" return } tgreadqdb set _qnum [lindex $text 0] if {$_qnum>$tgquestionstotal} { [tgpriv] $nick "Böyle Bir Soru Bulunamadı." return } set _qques [lindex [split [lindex $tgquestionslist [expr $_qnum-1]] |] 1] set _qans [lindex [split [lindex $tgquestionslist [expr $_qnum-1]] |] 0] set _desc [lrange $text 1 end] if {$_desc==""} { set _desc "No further info given for this error." } set _file [open $tgerrfil a] puts $_file "Reported by:\t$nick" puts $_file "Bezirgan #:\t$_qnum" puts $_file "Bezirgan:\t$_qques" puts $_file "Answer:\t\t$_qans" puts $_file "Comments:\t$_desc" puts $_file "--------------------------------------------------------------------------------" close $_file [tgpriv] $nick "Hatayı Bildirdiğiniz İçin Teşekkür Ederiz." return 1 } #triggered when someone /msgs the bot with the rules command. proc tgrulesmsg {nick host hand text} { global tgrules [tgpriv] $nick "Kanal Kuralları: $tgrules" return 1 } #triggered when someone /msgs the bot with the help command. proc tggivehelp {nick host hand {text ""}} { global botnick tgcmdlookup tgcmdhelp tgcmdstart tgcmdstop tgchan tgflagsstop global tgcmdstop tgflagshint tgcmdhint tgflagsskip tgcmdskip tgflagsreset tgcmdreset global tgcmdtarget tgcmderror tgcmdrules if {$text==""} { [tgpriv] $nick "Yardım Almak İçin Kullanacağınız Komut /MSG commands:" [tgpriv] $nick "Komutları command Yerine Yazınız, /MSG $botnick <command>" [tgpriv] $nick " \002[strupr $tgcmdrules]\002" [tgpriv] $nick " -- Kanal Kurallarını Listelemek İçin" [tgpriv] $nick " \002[strupr $tgcmdlookup]\002 \[nick\]" [tgpriv] $nick " -- Oyundaki Skorunuzu Öğrenmek İçin \[nick\], " [tgpriv] $nick " Sadece Kendi Skorunuzu Görüntüler." [tgpriv] $nick " \002[strupr $tgcmdtarget]\002" [tgpriv] $nick " -- Oyun botundaki Hedefinizi Gösterir" [tgpriv] $nick " Kimin Sizin Önünüzde Olduğunu Yada Arkanızdakinin Kim Olduğunu Görmek İçin" [tgpriv] $nick " \002[strupr $tgcmderror]\002 <number> \[description\]" [tgpriv] $nick " -- Sorulardaki Hataları bizlere Bildirmenize Yarar <number>" [tgpriv] $nick " info[MENTION=78666]EglenceKeyfi[/MENTION].com" if {[matchattr $hand $tgflagsreset $tgchan]} { [tgpriv] $nick " \002[strupr $tgcmdreset]\002" [tgpriv] $nick " -- Skor Tablosunu Resetlemek İçin." } [tgpriv] $nick "Kanal Komutlarını Listelemek İçin, /MSG $botnick [strupr $tgcmdhelp] PUBCMDS" } if {[strlwr $text]=="pubcmds"} { [tgpriv] $nick "You have access to the following channel commands:" if {[matchattr $hand $tgflagsstart $tgchan]} { [tgpriv] $nick " \002$tgcmdstart\002 -- Oyunu Baslatır." } if {[matchattr $hand $tgflagsstop $tgchan]} { [tgpriv] $nick " \002$tgcmdstop\002 -- Oyunu Durdurur." } if {[matchattr $hand $tgflagshint $tgchan]} { [tgpriv] $nick " \002$tgcmdhint\002 -- İpucu Verir." } if {[matchattr $hand $tgflagsskip $tgchan]} { [tgpriv] $nick " \002$tgcmdskip\002 -- Soruyu Atlar." } [tgpriv] $nick "For a list of /MSG commands, /MSG $botnick [strupr $tgcmdhelp]" } return 1 } #misc procs proc tggamemsg {what} { global tgchan putquick "PRIVMSG $tgchan :$what" } #Returns ordinal version of number passed to it. #i.e. [tgordnum 1] returns "1st", [tgordnum 33] returns "33rd" #Surely there's an easier way to do this? proc tgordnum {num} { set _last1 [string range $num [expr [strlen $num]-1] end] set _last2 [string range $num [expr [strlen $num]-2] end] if {$_last1=="1"&&$_last2!="11"} { return "[expr $num]st" } elseif {$_last1=="2"&&$_last2!="09"} { return "[expr $num]nd" } elseif {$_last1=="3"&&$_last2!="13"} { return "[expr $num]rd" } else { return "[expr $num]th" } } proc tgpriv {} { global tgpriv2msg if {$tgpriv2msg==1} { return "putmsg" } else { return "putnotc" } } tgreadqdb
Bu TCL kullanabilirsiniz, sorunsuzdur. |