| View previous topic :: View next topic |
| Author |
Message |
ultralord Master

Joined: 06 Nov 2006 Posts: 255
|
Posted: Thu Aug 21, 2008 7:34 pm Post subject: Help with one of my script.. |
|
|
Hello, part of my script
| Code: | proc g_mywins {nickname hand idx args} {
global g_winstats g_pickupchan
if { [matchattr $idx L] } {
if {[llength $g_winstats]==0} {
putserv "NOTICE $nickname :No Wins yet :)"
return 0
}
set stats $g_winstats
set results [list ]
while {[llength $stats]!=0} {
set match [lindex $stats 0]
set counter 0
set temp [list ]
set temp [linsert $temp end $match]
while {[lsearch -exact $stats $match]>-1} {
incr counter
set pos [lsearch -exact $stats $match]
set stats [lreplace $stats $pos $pos]
}
set temp [linsert $temp end $counter]
set results [linsert $results end $temp]
}
set results [lsort -integer -decreasing -index 1 $results]
set counter 1
foreach result $results {
if { [matchattr $idx G] } {
set admin0r 1
} else {
set admin0r 0
}
if {$nickname == [lindex $result 0]} {
if {$admin0r == 1} {
putquick "NOTICE $nickname :14,1\[9«4 You ([lindex $result 0]) have [lindex $result 1] Wins. Status: Admin. 7»14]"
} else {
putquick "NOTICE $nickname :14,1\[9«4 You ([lindex $result 0]) have [lindex $result 1] Wins. 0,1. Status: 4User0,1. 7»14]"
}
}
incr counter
}
} else {
if {[llength $g_winstats]==0} {
putserv "NOTICE $nickname :No Wins yet :)"
return 0
}
set stats $g_winstats
set results [list ]
while {[llength $stats]!=0} {
set match [lindex $stats 0]
set counter 0
set temp [list ]
set temp [linsert $temp end $match]
while {[lsearch -exact $stats $match]>-1} {
incr counter
set pos [lsearch -exact $stats $match]
set stats [lreplace $stats $pos $pos]
}
set temp [linsert $temp end $counter]
set results [linsert $results end $temp]
}
set results [lsort -integer -decreasing -index 1 $results]
set counter 1
foreach result $results {
if { [matchattr $idx G] } {
set admin0r 1
} else {
set admin0r 0
}
if {$nickname == [lindex $result 0]} {
if {$admin0r == 1} {
putquick "NOTICE $nickname :14,1\[9«4 You ([lindex $result 0]) have [lindex $result 1] Wins. Status: Admin. 7»14]"
} else {
putquick "NOTICE $nickname :14,1\[9«4 You ([lindex $result 0]) have [lindex $result 1] Wins. 0,1. Status: 4User0,1. 7»14]"
}
}
incr counter
}
}
} |
he return
<Ultralord> !mywins
-Botnick- [« You (Ultralord) have 2 Wins. . Status: User. »]
2nd part:
| Code: | proc g_myloses {nickname hand idx args} {
global g_losestats g_pickupchan
if { [matchattr $idx L] } {
if {[llength $g_losestats]==0} {
putserv "NOTICE $nickname :No Looses yet :)"
return 0
}
set stats $g_losestats
set results [list ]
while {[llength $stats]!=0} {
set match [lindex $stats 0]
set counter 0
set temp [list ]
set temp [linsert $temp end $match]
while {[lsearch -exact $stats $match]>-1} {
incr counter
set pos [lsearch -exact $stats $match]
set stats [lreplace $stats $pos $pos]
}
set temp [linsert $temp end $counter]
set results [linsert $results end $temp]
}
set results [lsort -integer -decreasing -index 1 $results]
set counter 1
# putquick "NOTICE $nickname :1,0«1,15«1,14«0,1 Top 10 gather players. 1,14»1,15»1,0»"
foreach result $results {
if { [matchattr $idx G] } {
set admin0r 1
} else {
set admin0r 0
}
if {$nickname == [lindex $result 0]} {
if {$admin0r == 1} {
putquick "NOTICE $nickname :14,1\[9«4 You ([lindex $result 0]) have [lindex $result 1] Looses. Status: Admin. 7»14]"
} else {
putquick "NOTICE $nickname :14,1\[9«4 You ([lindex $result 0]) have [lindex $result 1] Looses. 0,1. Status: 4User0,1. 7»14]"
}
}
incr counter
}
} else {
if {[llength $g_losestats]==0} {
putserv "NOTICE $nickname :No Looses yet :)"
return 0
}
set stats $g_losestats
set results [list ]
while {[llength $stats]!=0} {
set match [lindex $stats 0]
set counter 0
set temp [list ]
set temp [linsert $temp end $match]
while {[lsearch -exact $stats $match]>-1} {
incr counter
set pos [lsearch -exact $stats $match]
set stats [lreplace $stats $pos $pos]
}
set temp [linsert $temp end $counter]
set results [linsert $results end $temp]
}
set results [lsort -integer -decreasing -index 1 $results]
set counter 1
# putquick "NOTICE $nickname :1,0«1,15«1,14«0,1 Top 10 gather players. 1,14»1,15»1,0»"
foreach result $results {
if { [matchattr $idx G] } {
set admin0r 1
} else {
set admin0r 0
}
if {$nickname == [lindex $result 0]} {
if {$admin0r == 1} {
putquick "NOTICE $nickname :14,1\[9«4 You ([lindex $result 0]) have [lindex $result 1] Looses. Status: Admin. 7»14]"
} else {
putquick "NOTICE $nickname :14,1\[9«4 You ([lindex $result 0]) have [lindex $result 1] Looses. 0,1. Status: 4User0,1. 7»14]"
}
}
incr counter
}
}
}
|
he return
<Ultralord> !mylooses
-Botnick- [« You (Ultralord) have 4 Looses. . Status: User. »]
the winstats.txt and losestats.txt is .txt files with names inside
example: ( You (Ultralord) have 2 Wins ( my nick is two times on winstats.txt file ) and same with losestats.txt..
i want to make divide the stats like 4/2 with this stats and if the result of divide is more than 5 then the bot gives one flag +V on specific user with that stat..
if this help's:
i add points wins with that proc:
| Code: | proc g_addwinstats { nick uhost handle arg } {
global g_winstats g_winplayer g_winplayerstats
set g_winplayer [lindex $arg 0]
set g_winstats [linsert $g_winstats end $g_winplayer]
set fileio [open /home/ultralord/www/dota/g_winstats.txt "w"]
puts $fileio $g_winstats
flush $fileio
close $fileio
putquick "PRIVMSG $nick :14,1\[9«4 Mr. $g_winplayer : Added on WIN list 7»14]"
} |
same with loose points..
plz someone help me with that..and if he goes well i pay some money.. i need it to work..
thanks !! |
|
| Back to top |
|
 |
ultralord Master

Joined: 06 Nov 2006 Posts: 255
|
Posted: Fri Aug 22, 2008 3:57 am Post subject: |
|
|
| Quote: | | i want to make divide the stats like 4/2 with this stats and if the result of divide is more than 5 then the bot gives one flag +V on specific user with that stat.. |
anyone? know how i can calculate the divide from 2 results from .txt file
 |
|
| Back to top |
|
 |
ultralord Master

Joined: 06 Nov 2006 Posts: 255
|
Posted: Fri Aug 22, 2008 5:43 am Post subject: |
|
|
if i do
set g_winstats [list]
set g_losestats [list]
set perc [expr {$g_winstats/$g_losestats}]
in the begging is correct? something like that.. |
|
| Back to top |
|
 |
game_over Voice
Joined: 26 Apr 2007 Posts: 29
|
Posted: Fri Aug 22, 2008 5:58 am Post subject: |
|
|
something like this
| Code: | set way1 "/home/ultralord/www/dota/g_winstats.txt"
set way2 "/home/ultralord/www/dota/g_losestats.txt"
bind *something* join or whatever or some proc
proc maching {nick host chan ......} {
global way1 way2
set findwin ""
set findlose ""
set searchwin [open $way1 r]
foreach newwin $searchwin {
if {[lindex $newwin 0]} {set findwin $newwin}
}
set searchlose [open $way2 r]
foreach newlose $searchlose {
if {[lindex $newlose 0]} {set findlose $newlose}
}
if {$findwin == ""} {
set winpoints 1
} else {
set winpoints [lindex $findwin 1]
}
if {$findlose == ""}
set losespoints 1
} else {
set losespoints [lindex $findlose 1]
}
if {[expr $winpoints / $losespoints] >= 5 } {
putquick "MODE $chan bla bla bla ...."
}
} |
|
|
| Back to top |
|
 |
ultralord Master

Joined: 06 Nov 2006 Posts: 255
|
Posted: Fri Aug 22, 2008 7:28 am Post subject: |
|
|
i put
| Code: | proc maching { nick host chan } {
global way1 way2
set findwin ""
set findlose ""
set searchwin [open $way1 r]
foreach newwin $searchwin {
if {[lindex $newwin 0]} {set findwin $newwin}
}
set searchlose [open $way2 r]
foreach newlose $searchlose {
if {[lindex $newlose 0]} {set findlose $newlose}
}
if {$findwin == ""} {
set winpoints 1
} else {
set winpoints [lindex $findwin 1]
}
if {$findlose == ""}
set losespoints 1
} else {
set losespoints [lindex $findlose 1]
}
if {[expr $winpoints / $losespoints] >= 5 } {
putquick "MODE $chan bla bla bla ...."
}
}
}
|
but error when i run from putty
| Code: | [13:27] wrong # args: should be "proc name args body"
while executing
"proc maching { nick host chan } {
global way1 way2
set findwin ""
set findlose ""
set searchwin [open $way1 r]
foreach newwin $searchwi..."
(file "scripts/test.tcl" line 313)
invoked from within
"source scripts/test.tcl"
(file "eggdrop.conf" line 152)
[13:27] * CONFIG FILE NOT LOADED (NOT FOUND, OR ERROR)
|
how i can fix it? i tried but nothing.. :/ |
|
| Back to top |
|
 |
game_over Voice
Joined: 26 Apr 2007 Posts: 29
|
Posted: Fri Aug 22, 2008 8:11 am Post subject: |
|
|
i only show you example this is not realy finished script
first you may have bind
| Code: | | bind join - * maching |
and realy working proc
| Code: | | proc maching {nick host hand chan text} { |
second in line you have to write realy working mode
| Code: | | putquick "MODE $chan +v $nick" |
i just post you example without strict parts of tcl for eggdrop bindings  |
|
| Back to top |
|
 |
ultralord Master

Joined: 06 Nov 2006 Posts: 255
|
Posted: Fri Aug 22, 2008 8:28 am Post subject: |
|
|
i put binds and all other examples just to see if it works and i have same error again
because i am very tried to do that all day can you fix it for me?
only i want to divide the winstats/losestats from this txt files
http://grid.sh3lls.net/~ultralord/dota/g_winstats.txt
http://grid.sh3lls.net/~ultralord/dota/g_losestats.txt
and example:
nick = Ultralord
If nick Ultralord have divided his win/lose >= 5 then the bot make some proc i know what proc
help me plx and if all this works ok.. i send you payment from paypal.. just need it that :/ |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Fri Aug 22, 2008 1:10 pm Post subject: |
|
|
Game_over:
First off, your file handling is incorrect... Doing a foreach-loop on a filehandle will not yield the result you expect.
Next, I can't even imagine the purpose of the lindex commands, or how you expect that code to produce a tally of wins/losses...
Finally, properly indenting the code would reveal that there is one { missing from one of the if-constructs...
Ultralord:
Start off with counting both wins and losses. Since you already have commands to print number of wins (and losses), most of this code should be re-usable. Once you have both numbers, just do the division (using the expr command) and test whether the result is >= 5. _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
ultralord Master

Joined: 06 Nov 2006 Posts: 255
|
Posted: Fri Aug 22, 2008 6:01 pm Post subject: |
|
|
yes i know i must count both win/looses on same proc but i dont know how i can do that..
also i want to say again what i want to do with that script
so.. i have two .txt files
http://grid.sh3lls.net/~ultralord/dota/g_winstats.txt
http://grid.sh3lls.net/~ultralord/dota/g_losestats.txt
first i want when someone join on channel then one proc must work and his job is count how many times is his nick on the winstats.txt and after that count how many times is his nick on the losestats.txt and then the proc must do divide winstats/loses and if the result is >=5 then bot can say any msg like example: Ultralord you are VIP member ( if his result is >=5)
that i want to do..
i must start to count both files but all the time cant unterestand..
someone can do something with that?
thanks for support at all ~ |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Fri Aug 22, 2008 6:07 pm Post subject: |
|
|
As I said, you've got most of the code there already, just a matter of re-using it..
To me, this rather sounds like you're looking for "Script Request", not "Scripting Help" _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
ultralord Master

Joined: 06 Nov 2006 Posts: 255
|
Posted: Fri Aug 22, 2008 6:43 pm Post subject: |
|
|
ok.. i am going to try with the previus code.. also i post it on request if someone can do that..
thanks.. |
|
| Back to top |
|
 |
ultralord Master

Joined: 06 Nov 2006 Posts: 255
|
Posted: Fri Aug 22, 2008 7:02 pm Post subject: |
|
|
| game_over wrote: | something like this
| Code: | set way1 "/home/ultralord/www/dota/g_winstats.txt"
set way2 "/home/ultralord/www/dota/g_losestats.txt"
bind *something* join or whatever or some proc
proc maching {nick host chan ......} {
global way1 way2
set findwin ""
set findlose ""
set searchwin [open $way1 r]
foreach newwin $searchwin {
if {[lindex $newwin 0]} {set findwin $newwin}
}
set searchlose [open $way2 r]
foreach newlose $searchlose {
if {[lindex $newlose 0]} {set findlose $newlose}
}
if {$findwin == ""} {
set winpoints 1
} else {
set winpoints [lindex $findwin 1]
}
if {$findlose == ""}
set losespoints 1
} else {
set losespoints [lindex $findlose 1]
}
if {[expr $winpoints / $losespoints] >= 5 } {
putquick "MODE $chan bla bla bla ...."
}
} |
|
if i change the newwin with nick will be correct?
because i want to foreach the $nick on $searchwin
or i say %@#^%  |
|
| Back to top |
|
 |
game_over Voice
Joined: 26 Apr 2007 Posts: 29
|
Posted: Fri Aug 29, 2008 6:38 am Post subject: |
|
|
| nml375 wrote: | Game_over:
First off, your file handling is incorrect... Doing a foreach-loop on a filehandle will not yield the result you expect.
Next, I can't even imagine the purpose of the lindex commands, or how you expect that code to produce a tally of wins/losses...
Finally, properly indenting the code would reveal that there is one { missing from one of the if-constructs...
|
Because i think the file structure is that:
nick1 wins
nick2 wins
and wins and loses are writed whit nums this is more effective way
now i am on work when i gather at home i look this files an run on my bot and you have no problems  |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Fri Aug 29, 2008 8:41 am Post subject: |
|
|
@game_over:
foreach does'nt understand file-descriptors... foreach only understands lists.
A file descriptor is simply a short string containing one word that identifies the opened file. But to foreach, it just looks like a list with one single entity, looking something like "file12". Doing a foreach on that will just run the code once, with newwin containing "file12", nothing else...
As for the file structure, it is a single line with the nicks of the winners in a list. Thus, even if you did fix your code to actually read from the file, your if-conditional makes no sense...
First off, newwin would not be a list, but a string - don't use lindex here, that'll break things.
Secondly, should the lindex not choke on the data, it would most likely just return a possibly mangled newwin, which most certainly is not a boolean data (required by if). Hence you'd only end up with an error message such as: expected boolean value but got "nickname". _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
game_over Voice
Joined: 26 Apr 2007 Posts: 29
|
Posted: Fri Aug 29, 2008 12:31 pm Post subject: |
|
|
I forgot read command but i tell you this i same example. I see you want all. Only insert this
| Code: | bind join - * maching
proc maching {nick host hand chan} {
global g_losestats g_pickupchan g_winstats
if {$g_pickupchan != $chan} {return 0}
set findwin 0
set findlose 0
set searchwin [split [read [open $g_winstats r]] "\n"]
foreach newwin [lindex $searchwin 0] {
if {$newwin == $nick} {incr findwin 1}
}
set searchlose [split [read [open $g_losestats r]] "\n"]
foreach newlose [lindex $searchlose 0] {
if {$newlose == $nick} {incr findlose 1}
}
if {$findwin == 0} {
set findwin 1
}
if {$findlose == 0} {
set findlose 1
}
if {[expr $findwin / $findlose] >= "5" } {
putquick "PRIVMSG $g_pickupchan : \002\00304 $nick\003 You have coefficient\00303 [expr $findwin / $findlose] \003 I give you\00304 +"
putquick "MODE $g_pickupchan +v $nick"
}
} |
this do that
http://img5.pictiger.com/4e6/16597121.jpg?u=1220027072
now i say expr 5 / 0 wins and loses is 0 i script if you don't have loses set loses to 1. now 5 / 1 = 5 and voise is up and 0 / 5 to 1 / 5 . If want to see nums like this 0.0005 just
| Quote: | | [expr $findwin / $findlose] |
to
| Quote: | | [expr $findwin. / $findlose.] |
|
|
| Back to top |
|
 |
|