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.

[SOLVED] Kick Counter

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
g
gasak
Halfop
Posts: 45
Joined: Mon Aug 09, 2010 11:09 pm

[SOLVED] Kick Counter

Post by gasak »

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.
Last edited by gasak on Fri Jun 29, 2012 12:31 am, edited 1 time in total.
Learning Knows No Boundaries!!
d
doggo
Halfop
Posts: 97
Joined: Tue Jan 05, 2010 7:53 am
Contact:

Post by doggo »

i came up with this.. tested a lil bit seems to work ok :D

Code: Select all

# 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"

Last edited by doggo on Thu Jun 28, 2012 12:26 pm, edited 5 times in total.
g
gasak
Halfop
Posts: 45
Joined: Mon Aug 09, 2010 11:09 pm

Post by gasak »

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!!
d
doggo
Halfop
Posts: 97
Joined: Tue Jan 05, 2010 7:53 am
Contact:

Post by doggo »

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: Select all

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 :)
g
gasak
Halfop
Posts: 45
Joined: Mon Aug 09, 2010 11:09 pm

Post by gasak »

ok ill give it a whirl. Will notify after whether work or not :)
Learning Knows No Boundaries!!
g
gasak
Halfop
Posts: 45
Joined: Mon Aug 09, 2010 11:09 pm

Post by gasak »

Hi doggo

It works perfectly :D But got some question on the kick database "kickcount.db" Why the way it store the kick count is different?

Its like this
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!!
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

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.
g
gasak
Halfop
Posts: 45
Joined: Mon Aug 09, 2010 11:09 pm

Post by gasak »

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!!
d
doggo
Halfop
Posts: 97
Joined: Tue Jan 05, 2010 7:53 am
Contact:

Post by doggo »

edited script above to do what you want :D

delete everything out of the kickcount.db and leave just a 0 in there :wink:
g
gasak
Halfop
Posts: 45
Joined: Mon Aug 09, 2010 11:09 pm

Post by gasak »

PERFECT!!

Thanks a lot doggo. You're the man!!

Thank you very much!
Learning Knows No Boundaries!!
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

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: Select all

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: Select all

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.
g
gasak
Halfop
Posts: 45
Joined: Mon Aug 09, 2010 11:09 pm

Post by gasak »

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!!
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Code: Select all

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: Select all

putserv "KICK $chan $who $reason - kick#: [count:kicks]" 
you would need to pass the channel variable like this:

Code: Select all

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.
g
gasak
Halfop
Posts: 45
Joined: Mon Aug 09, 2010 11:09 pm

Post by gasak »

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!!
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Simple. Just .chanset #channel kicksCounter 0
Once the game is over, the king and the pawn go back in the same box.
Post Reply