Страница 1 из 1

Как объединить top скрипта рыбалки и еще какой-то фигни?

СообщениеДобавлено: 08 июл 2011 12:58
DmitRex
Есть два скрипта которые выводят Топ5 лидеторв игры:
По трофеям:
TCL: [ Скачать ] [ Скрыть ]
bind pub - !топ5 top5
proc top5 {nick uhost hand chan text} {
if {$text == "трофеев"} {
if {![file exists data/wc2.usr]} {putmsg $chan "Таблица рекордов пуста. (Нет файла базы игроков)"; return}
set top_f2 [::egglib::readdata "data/wc2.usr"]
if {$top_f2 == ""} {putmsg $chan "Таблица рекордов пуста."; return}
foreach user $top_f2 {
set nik_top2 [lindex [split $user +] 0]
set score2 [lindex [split $user +] 1]
lappend scorelist2 "$nik_top2 $score2"
}

set scorelist2 [lsort -real -decreasing -index 1 $scorelist2]
set msg2 ""
set place2 0
foreach item [lrange $scorelist2 0 4] {
        if {[lindex $item 1] != 0} { append msg2 ", 14[incr place].  12[lindex $item 0] 2(9\002\002[lindex $item 1]2)" }
        unset item
}
if {$msg2 != ""} { putmsg $chan "2Топ-5 по трофеям: [string range $msg2 2 end]\003" }
unset scorelist2 msg2 place2}
}

И по прочтённым кнмгам:
TCL: [ Скачать ] [ Скрыть ]
bind pub - !топ5 top5
proc top5 {nick uhost hand chan text} {
if {$text == "книг"} {
if {![file exists data/wc.usr]} {putmsg $chan "Таблица рекордов пуста. (Нет файла базы игроков)"; return}
set top_f [::egglib::readdata "data/wc.usr"]
if {$top_f == ""} {putmsg $chan "Таблица рекордов пуста."; return}
foreach user $top_f {
set nik_top [lindex [split $user +] 0]
set score [lindex [split $user +] 1]
lappend scorelist "$nik_top $score"
}

set scorelist [lsort -real -decreasing -index 1 $scorelist]
set msg ""
set place 0
foreach item [lrange $scorelist 0 4] {
        if {[lindex $item 1] != 0} { append msg ", 14[incr place].  12[lindex $item 0] 2(9\002\002[lindex $item 1]2)" }
        unset item
}
if {$msg != ""} { putmsg $chan "2Топ-5 по прочтенным книгам: [string range $msg 2 end]\003" }
unset scorelist msg place}
}

Но эти два скрипта которые находятся раздельны от друг друга некорректно работают по командам !топ5 книг и !топ5 трофеев .
Как сделать чтобы они работали как следует?

Тему переименовал. Потрудись давать более осмысленные названия, так чтобы из них можно было хоть что-то понять. В следующий раз темы с таким названием будут удалены.
Спасиба, КЭП!

Re: top

СообщениеДобавлено: 08 июл 2011 13:26
tvrsh
Полностью скопировать содержимое второй процедуры в первую.

Re: Как объединить top скрипта рыбалки и еще какой-то фигни?

СообщениеДобавлено: 08 июл 2011 13:37
DmitRex
TCL: [ Скачать ] [ Скрыть ]
bind pub - !топ5 top5
proc top5 {nick uhost hand chan text} {
if {$text == "трофеев"} {
if {![file exists data/wc2.usr]} {putmsg $chan "Таблица рекордов пуста. (Нет файла базы игроков)"; return}
set top_f2 [::egglib::readdata "data/wc2.usr"]
if {$top_f2 == ""} {putmsg $chan "Таблица рекордов пуста."; return}
foreach user $top_f2 {
set nik_top2 [lindex [split $user +] 0]
set score2 [lindex [split $user +] 1]
lappend scorelist2 "$nik_top2 $score2"
}

set scorelist2 [lsort -real -decreasing -index 1 $scorelist2]
set msg2 ""
set place2 0
foreach item [lrange $scorelist2 0 4] {
        if {[lindex $item 1] != 0} { append msg2 ", 14[incr place].  12[lindex $item 0] 2(9\002\002[lindex $item 1]2)" }
        unset item
}
if {$msg2 != ""} { putmsg $chan "2Топ-5 по трофеям: [string range $msg2 2 end]\003" }
unset scorelist2 msg2 place2}
if {$text == "книг"} {
if {![file exists data/wc.usr]} {putmsg $chan "Таблица рекордов пуста. (Нет файла базы игроков)"; return}
set top_f [::egglib::readdata "data/wc.usr"]
if {$top_f == ""} {putmsg $chan "Таблица рекордов пуста."; return}
foreach user $top_f {
set nik_top [lindex [split $user +] 0]
set score [lindex [split $user +] 1]
lappend scorelist "$nik_top $score"
}

set scorelist [lsort -real -decreasing -index 1 $scorelist]
set msg ""
set place 0
foreach item [lrange $scorelist 0 4] {
        if {[lindex $item 1] != 0} { append msg ", 14[incr place].  12[lindex $item 0] 2(9\002\002[lindex $item 1]2)" }
        unset item
}
if {$msg != ""} { putmsg $chan "2Топ-5 по прочтенным книгам: [string range $msg 2 end]\003" }
unset scorelist msg place}
}
 

Re: Как объединить top скрипта рыбалки и еще какой-то фигни?

СообщениеДобавлено: 08 июл 2011 13:54
tvrsh
Что должен значить этот кусок кода?
Не пиши больше на этом форуме.