Jump to content

Room Stats Code


Bloodyboss

Recommended Posts

hey there mate,

 

Thought I'd post something here to help you on the way... I wouldn't know the exact code they use... but I have an idea on what you could use to get you started...

 

Basically its an on TEXT event, which would record and store data of each nickname which posts a message to the channel..

 

You could use variables or an .ini file, or even better still hash tables which I'm a bit of a fan of.. However for this purpose I'll just use .ini to show an example, you can edit however you like..

 

on !:TEXT:*:#:{
  var %n = $nick, %c = $chan, %x = $readini(chanlog.ini,%c,%n), %v = $gettok(%log. [ $+ %c],1,32)
  inc %x
  writeini -n chanlog.ini %c %n %x
  if (%x < %v) return
  else { set %log. [ $+ %c ] $iif(%x == %v,%log. [ $+ %c ],$iif(%x > %v,%x)) %n }
}
/*
Note: "on !:TEXT" means, whoever writes something to the channel except for you!
Note: The "-n" flag in /writeini, means it will attempt to write to the .ini file if it is bigger than 64k
*/

 

Thats a simple code to log the data...

Then to show the data could be something like...

 

on *:TEXT:@stat:#:{
if (!%log. [ $+ [ $chan ] ]) msg # No data is stored for this Channel.
else msg # Top Talker in this Channel $gettok(%log. [ $+ [ # ] ],2,32) with $gettok(%log. [ $+ [ # ] ],1,32) Lines!
}

/*
Note: With this on TEXT event, anyone could use this command by typing @stat, so either add a user level or something along the lines of that... 
*/

 

Just an idea of the code... I'm sure there's plenty of ways to do this, and you can add, edit this to suit your needs now =)

 

Kind Regards,

Daniel

Edited by Dan*
Link to comment
Share on other sites

ooo, Also realised there were a few bugs in this code... Heres the new code which straightens out some of the bugs...

 

/*
Bug Fixes Include:
- If local variable = $null, set it as 0...
- Added evaluation tags in the logging process, as it will evaluate the local variable %c now!
- Added support for multiple people to be the top talkers.. So if Daniel and James have both the highest lines, will now say " Daniel & James"

NOTE: @stat command is available to anyone, I'd strongly recommend you changing this to only allow a user level nickname...

*/

on *:TEXT:*:#:{
if ($1 == @stat) {
  if (!%log. [ $+ [ # ] ]) msg # No data is stored for this Channel.
  else msg # Top Talker in this Channel $replace($gettok(%log. [ $+ [ # ] ],2-,32),$chr(32),$+($chr(32),$chr(38),$chr(32))) with $gettok(%log. [ $+ [ # ] ],1,32) Lines!
}
else {
  var %n = $nick, %c = $chan, %x = $readini(chanlog.ini,%c,%n), %v = $iif(%log. [ $+ [ %c ] ],$gettok(%log. [ $+ [ %c ] ],1,32),0)
  inc %x
   writeini -n chanlog.ini %c %n %x
  if (%x < %v) return
  set %log. [ $+ [ %c ] ] $iif(%x == %v,%log. [ $+ [ %c ] ],$iif(%x > %v,%x)) %n
}
}

 

Hope this helps...

 

Kind Regards,

Daniel

Edited by Dan*
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...