| View previous topic :: View next topic |
| Author |
Message |
gasak Halfop
Joined: 09 Aug 2010 Posts: 45
|
Posted: Thu Jun 28, 2012 3:23 am Post subject: [SOLVED] Kick Counter |
|
|
Dear Masters,
I have a huge protection tcl, and i want to add a kick counter on it. Which is it will read the kick counts from a file so that it would be an orderly counts. I tried Sir_Fz suggestion here but its not orderly counts. Different procs then it counts the new one.
Hope you can get what i mean. Thank you very much. _________________ Learning Knows No Boundaries!!
Last edited by gasak on Fri Jun 29, 2012 12:31 am; edited 1 time in total |
|
| Back to top |
|
 |
doggo Halfop
Joined: 05 Jan 2010 Posts: 97
|
Posted: Thu Jun 28, 2012 5:06 am Post subject: |
|
|
i came up with this.. tested a lil bit seems to work ok
| Code: | # 28/06/2012
# kickcount function v1.0 for eggdrop
# by doggoo #omgwtfnzbs@EFNET
# http://forum.egghelp.org/viewtopic.php?t=19012
#
# usage:
# just make all your bots KICK msgs look something like this...
# putserv "KICK $chan $who $reason - kick#: [count:kicks]"
#
# returns:
# -kick [slink] test
# * spunky has kicked [slink] from #omgwtfnzbs (test - kick#: 1)
# * [slink] (~bob@omgwtfnzbs.com) has joined #omgwtfnzbs
# -kick [slink] test
# * spunky has kicked [slink] from #omgwtfnzbs (test - kick#: 2)
#
# and so on ect...
proc count:kicks {} {
set increment_count "/path/to/kickcount.db"
if { ![file exists $increment_count] } { putlog "kickcount.db does not exist.";return }
set open_text [open $increment_count "r"]
set KICKCOUNT [read -nonewline $open_text]
close $open_text
incr KICKCOUNT
set re_open_text [open $increment_count "w"]
puts $re_open_text $KICKCOUNT
close $re_open_text
return $KICKCOUNT
}
putlog "kickcount function v1.0 loaded"
|
_________________ NON geeky!! http://gotcode4u.com/
Last edited by doggo on Thu Jun 28, 2012 12:26 pm; edited 5 times in total |
|
| Back to top |
|
 |
gasak Halfop
Joined: 09 Aug 2010 Posts: 45
|
Posted: Thu Jun 28, 2012 5:16 am Post subject: |
|
|
Hi doggoo,
What is the testkick proc for? What i need is the kcount script that will work on every kick done by the TCL.
Please advice.
Thanks _________________ Learning Knows No Boundaries!! |
|
| Back to top |
|
 |
doggo Halfop
Joined: 05 Jan 2010 Posts: 97
|
Posted: Thu Jun 28, 2012 5:41 am Post subject: |
|
|
you load this function then in all the tcl's that you use to kick, edit the kick lines to look something like this..
| Code: | putserv "KICK $chan $who $reason - kick#: [count:kicks]"
|
cant really help you any more than that without knowing what tcl script you want to count kicks in  _________________ NON geeky!! http://gotcode4u.com/ |
|
| Back to top |
|
 |
gasak Halfop
Joined: 09 Aug 2010 Posts: 45
|
Posted: Thu Jun 28, 2012 5:46 am Post subject: |
|
|
ok ill give it a whirl. Will notify after whether work or not  _________________ Learning Knows No Boundaries!! |
|
| Back to top |
|
 |
gasak Halfop
Joined: 09 Aug 2010 Posts: 45
|
Posted: Thu Jun 28, 2012 8:01 am Post subject: |
|
|
Hi doggo
It works perfectly But got some question on the kick database "kickcount.db" Why the way it store the kick count is different?
Its like this
| Quote: | 1340884296
1340884305 |
So its gonna be a huge file when it reach for example more than 100 kicks. I used to have one that works that it would replace the number on the database as the kick done on particular times. So when the kicks done already 100 so inside the data is the number 100, when 105 and it shown 105, and so on. So its always only 1 line inside since it replace the number equal the kicks done.
Hope you can understand
Please advice. Thanks. _________________ Learning Knows No Boundaries!! |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Thu Jun 28, 2012 9:33 am Post subject: |
|
|
Why not store this info in a user defined channel flag like setudef int kickCount and increment that inside your script upon a kick? _________________ Once the game is over, the king and the pawn go back in the same box. |
|
| Back to top |
|
 |
gasak Halfop
Joined: 09 Aug 2010 Posts: 45
|
Posted: Thu Jun 28, 2012 10:22 am Post subject: |
|
|
| caesar wrote: | | Why not store this info in a user defined channel flag like setudef int kickCount and increment that inside your script upon a kick? |
how caesar? _________________ Learning Knows No Boundaries!! |
|
| Back to top |
|
 |
doggo Halfop
Joined: 05 Jan 2010 Posts: 97
|
Posted: Thu Jun 28, 2012 12:21 pm Post subject: |
|
|
edited script above to do what you want
delete everything out of the kickcount.db and leave just a 0 in there  _________________ NON geeky!! http://gotcode4u.com/ |
|
| Back to top |
|
 |
gasak Halfop
Joined: 09 Aug 2010 Posts: 45
|
Posted: Thu Jun 28, 2012 12:35 pm Post subject: |
|
|
PERFECT!!
Thanks a lot doggo. You're the man!!
Thank you very much! _________________ Learning Knows No Boundaries!! |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Fri Jun 29, 2012 12:27 am Post subject: |
|
|
Why do you have to write the kicks count in to a file anyway? You can easily create another kick bind that will monitor and increment the kicks count on a channel made by the bot, like this:
| Code: |
setudef int kickCount
bind kick * * kick:count
proc kick:count {nick uhost hand chan target reason} {
if {![isbotnick $nick]} return
set count [incr [channel get $chan kickCount]]
channel set $chan kickCount $count
}
|
then in your script would use something like:
| Code: |
set count [channel get $chan kickCount]
putserv "KICK $chan $who $reason - kick#: $count"
|
_________________ Once the game is over, the king and the pawn go back in the same box. |
|
| Back to top |
|
 |
gasak Halfop
Joined: 09 Aug 2010 Posts: 45
|
Posted: Thu Jul 19, 2012 12:21 pm Post subject: |
|
|
Hi doggo,
Sorry to bump it again, but i got some minor bugs on the kick count. The counting made is not an order list counted. I put 0 for the first time, but suddenly when the bot kick at the first time its already 13. I try again to make it kick then its correct counting to 14. And after that it jumps again to 21 for the next kick. Please advice about this minor bugs.
Thanks doggo. _________________ Learning Knows No Boundaries!! |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Fri Jul 20, 2012 12:27 am Post subject: |
|
|
| Code: |
setudef int kicksCounter
proc kicks:Counter {chan} {
set count [incr [channel get $chan kicksCounter]]
channel set $chan kicksCounter $count
return $count
}
putlog "kicksCounter function v1.0 loaded"
|
Here. Now all you have to do is to first enable the kick counter on the channel you wish with .chanset #channel +kicksCounter and instead of:
| Code: |
putserv "KICK $chan $who $reason - kick#: [count:kicks]"
|
you would need to pass the channel variable like this:
| Code: |
putserv "KICK $chan $who $reason - kick #[kicks:Counter $chan]"
|
and no more reading writing to the disk upon each kick. _________________ Once the game is over, the king and the pawn go back in the same box. |
|
| Back to top |
|
 |
gasak Halfop
Joined: 09 Aug 2010 Posts: 45
|
Posted: Fri Jul 20, 2012 9:18 am Post subject: |
|
|
caesar,
how if afterwards i want to reset the kickcounter from 0 again? What would be the command since it doesnt reading writing into disk?
Thanks. _________________ Learning Knows No Boundaries!! |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Sat Jul 21, 2012 12:11 pm Post subject: |
|
|
Simple. Just .chanset #channel kicksCounter 0 _________________ Once the game is over, the king and the pawn go back in the same box. |
|
| Back to top |
|
 |
|