mIRC Homepage

need help with calculate.

Posted By: Tarekhere

need help with calculate. - 14/04/14 05:40 AM

I know this sounds too much but I need it really.

I need an mirc script that will calculate how much time each op in my room spends time with +o mode .. and save it to a file as I want 2 know how many time each op spends opping the room, and i want a command to view them while im away from my computer, like i've added my self to userlist as admin.

Thanks a lot in advance
Posted By: AllDayGrinding

Re: need help with calculate. - 14/04/14 09:17 AM

You could maybe make a Points code then It saves all the points in the mIRC folder so it says how many points they have as you get points every 10 Mins or so
Posted By: Tarekhere

Re: need help with calculate. - 14/04/14 09:32 PM

i dont really know how 2 do that ..
Posted By: Nillen

Re: need help with calculate. - 14/04/14 10:50 PM

I was expecting someone more experienced to do this for you. But I'll give it a shot.

What this code will do is every time your ops will join the channel, it'll start a timer adding a second counter to an ini file on your computer. You can read this file to see how many seconds they've spent later on.

Code:
alias add.sec {
  writeini -n Optimes.ini $1 Seconds $calc($readini(Optimes.ini,$1,Seconds) + 5)
}

on *:text:!optime*:#: { 
  if ($2 == $null) { msg # $nick has spent $readini(Optimes.ini,$nick,Seconds) seconds as an op. | return }
  else { msg # $2 has spent $readini(Optimes.ini,$2,Seconds) seconds as an op. }
}

on *:join:#: 
if ($istok(%ops,$nick,32)) $+(.timersec.,$nick) 0 5 add.sec $nick

on *:text:*:#: { 
  if ($nick !isop #) return
  if ($istok(%ops,$nick,32)) return
  set %ops $addtok(%ops,$nick,32)
}

on *:part:#: { 
  $+(.timersec.,$nick) off
}


It's untested but should work the way you want it to. If you want to you can start the timers differently, I just put it so when an op types in the chat he'll be put in the variable.
Note, this will only start the timer when they join, so if you put in the script, no timers will be started until you receive the notification that they have joined the channel.
Posted By: Tarekhere

Re: need help with calculate. - 14/04/14 11:50 PM

Nillen thanks a lot for ur help .. but can it be edited to become on +o mode ?? not on join and part ??

and it returns for me this when i /add.sec
* /writeini: insufficient parameters (line 22, script4.mrc)
Posted By: blessing

Re: need help with calculate. - 15/04/14 04:05 AM

Another way to check op.

It checks all user that has @op in the channel every 5 secs then write it to file.
When you type !optime user, it will inform you the time user has spent as an op.

It works for multi channel, !optime is per channel basis.

Code:
on *:join:#:if !$timer($+(opcheck.,#))  { $+(.timeropcheck.,#) 0 5 opcheck # }
on *:text:!optime *:#:if $nick isop # { optime # $iif($2,$2,$nick) 1 }

alias -l opcheck {
  if $me !ison $1 { $+(.timeropcheck.,$1) off | return }
  var %i 1
  while $nick($1,%i,o) { 
    optime $1 $v1 
    inc %i 
  }
}

alias -l optime {
    if $isfile(opfile.ini) { var %d $iif($readini(opfile.ini,$+(optime.,$1),$2),$v1,0) }
    else { var %d 0 }
    if $3 { msg $1 $2 has $iif(%d,spent $duration(%d) as an op.,no online record.) } 
    else { writeini opfile.ini $+(optime.,$1) $2 $calc(%d + 5) }
    return
}


- untested.
Posted By: Tarekhere

Re: need help with calculate. - 16/04/14 07:24 AM

ok i tested it and its working successfully, but I need 1 more thing, I need it to save records for only 1 channel, and i need it to save daily records and weekly records .. is that possible ?
Posted By: patrickplays

Re: need help with calculate. - 17/04/14 05:54 PM

Code:
on *:join:#yourchannelhere:


this should work, i guess :s
Posted By: Nillen

Re: need help with calculate. - 17/04/14 06:04 PM

Well, you'd have to make a timer that increases a variable every 24 hours, the variable should be used in a save context, so that the script saves to opfile $+ %x $+ .ini and the timer ups the %x.

Then you can make another remote command for instance to compile the past 7 files worth.

I dunno, that's what I'd do at least.
Posted By: Tarekhere

Re: need help with calculate. - 28/04/14 12:24 PM

Originally Posted By: Nillen
Well, you'd have to make a timer that increases a variable every 24 hours, the variable should be used in a save context, so that the script saves to opfile $+ %x $+ .ini and the timer ups the %x.

Then you can make another remote command for instance to compile the past 7 files worth.

I dunno, that's what I'd do at least.



I dont know really how 2 do that frown
Posted By: Nillen

Re: need help with calculate. - 28/04/14 05:01 PM

Add something like this to blessing's code
Code:
on *:join:#:if !$timer($+(opcheck.,#))  { $+(.timeropcheck.,#) 0 5 opcheck # }
on *:text:!optime *:#:if $nick isop # { optime # $iif($2,$2,$nick) 1 }

alias -l opcheck {
  if $me !ison $1 { $+(.timeropcheck.,$1) off | return }
  var %i 1
  while $nick($1,%i,o) { 
    optime $1 $v1 
    inc %i 
  }
}

alias -l optime {
  if $isfile(opfile.ini) { var %d $iif($readini(opfile.ini,$+(Week.,%x,.,$1),$2),$v1,0) }
  else { var %d 0 }
  if $3 { msg $1 $2 has $iif(%d,spent $duration(%d) as an op today.,no online record today.) } 
  else { writeini opfile.ini $+(Week.,%x,.,$1) $2 $calc(%d + 5) }
  return
}

alias -l dayup inc %x
alias dayupstart timer 0 86400 dayup
menu channel {
  Set Day { set %x $?="" }
  Start Day Timer { dayupstart }
  Manual Dayup { dayup }
}

You'll probably figure out how to do it better though.
© 2020 mIRC Discussion Forums