mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Apr 2005
Posts: 72
B
Babel fish
OP Offline
Babel fish
B
Joined: Apr 2005
Posts: 72
hello...
i have a script that count idle-time on join and written lines
and write this in hashtables
but i will count idle-time and written words
in addition the script starts hundreds of timers :-(
is there another way to count?
[code]on *:TEXT:*:#chan: {
hinc -m tmp1 $nick
if $hget(tmp1,$nick) = 10 {
hinc -m tmp $nick
hdel tmp1 $nick
}
}
on *:JOIN:#chan: {
timer 1 600 mk $nick #
}
alias mk {
if $1 ison $2 {
hinc -m tmpj $1
timer 1 600 mk $1-
}
}


thx bodo

Last edited by bodo0815; 23/05/05 03:04 PM.
Joined: Apr 2003
Posts: 701
K
Hoopy frood
Offline
Hoopy frood
K
Joined: Apr 2003
Posts: 701
That must indeed be a lot of timers shocked
Here's a suggestion:
on join: write $ctime to hash table (current)
on part and on quit: calculate idle time and write that to hash table (another entry: total)
on your quit: write idle time entries to all other nicks and channels
on text: add one to some hash entry. I have no idea why you need two different hash tables to count the same. Seems like you want to do something every 10th on text event, but using if ($calc( count % 10) == 0) is simpler and only needs one entry...
on action: don't forget those if needed smile

If you have a trigger or an alias that calculates the idle time at a specific instant, then you have some more work to do than just read the hash table like you do now. But it's still not much: $calc($ctime - join time from hash current + idle time from hash total)

Joined: Apr 2005
Posts: 72
B
Babel fish
OP Offline
Babel fish
B
Joined: Apr 2005
Posts: 72
i have no plan
i don´t know how i make this script :-(

Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
I don't understand just what it is you're looking for. When a person says something or does an action in a room, then their idle time for that room drops to 0. What is the purpose of the script? Usually for something like this it's to keep people from idling in the room. If that's what it's for, then try the following:
Code:
on !*:join:#:{
$+(.timer,$cid,.,#,.,$site) 0 3600 .ban -ku120 # $site
}
on !*:text:*:#:{
$+(.timer,$cid,.,#,.,$site) 0 3600 .ban -ku120 # $site
}
on !*:action:*:#:{
$+(.timer,$cid,.,#,.,$site) 0 3600 .ban -ku120 # $site
}
on !*:part:#:{
$+(.timer,$cid,.,#,.,$site) off
}
on !*:kick:#:{
$+(.timer,$cid,.,#,.,$site) off
}
on !*:quit:{
$+(.timer,$cid,.,#,.,$site) off
}
 


Still uses a lot of timers, especially if you have it running in one or more rooms that are busy, but will work in multiple rooms and multiple connections

Joined: Apr 2005
Posts: 72
B
Babel fish
OP Offline
Babel fish
B
Joined: Apr 2005
Posts: 72
1.] i need a script that´s count every word from a user in channel
if user write 100 words the user gets one point, next 100 words +1 point...
2.] then the script count time from every user in a channel
if a user 10min in a channel he gets one point, next 10min +1 point...

sorry for my english :-)

thx bodo

Last edited by bodo0815; 24/05/05 04:40 AM.
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
ok...I get you now...give this a try:
Code:
 on !*:join:#:{
.hadd -m Time $address $ctime
}
on *:text:!points*:#:{
if !$2 {
.msg $nick you have $calc($hget(Points,$address) + ($ctime - $hget(Time,$address)) / 600) points
}
else {
var %a = 1
while %a <= $numtok($2-,32) {
.msg $nick $gettok($2-,%a,32) has $calc($hget(Points,$gettok($address($gettok($2-,%a,32),5),2,33)) + ($ctime - $hget(Time,$gettok($address($gettok($2-,%a,32),5),2,33))) / 600) points

inc %a
}
}
}
on !*:text:*:#:{
.hinc -m Points $address $calc($0 / 100)
}
on !*:part:#:{
.hinc -m Points $address $calc(($ctime - $hget(Time,$address)) / 600)
}
on !*:kick:#:{
.hinc -m Points $address $calc(($ctime - $hget(Time,$address)) / 600)
}
on !*:quit:{
.hinc -m Points $address $calc(($ctime - $hget(Time,$address)) / 600)
}
 


I wasn't sure if you wanted to allow for partial points or not, so I defaulted to allowing for them. If you don't want to allow partial points, then put $int() around each of the $calc statements. That will bring the increment amount to the actual number of points earned.

While you didn't ask for it, I included a command !points which will allow a person to view how many points they, or someone else, has.
Usage: !points - shows you how many points you have
: !points <nick(s)> - shows the number of points for the respective nick

NOTE: The !points command will NOT work if the person is not in the room

Joined: Apr 2005
Posts: 72
B
Babel fish
OP Offline
Babel fish
B
Joined: Apr 2005
Posts: 72
it works...
but [10: 14: 01] <bot> you have 1861537.286667 points
hmmm :-)

Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
That's because of the fractional number of points calculated.
I gave you instructions on how to have it only calculate the whole numbers, but if you want the fractions calculated, how do you want the display to show? As a whole number or with a fraction? Based on your post, you don't want it as a decimal fraction.

If you want it as a whole number then put $int() around the $calc sections of the lines that have the display

If you want a fraction, what do you want as a base denominator? or do you want it in LCF (lowest common factor) format?

Joined: Apr 2005
Posts: 72
B
Babel fish
OP Offline
Babel fish
B
Joined: Apr 2005
Posts: 72
boar... my english is not so good, i don´t understand u :-(
i will normal numbers 1, 2, 3, 4.....

Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
$int($calc($hget(Points,$address) + ($ctime - $hget(Time,$address)) / 600))

-Andy

Joined: Apr 2005
Posts: 72
B
Babel fish
OP Offline
Babel fish
B
Joined: Apr 2005
Posts: 72
why is the points so big?
[19: 53: 22] <bot> you have 1861599 points

Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
I don't know how well the script works, but the points you showed earlier using $int() returns the number with no rounding.

-Andy

Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
That might be due to a problem in the calculation of the points.
In order to ensure that any points that are currently in the hash table are not transferred to this code, before running it issue the following line in the client that's running the code.
Code:
/hfree Time | /hfree Points  

Try using the script below instead and see if the number of points still seems really big, or if it looks more realistic.
Code:
 on !*:join:#:{
  .hadd -m Time $address $ctime
}
on *:text:!points*:#:{
  if !$2 {
    var %points = $hget(Points,$address)
    var %time = $hget(Time,$address)
    var %time = $calc($ctime - %time)
    var %time = $calc(%time / 600)
    var %time = $int(%time)
    inc %points %time
    .msg $nick you have %points points
  }
  else {
    var %a = 1
    while %a &lt;= $numtok($2-,32) {
      var %address = $gettok($address($gettok($2-,%a,32),5),2,33)
      var %points = $hget(Points,%address)
      var %time = $hget(Time,%address)
      var %time = $calc($ctime - %time)
      var %time = $calc(%time / 600)
      var %time = $int(%time)
      inc %points %time
      .msg $nick $gettok($2-,%a,32) has %points points
      inc %a
    }
  }
}
on !*:text:*:#:{
  .hinc -m Points $address $calc($0 / 100)
}
on !*:part:#:{
  var %time = $hget(Time,$address)
  var %time = $calc($ctime - %time)
  var %time = $calc(%time / 600)
      var %time = $int(%time)
  .hinc -m Points $address %time
}
on !*:kick:#:{
  var %time = $hget(Time,$address)
  var %time = $calc($ctime - %time)
  var %time = $calc(%time / 600)
      var %time = $int(%time)
  .hinc -m Points $address %time
}
on !*:quit:{
  var %time = $hget(Time,$address)
  var %time = $calc($ctime - %time)
  var %time = $calc(%time / 600)
      var %time = $int(%time)
  .hinc -m Points $address %time
}
 


Link Copied to Clipboard