View Single Post
Old 01-30-2005, 10:04 AM  
|Killer|999
Junior Member
 
Join Date: Jan 2004
Posts: 10
Default

Quote:
Originally posted by wooolF[RM]
This script needed a small update because of negative results at some point (when user have too much credits). So here's updated script :

Code:
#credits.tcl 1.1
set passwd      "C:/ioFTPD/etc/UserIdTable"
set userroot	"C:/ioFTPD/users"
proc credits {nick uhost handle chan args} {
global passwd userroot
if {[lindex $args 0] == ""} {putserv "PRIVMSG $chan :usage !credits user";return}
set fileid [open $passwd r]
set data [read $fileid]
close $fileid
foreach line [split $data \n] {
		if {[string equal [lindex $args 0] [lindex [split $line :] 0]]} {
		set data $line
	}
	}
foreach dline [split $data \n] {
set cname [lindex [split $dline :] 0]
set dline [lindex [split $dline :] 1]
if {[regexp -- "[lindex $args 0]" $cname]} {set exist 1} else {set exist 0}
	if {![string equal {} $dline] } {
		if {![file exists $userroot/$dline]} {
		return
		}
			set fileid [open $userroot/$dline r]
			set sata [read $fileid]
			close $fileid
			foreach line [split $sata \n] {
			set line [string tolower $line]	
			}
	}
}	
foreach line [split $sata \n] {
		if {[string equal "credits" [lindex [split $line " "] 0]]} {
		set credsex $line
		set credsec0 [lindex $credsex 1]
		set credsec1 [lindex $credsex 2]
		set credsec2 [lindex $credsex 3]
		set credsec3 [lindex $credsex 4]
		set credsec4 [lindex $credsex 5]
		set credsec5 [lindex $credsex 6]
		set credsec6 [lindex $credsex 7]
		set credsec7 [lindex $credsex 8]
		set credsec8 [lindex $credsex 9]
		set credsec9 [lindex $credsex 10]
		set allcreds [expr ($credsec0 + $credsec1 + $credsec2 + $credsec3 + $credsec4 + $credsec5 + $credsec6 + $credsec7 + $credsec8 + $credsec9) * 1.0]
		}
       }
       if {$exist == 1} {
       	putserv "PRIVMSG $chan :[lindex $args 0] has \002[formatkb $allcreds]\002 credits"} else {
       	putserv "PRIVMSG $chan :User does not exist!"
       	}
}
proc formatkb {size} {
   if {$size >= 1073741824} {
      set amount "[format %.2f [expr $size/1073741824.0]] TB"
   } elseif {$size >= 1048576} {
      set amount "[format %.2f [expr $size/1048576.0]] GB"
   } elseif {$size >= 1024} {
      set amount "[format %.2f [expr $size/1024.0]] MB"
   } else {
      set amount "[format %.2f $size] KB"
   }
   return $amount
}
bind pub -|- !credits credits	
putlog "credit script 1.1 loaded!!!"
PS: All credits goes to SomeoneWhoCares for making it and to badass because it was based on his static.tcl
how can i fix it when channel is encrypted ?
bot wont respons now on !credits
thx already
|Killer|999 is offline   Reply With Quote