egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Help with one of my script..
Goto page Previous  1, 2
 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Fri Aug 29, 2008 12:45 pm    Post subject: Reply with quote

That looks alot better Smile

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
View user's profile Send private message
game_over
Voice


Joined: 26 Apr 2007
Posts: 29

PostPosted: Fri Aug 29, 2008 2:49 pm    Post subject: Reply with quote

nml375 wrote:
That looks alot better Smile

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 Smile. On my bot read is in one proc and others call him Smile.
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Fri Aug 29, 2008 3:07 pm    Post subject: Reply with quote

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
View user's profile Send private message
ultralord
Master


Joined: 06 Nov 2006
Posts: 255

PostPosted: Sat Aug 30, 2008 8:01 am    Post subject: Reply with quote

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
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Sat Aug 30, 2008 9:17 am    Post subject: Reply with quote

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
View user's profile Send private message
ultralord
Master


Joined: 06 Nov 2006
Posts: 255

PostPosted: Sat Aug 30, 2008 12:22 pm    Post subject: Reply with quote

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
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Sat Aug 30, 2008 12:30 pm    Post subject: Reply with quote

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
View user's profile Send private message
ultralord
Master


Joined: 06 Nov 2006
Posts: 255

PostPosted: Sat Aug 30, 2008 12:42 pm    Post subject: Reply with quote

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
View user's profile Send private message
ultralord
Master


Joined: 06 Nov 2006
Posts: 255

PostPosted: Sun Aug 31, 2008 4:32 am    Post subject: Reply with quote

someone knows why the bot not response to script?? :/
Back to top
View user's profile Send private message
Nor7on
Op


Joined: 03 Mar 2007
Posts: 185
Location: Spain - Barcelona

PostPosted: Sun Aug 31, 2008 5:00 am    Post subject: Reply with quote

put in partyline.

Code:
.console +o


and look if it show some error message.
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
ultralord
Master


Joined: 06 Nov 2006
Posts: 255

PostPosted: Sun Aug 31, 2008 8:05 am    Post subject: Reply with quote

no errors nothing.. wtf... can someone try it to see if he had that problem?
Back to top
View user's profile Send private message
ultralord
Master


Joined: 06 Nov 2006
Posts: 255

PostPosted: Sun Aug 31, 2008 8:56 am    Post subject: Reply with quote

IT WORKS MANY THNX!!!!!!!!!!!!!!!






Surprised Surprised Surprised Surprised Surprised Surprised Surprised
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber