This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

system is busy

Old posts that have not been replied to for several years.
Locked
B
Black|Man
Voice
Posts: 21
Joined: Fri Oct 25, 2002 8:49 am
Location: Denmark

system is busy

Post by Black|Man »

how to add this line in this script ? ---> Search info system is busy, please try again in 5 seconds

Code: Select all

proc find {nick host hand chan arg} {
if {[string length $arg] < 3} { 
# they put in less than four characters.. bitch at them 
	putquick "NOTICE $nick : oh pls n00b... use more than 2 characters ffs"
	return
	} else { 
}

    putquick "NOTICE $nick :4Starting Search For 9 [lindex [split $arg] 0]  4Please wait..." 
    set stat [exec_players]
    set stat_arr [split $stat "\n"]
    set i 0
    set str $stat_arr
    set found 0
    #    set str [lsort $stat_arr]
    for {set i 0} {$i < [llength $str]} {incr i} {
	set j [expr $i + 1]
	# Loop through all the players and save them into a list
	while {[string range [lindex $str $j] 0 6] == "Player:"} {
	    set player [string trimleft [lindex $str $j] "Player:"]
	    set playername [lindex [split $player " "] 2]
	    set server [join [lindex [split [lindex $str $i] ""] 1] " "]
	    if {[string first [string tolower $arg] [string tolower $playername]] != -1} then {
		incr found
      putquick "NOTICE $nick :$playername is on $server"
	    }
	    incr j
	}
	# Make sure we don't check through the players again
	set i [expr $j - 1]
    }
    set info_str [get_number_of $found "player"]
    putquick "NOTICE $nick :$info_str"
    return 0
}
User avatar
Papillon
Owner
Posts: 724
Joined: Fri Feb 15, 2002 8:00 pm
Location: *.no

Post by Papillon »

just add a utimer, set a variable to "1" while it is searching.. make it global, once 5 secs is gone (which you set with the utimer) you can set the variable to 0 again.. then just add a check on at the beginning of the proc which will return 0 and send te msg if the var == 1 , if not it will start a continue..
Elen sila lúmenn' omentielvo
B
Black|Man
Voice
Posts: 21
Joined: Fri Oct 25, 2002 8:49 am
Location: Denmark

Post by Black|Man »

how i do that ?
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

Here is the first 3 lines of your script, change them from

Code: Select all

proc find {nick host hand chan arg} { 
if {[string length $arg] < 3} { 
# they put in less than four characters.. bitch at them 
and make them

Code: Select all

proc find {nick host hand chan arg} { 
global findhold
if {[info exists findhold]} {
  puthelp "PRIVMSG $nick :Search info system is busy, please try again in 5 seconds"
  return
}
set findhold 1
utimer 5 [list catch {unset findhold}]
if {[string length $arg] < 3} { 
# they put in less than four characters.. bitch at them 
B
Black|Man
Voice
Posts: 21
Joined: Fri Oct 25, 2002 8:49 am
Location: Denmark

Post by Black|Man »

little problem is now Search info system is busy, please try again in 5 seconds come after the first user have search and the bot is ready to a new search :(
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

Sorry

Find the line

Code: Select all

utimer 5 [list catch {unset findhold}]
and replace with

Code: Select all

utimer 5 [list catch [list unset findhold]]
B
Black|Man
Voice
Posts: 21
Joined: Fri Oct 25, 2002 8:49 am
Location: Denmark

Post by Black|Man »

still the same problem, are you on irc ?
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

I am on EFnet

You can find me in #mIRC4dummies or by my nickname
e
egghead
Master
Posts: 481
Joined: Mon Oct 29, 2001 8:00 pm
Contact:

Post by egghead »

Black|Man wrote:little problem is now Search info system is busy, please try again in 5 seconds come after the first user have search and the bot is ready to a new search :(
Afaics, there is no real solution to the problem in this way. The proc is triggered, processes the request, gives results and is then ready for a new request. Note that all requests are processed sequentially.

The only way to have it the way you want is by having two individual and separated procs. In one proc you store the request and the timestamp. Any new requests are tested for the 5 seconds by this proc. In other words this proc is always available to process new requests.

The second proc, which may be triggered by the first proc (for example by a utimer), performs the find in the stats and outputs the result.
e
egghead
Master
Posts: 481
Joined: Mon Oct 29, 2001 8:00 pm
Contact:

Post by egghead »

Black|man, in a private message on this forum you have asked what line has to be added and how to modify your code. This of course is left to you :)

Below you will find the framework of the two procs. See if you can use it.

And for the benefit of the other users, use the forum ;)

Code: Select all


bind pub - !find trigfind

proc trigfind { nick uhost hand chan text } {

   global findstamp

   set currenttime [unixtime]

   # Check if a timestamp exists
   # Note that the existence of the "findstamp" indicates that the
   # data processing is still busy. Or something went wrong
   # during the data processing and the variable was never unset.

   if { [info exists findstamp] } {

      # It is assumed that the data processing always takes
      # less than 10 seconds.  This is a sanity check.

      if { [expr $currenttime - $findstamp] < 10 } {

         puthelp "PRIVMSG $chan :System is currently busy."

         # do not proceed any further and ...

         return

      }

   }

   # trigger the stats data processing proc

   utimer 0 [list execfind $chan $text]

   # notify the channel: data processing has started

   puthelp "PRIVMSG $chan :Data processing has started, please wait."

   # reset the timestamp

   set findstamp $currenttime

}

proc execfind { chan text } {

   global findstamp

   puthelp "PRIVMSG $chan :Hello $chan! ($text)."

   # do stats data processing here
   # ...
   # ...
   # ...
   # end stats processing here

   # unset the timestamp and eggdrop is ready for new 
   # requests.

   if { [info exists findstamp] } { unset findstamp }

}

Last edited by egghead on Mon Jan 13, 2003 6:21 pm, edited 6 times in total.
B
Black|Man
Voice
Posts: 21
Joined: Fri Oct 25, 2002 8:49 am
Location: Denmark

Post by Black|Man »

hmmm privat msg ok wrong button :)

hmmm i am new to all this where i put this script in ?
B
Black|Man
Voice
Posts: 21
Joined: Fri Oct 25, 2002 8:49 am
Location: Denmark

Post by Black|Man »

what have i do wrong here ? :(

[13:58] Tcl error [find]: can't read "currenttime": no such variable
[13:58] Tcl error in script for 'timer22':

Code: Select all

proc find {nick host hand chan arg} { 
if {[string length $arg] < 3} {
   global findstamp
   set currenttime [unixtime]
   if { [info exists findstamp] } {
      if { [expr $currenttime - $findstamp] < 10 } {
         puthelp "PRIVMSG $chan :System is currently busy."
         return
# they put in less than four characters.. bitch at them 
   putquick "NOTICE $nick : oh pls n00b... use more than 2 characters ffs" 
   return 
   } else { 
} 

    putquick "NOTICE $nick :4Starting Search For 9 [lindex [split $arg] 0]  4Please wait..." 
    set stat [exec_players] 
    set stat_arr [split $stat "\n"] 
    set i 0 
    set str $stat_arr 
    set found 0 
    #    set str [lsort $stat_arr] 
    for {set i 0} {$i < [llength $str]} {incr i} { 
   set j [expr $i + 1] 
   # Loop through all the players and save them into a list 
   while {[string range [lindex $str $j] 0 6] == "Player:"} { 
       set player [string trimleft [lindex $str $j] "Player:"] 
       set playername [lindex [split $player " "] 2] 
       set server [join [lindex [split [lindex $str $i] ""] 1] " "] 
       if {[string first [string tolower $arg] [string tolower $playername]] != -1} then { 
      incr found 
      putquick "NOTICE $nick :$playername is on $server" 
       } 
       incr j 
   } 
   # Make sure we don't check through the players again 
   set i [expr $j - 1] 
    } 
    set info_str [get_number_of $found "player"] 
    putquick "NOTICE $nick :$info_str" 
    return 0 
}
   }
   utimer 0 [exec_players]
   puthelp "PRIVMSG $chan :Data processing has started, please wait."
   set findstamp $currenttime
}
e
egghead
Master
Posts: 481
Joined: Mon Oct 29, 2001 8:00 pm
Contact:

Post by egghead »

Black|Man wrote:what have i do wrong here ? :(
You are mudding around with tcl without attempting to understand what you are doing. In other words, you are taking random bits and pieces of the suggestions made here and insert them at more or less random places in your existing script.

If you want to modify a tcl beyond trivial string modifications (such as modifying "hello world" into "hello channel"), you must go through it step by step and understand what is happening and what you are doing.

It was suggested earlier to use two separated procs. But you continue to use one single proc.
One proc takes care of the trigger and the other proc takes care of the execution of the players data processing.

The reason why you get the error message is because the variable "currenttime" only gets set "if {[string length $arg] < 3}". But this is not the root problem. :evil:
B
Black|Man
Voice
Posts: 21
Joined: Fri Oct 25, 2002 8:49 am
Location: Denmark

Post by Black|Man »

ok thanks,
but i need some big help to this i have try 5 hours now and that don't still work for me :oops:

Code: Select all

proc find {nick host hand chan arg} { 
  global findstamp
   if {[string length $arg] < 3} { 
      putquick "NOTICE $nick : oh pls n00b... use more than 2 characters ffs" 
      return 0
   }

   if {[info exists findstamp]} {
      if {[expr [unixtime] - $findstamp] < 10} {
         puthelp "NOTICE $nick : ystem is currently busy."
         return 0
      }
    }
    putquick "NOTICE $nick 4Starting Search For 9 [lindex [split $arg] 0]  4Please wait..." 
    set stat [exec_players] 
    set stat_arr [split $stat "\n"] 
    set i 0 
    set str $stat_arr 
    set found 0 
    #    set str [lsort $stat_arr] 
    for {set i 0} {$i < [llength $str]} {incr i} { 
   set j [expr $i + 1] 
   # Loop through all the players and save them into a list 
   while {[string range [lindex $str $j] 0 6] == "Player:"} { 
       set player [string trimleft [lindex $str $j] "Player:"] 
       set playername [lindex [split $player " "] 2] 
       set server [join [lindex [split [lindex $str $i] "] 1] " "] 
       if {[string first [string tolower $arg] [string tolower $playername]] != -1} then { 

      incr found 
      putquick "NOTICE $nick :$playername is on $server" 
       } 
       incr j 
   } 
   # Make sure we don't check through the players again 
   set i [expr $j - 1] 
    } 
    set info_str [get_number_of $found "player"] 
    putquick "NOTICE $nick :$info_str" 
    catch {unset findstamp}
    return 0 
}
Locked