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.

Traffic Script...

Old posts that have not been replied to for several years.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Oh. Sorry then. Just ignore my last post. :P
Once the game is over, the king and the pawn go back in the same box.
User avatar
GodOfSuicide
Master
Posts: 463
Joined: Mon Jun 17, 2002 8:00 pm
Location: Austria

Post by GodOfSuicide »

hmm..

i loaded the tcl with the proc by .tcl source ... and it didnt work..after a bot restart it works fine now...thanks ppslim

this is the code i use now :

Code: Select all

bind pub -|- !traffic traffic_pub

proc gettraffic {type direction time} { 
   set d 0 
   set t 0 
   switch -- [string tolower $direction] { 
      "in" { set d 1 } 
      "out" { set d 3 } 
      default { error "Invalid direction used" } 
   } 
   switch -- [string tolower $time] { 
      "today" { set t 0 } 
      "total" { set t 1 } 
      default { error "Invalid value type given" } 
   } 
   set traf [traffic] 
   if {[set idx [lsearch $traf "$type *"]] < 0} { 
      error "Invalid traffic type given" 
   } 
   return [lindex [lindex $traf $idx] [expr $d + $t]] 
} 

proc traffic_pub { nick uhost hand chan text } { 
   set totaltrafficin [gettraffic total in total]
   set todaytrafficin [gettraffic total in today]
   set totaltrafficout [gettraffic total out total]
   set todaytrafficout [gettraffic total out today]
   
   set totaltrafficin [calc_mb $totaltrafficin]
   set todaytrafficin [calc_mb $todaytrafficin]
   set totaltrafficout [calc_mb $totaltrafficout]
   set todaytrafficout [calc_mb $todaytrafficout]
   putserv "PRIVMSG $chan :Total : $totaltrafficin in, $totaltrafficout out" 
   putserv "PRIVMSG $chan :Today : $todaytrafficin in, $todaytrafficout out" 
} 

proc calc_mb { wert } {
	if {[expr $wert > 1024] && [expr $wert < 1048576]} {
   		set wert [expr $wert / 1024]
   		lappend wert KB
   	} else {
   	if {[expr $wert > 1048576]} {
   	   	set wert [expr $wert / 1048576]
   	   	lappend wert MB
   	}
   	}
 	return $wert
}
it works really fine for me, even the unit calculation (my first math function ;) ).

thanks ppslim for helping me.
Locked