mIRC Home    About    Download    Register    News    Help

Print Thread
#241331 08/04/13 02:54 PM
Joined: Jun 2011
Posts: 29
M
Ameglian cow
OP Offline
Ameglian cow
M
Joined: Jun 2011
Posts: 29
Code:
 
;Starts the counter
on *:TEXT:!ppp*:#:{
  msg $chan $nick is now on air!
  set %startctime $ctime
}
;Stop the counter
on *:TEXT:!ooo*:#:{
  inc %OnAir. $+ $nick $duration($calc($ctime - %startctime))
  msg $chan Time: $duration($calc($ctime - %startctime))
  unset %startctime
  msg $chan $nick is now off air
}
;Information
on *:TEXT:!iii*:#:{
  msg $chan Time: $bytes($($+(%,OnAir.,$nick),2),b)
}


This script is ment to total up the amount of time a user has been on air with our radio station. so they !ppp
when they go on air, then !ooo when they get off. That time then gets added to their total time to tell chan users
how long in total they have spent on air. Then !iii is to relay their total time to the chan

Any help is very much welcome.

Joined: Oct 2012
Posts: 164
D
Vogon poet
Offline
Vogon poet
D
Joined: Oct 2012
Posts: 164
Keep the %OnAir.* vars set to just a ctime value and use $duration() in the Info block.
Code:
;Starts the counter
; If you're only using a single 'word' trigger (!ppp, !ooo, !iii) you don't need the wildcard match ;)
on *:TEXT:!ppp:#:{
  msg $chan $nick is now on air!
  set %startctime $ctime
}
;Stop the counter
on *:TEXT:!ooo:#:{
  inc %OnAir. $+ $nick $calc($ctime - %startctime)
  msg $chan Time: $duration($calc($ctime - %startctime))
  unset %startctime
  msg $chan $nick is now off air
}
;Information
on *:TEXT:!iii:#:{
  msg $chan Time: $duration($($+(%,OnAir.,$nick),2))
}


You will have to reset the %OnAir.* vars that you have already.

Joined: Jun 2011
Posts: 29
M
Ameglian cow
OP Offline
Ameglian cow
M
Joined: Jun 2011
Posts: 29
Thank-you, works a treat.

Joined: Jun 2011
Posts: 29
M
Ameglian cow
OP Offline
Ameglian cow
M
Joined: Jun 2011
Posts: 29
Code:
on *:text:+dj *:#: {
  if ($2 == off) {
    set %no-dj_ctime $ctime
    inc %OnAir. $+ $nick $calc($ctime - %dj_ctime)
    inc %OnAir.Staff $calc($ctime - %dj_ctime)
    set %DJ Playlist
    msg $chan Off
    writeini -n radio.ini DJ Current Playlist
    writeini -n radio.ini DJ Time $time
    writeini -n radio.ini DJ Date $date
  }
  else ($2 == on) {
    set %dj_ctime $ctime
    inc %OnAir.Playlist $calc($ctime - %no-dj_ctime)
    set %DJ $nick
    msg $chan On
    writeini -n radio.ini DJ Current $nick
  }  
}
on *:TEXT:!look *:#:{
  msg $chan Time: $duration($($+(%,OnAir.,$2),2))
}


Ok, so this is what I have.

So this script counts up a DJs airtime AND it counts up the total airtime for ALL DJs as a combined element. So you have 2 stats, one for 1 DJ and the other for all DJs.

I want to throw something else into fishpond here, when the DJs are off air we have a playlist so I have counted the playlist as another DJ---> inc %OnAir.Playlist $calc($ctime - %no-dj_ctime)

I want to try and work out a % airtime for total staff and playlist, Is this possible?

Code:
inc %OnAir.Staff $calc($ctime - %dj_ctime) <---Staff total
inc %OnAir.Playlist $calc($ctime - %no-dj_ctime) <--- Playlist total


So it looks like:

Code:
[10:10:12] mumra_2790: !airtime 
[10:10:13] Dinky: So far our DJs have been on air for 76% of the time!


Agian any help is welcome!

Joined: Oct 2012
Posts: 164
D
Vogon poet
Offline
Vogon poet
D
Joined: Oct 2012
Posts: 164
It's just calculating percentage... wink
((amount ÷ total) × 100) = percentage
Code:
on *:text:!airtime:#:{
  msg $chan So far our DJs have been on air for $&
    $round($calc((%OnAir.Staff / (%OnAir.Staff + %OnAir.Playlist))*100),0) $+ % $&
    of the time!
}


In the +dj event you should also be checking if $nick OR Playlist is %DJ AND if $nick is someone who is authorised to be a DJ (but I don't know where or how that last info is stored so I can't add it).
Code:
on *:text:+dj *:#: {
  if ($2 == off) && (%DJ == $nick) {
    set %no-dj_ctime $ctime
    inc %OnAir. $+ $nick $calc($ctime - %dj_ctime)
    inc %OnAir.Staff $calc($ctime - %dj_ctime)
    set %DJ Playlist
    msg $chan Off
    writeini -n radio.ini DJ Current Playlist
    writeini -n radio.ini DJ Time $time
    writeini -n radio.ini DJ Date $date
  }
  elseif ($2 == on) && (%DJ == Playlist) {
    set %dj_ctime $ctime
    inc %OnAir.Playlist $calc($ctime - %no-dj_ctime)
    set %DJ $nick
    msg $chan On
    writeini -n radio.ini DJ Current $nick
    writeini -n radio.ini DJ Time $time
    writeini -n radio.ini DJ Date $date
  }  
}

BTW...Your code also has "else ($2 == on) {" which should be "elseif ($2 == on) {"
smile


Link Copied to Clipboard