| View previous topic :: View next topic |
| Author |
Message |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Fri Aug 29, 2008 12:45 pm Post subject: |
|
|
That looks alot better
Personally, I'd find an equation such as win/(win+loss) more intuitive, but since ultralord requested win/loss, your approach to avoid division by zero is reasonable. Could probably skip setting win to 1, as win is the nominator, not the denominator. Though in either case, the end result would be the same.
One final advice though, once you've read the files, do take the time to close them in order to save system resources, and avoid locking the files for future score-updates. _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
game_over Voice
Joined: 26 Apr 2007 Posts: 29
|
Posted: Fri Aug 29, 2008 2:49 pm Post subject: |
|
|
| nml375 wrote: | That looks alot better
Personally, I'd find an equation such as win/(win+loss) more intuitive, but since ultralord requested win/loss, your approach to avoid division by zero is reasonable. Could probably skip setting win to 1, as win is the nominator, not the denominator. Though in either case, the end result would be the same.
One final advice though, once you've read the files, do take the time to close them in order to save system resources, and avoid locking the files for future score-updates. |
for me only when open .... "w" (write) is necessity to close files. When you use open whit "r" (read only) a think command open file read content and close file immediately. For test if we use file with read $file w and don't close and flush it we never open the file whit new stuff if we use open r we don't have to . On my bot read is in one proc and others call him . |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Fri Aug 29, 2008 3:07 pm Post subject: |
|
|
Nope, the file handle is still left open. Some systems do allow the same file to be opened by multiple handles given certain conditions. Tcl, however, will not reuse the same file handle, but instead horde system resources... In the long run, you'll use up your process' quota of file handlers, and your eggdrop will be completely unable to open any further files...
read will read all the data from the current filepointer up until the end, assuming the file has been accessed in a blocking mode and no numChars argument has been supplied. In other cases, the amount of data read may vary depending on current conditions. However, in none of those cases will read try to close the file descriptor.
In the end, Always close your file handles when you've stopped using them. _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
ultralord Master

Joined: 06 Nov 2006 Posts: 255
|
Posted: Sat Aug 30, 2008 8:01 am Post subject: |
|
|
many many thanks for that!!!!!! but when i run it.. i goes to test it.. i make /hop and i saw tcl error on dcc chat
[14:42:43] <Botnick> [13:43] Tcl error [maching]: couldn't open "uL uL uL Ultralord Ultralord uL uL Ultralord Ultralord uL vlakas eleos mp00 mosxasisisi uL vlakas eleos mp00 mosxasisisi.txt": no such file or directory
the txt's file is on directory
/home/ultralord/www/dota/g_winstats.txt
/home/ultralord/www/dota/g_losestats.txt |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Sat Aug 30, 2008 9:17 am Post subject: |
|
|
Replace the $g_winstats and $g_losestats with the actual path and filenames of the stats-files, and you should be able to open the files properly. _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
ultralord Master

Joined: 06 Nov 2006 Posts: 255
|
Posted: Sat Aug 30, 2008 12:22 pm Post subject: |
|
|
i try like.. :
| Code: | set way1 "/home/ultralord/www/dota/g_winstats.txt"
set way2 "/home/ultralord/www/dota/g_losestats.txt"
bind join - * maching
proc maching {nick host hand chan} {
global g_losestats g_pickupchan g_winstats way1 way2
if {$g_pickupchan != $chan} {return 0}
set findwin 0
set findlose 0
set searchwin [split [read [open $way1 r]] "\n"]
foreach newwin [lindex $searchwin 0] {
if {$newwin == $nick} {incr findwin 1}
}
set searchlose [split [read [open $way2 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"
}
}
|
but nothing happened no tcl errors but nothing.. like it doesnt work.. |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Sat Aug 30, 2008 12:30 pm Post subject: |
|
|
The way this script is written, all string comparisons are case sensitive, including nicknames and channel names. So, should g_pickupchan be set to "#mychan", and you decide to join "#MyChan", this script will not react. Same if you use ultralord as you nick instead of UltraLord.
Of course, I assume you've double checked the actual scores, as this script will not perform any actions unless the win/loose ratio is above 5 (as requested).. _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
ultralord Master

Joined: 06 Nov 2006 Posts: 255
|
Posted: Sat Aug 30, 2008 12:42 pm Post subject: |
|
|
i edit :
| Code: | set channels "#mychannel"
bind join - * maching
proc maching {nick host hand chan} {
global g_losestats g_pickupchan g_winstats way1 way2 channels
if { $channels != $g_pickupchan } {return 0}
set findwin 0
set findlose 0
set searchwin [split [read [open $way1 r]] "\n"]
foreach newwin [lindex $searchwin 0] {
if {$newwin == $nick} {incr findwin 1}
}
set searchlose [split [read [open $way2 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"
}
} |
but no response my nick is "Ultralord" on irc and on txt files.. :/ |
|
| Back to top |
|
 |
ultralord Master

Joined: 06 Nov 2006 Posts: 255
|
Posted: Sun Aug 31, 2008 4:32 am Post subject: |
|
|
| someone knows why the bot not response to script?? :/ |
|
| Back to top |
|
 |
Nor7on Op

Joined: 03 Mar 2007 Posts: 185 Location: Spain - Barcelona
|
Posted: Sun Aug 31, 2008 5:00 am Post subject: |
|
|
put in partyline.
and look if it show some error message. |
|
| Back to top |
|
 |
ultralord Master

Joined: 06 Nov 2006 Posts: 255
|
Posted: Sun Aug 31, 2008 8:05 am Post subject: |
|
|
| no errors nothing.. wtf... can someone try it to see if he had that problem? |
|
| Back to top |
|
 |
ultralord Master

Joined: 06 Nov 2006 Posts: 255
|
Posted: Sun Aug 31, 2008 8:56 am Post subject: |
|
|
IT WORKS MANY THNX!!!!!!!!!!!!!!!
 |
|
| Back to top |
|
 |
|