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.
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 .
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.
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 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)..