mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Mar 2024
Posts: 7
M
Maiko Online OP
Nutrimatic drinks dispenser
OP Online
Nutrimatic drinks dispenser
M
Joined: Mar 2024
Posts: 7
Hello .

I am trying to make a script that tracks the amount of times a person has joined a channel . I have found a few examples of script for tracking when I join a channel , but not what I was looking for .

A person ( PlayerA )join channel #test . The scripts writes down the person's nick $nick . to a text file channeltracker.txt and adds a counter of 1
A different person (PlayerB) joins the same channel ...script writes down that person nick to the same text file channeltracker.txt and adds a counter of 1

When PlayerA rejoins the channel #test , the script finds the $nick PlayerA and add +1 to PlayerA counter . $inc +1

After a while , the channeltracking.txt should look like a list

PlayerA 254
PlayerB 2
AnotherPerson 13
YetAnotherPerson 54


telling me that PlayerA has joined #test 254 times and is the most active person .

Joined: Mar 2024
Posts: 7
M
Maiko Online OP
Nutrimatic drinks dispenser
OP Online
Nutrimatic drinks dispenser
M
Joined: Mar 2024
Posts: 7
A person ( PlayerA )join channel #test . The scripts writes down the person's nick $nick . to a text file channeltracker.txt and adds a counter of 1 to PlayerA count .

A different person (PlayerB) joins the same channel #test ...script writes down that person nick to the same text file channeltracker.txt and adds a counter of 1 to PlayerB count .

Joined: Jan 2012
Posts: 337
Pan-dimensional mouse
Offline
Pan-dimensional mouse
Joined: Jan 2012
Posts: 337
I have created a small script code for you. Try using it:
Code
on *:JOIN:#test:{
  if ($read($ctfile,ntw,$nick *)) {
    var %rn $readn, %count $gettok($read($ctfile,nt,%rn),2,32)
    write $+(-l,%rn) $ctfile $nick $calc(%count + 1)
  }
  else { write -i $ctfile $nick 1 }
}

alias -l ctfile { return channeltracker.txt }


🌐 https://forum.epicnet.ru 📜 irc.epicnet.ru 6667 #Code | mIRC scripts, help, discuss, examples
Joined: May 2022
Posts: 124
F
Vogon poet
Offline
Vogon poet
F
Joined: May 2022
Posts: 124
This is great, I "stolen it" :-P
Thanks Epic.
A question: lines are not in order from high to low, is it possibile to write them in a .excel file?

Joined: Jan 2012
Posts: 337
Pan-dimensional mouse
Offline
Pan-dimensional mouse
Joined: Jan 2012
Posts: 337
Originally Posted by Fernet
I "stolen it" :-P
     [Linked Image from i.ibb.co]

Originally Posted by Fernet
... is it possibile to write them in a .excel file?
As far as I know, mIRC does not support writing files in ".xlsx" format for reading in Excel. But with the help of third-party tools, you can convert the file ".txt" to ".xlsx".

Originally Posted by Fernet
lines are not in order from high to low ...
Yes, because each new user is written to a new row, and an existing record is overwritten to the same row in which it was found. If you want all the lines written in the file to be displayed in order from the largest to the smallest number of channel visits each time the file is opened - you will have to create additional code with the function of constantly sorting and rewriting the file data. But there is a nuance! If there are too many such records over time, I am not sure about good productivity of your mIRC when it performs each new sorting.


🌐 https://forum.epicnet.ru 📜 irc.epicnet.ru 6667 #Code | mIRC scripts, help, discuss, examples
Joined: Mar 2024
Posts: 7
M
Maiko Online OP
Nutrimatic drinks dispenser
OP Online
Nutrimatic drinks dispenser
M
Joined: Mar 2024
Posts: 7
Let me get back to you on that .

I am already doing that , with Google Sheets .

Joined: Jan 2012
Posts: 337
Pan-dimensional mouse
Offline
Pan-dimensional mouse
Joined: Jan 2012
Posts: 337
Ok, I became interested in finding some simple but effective way to sort data in a file, and I think I came up with something. It is assumed that the highest results will always be at the top of the list. The method is to find the closest result with a smaller number than the new number of visits of the user being checked. The script uses a loop from the first to the found row with user data, and constantly compares the number of visits in each subsequent row. If the number of visits of a user is greater than the number in the line being checked, then the record with this user will be overwritten/embedded in this line, and all subsequent records will be shifted below, after which the cycle will be stopped, otherwise the overwriting is performed in the same line in which the line with the user data was found.

I can't be completely sure that this is the best solution, since this can only be determined after long-term testing with a large number of users :-)

So, try using this script code:
Code
on *:JOIN:#test:{
  if ($read($ctfile,ntw,$nick *)) {
    var %rn $readn, %count $calc($gettok($read($ctfile,nt,%rn),2,32) + 1)
    var %i 1 | while (%i <= %rn) {
      var %lc $gettok($read($ctfile,nt,%i),2,32)
      if (%count > %lc) { write $+(-dl,%rn) $ctfile | write $+(-il,%i) $ctfile $nick %count | break }
      if (%count == %lc) || (%i == %rn) { write $+(-l,%rn) $ctfile $nick %count }
      inc %i
    }
  }
  else { write -i $ctfile $nick 1 }
}

alias -l ctfile { return channeltracker.txt }

The contents of the file "channeltracker.txt" during my testing:
Quote
PlayerC 15
PlayerA 12
PlayerD 9
PlayerB 5


🌐 https://forum.epicnet.ru 📜 irc.epicnet.ru 6667 #Code | mIRC scripts, help, discuss, examples
Joined: Mar 2024
Posts: 7
M
Maiko Online OP
Nutrimatic drinks dispenser
OP Online
Nutrimatic drinks dispenser
M
Joined: Mar 2024
Posts: 7
I'll test that version out and get back with you .

Joined: Jan 2012
Posts: 337
Pan-dimensional mouse
Offline
Pan-dimensional mouse
Joined: Jan 2012
Posts: 337
Oops, I think I forgot to add a command "break" to one of the lines of code to stop the loop from running.

Make changes to this line: if (%count == %lc) || (%i == %rn) { write $+(-l,%rn) $ctfile $nick %count | break }

This is necessary so that the loop stops, if the condition (%count == %lc) is true, thereby avoiding unnecessary checks of lines in the file.

It is assumed that when a line with the same value as the user being checked is reached, all further results in the lines of the file will be the same or even less than at the very top of the file, and since over time there can be a lot of such lines (100500+) it is necessary to stop the loop as early as possible to avoid freezing mIRC.

How correct and necessary this change is can only be determined during testing, and if it turns out to be unnecessary, it can be removed :-)


⠄⠄⠄⠄⠄⠄⠄⠄⢀⣀⣀⣀⣀⡀⠄⠄⠄⠄⠸⠿⠿⠷⡢⡀
⠄⠄⠄⠄⠄⠄⠄⢸⣿⣿⣿⡿⠿⠟⠄⠄⠄⠄⠄⠄⠄⠄⢸⡷⡄
⠄⠄⠄⠄⠄⠄⠄⠄⠉⠉⠉⡟⠦⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠧⠹⡀
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⣠⢃⣄⢟⠉⠉⠉⠉⠉⠉⠉⠉⣹⢣⢆⢣
⠄⠄⠄⢀⣤⣶⣶⣶⣦⡴⢣⠎⠄⣎⢣⠄⠄⠄⠄⠄⠄⡴⡵⠁⢘⡌⢷⣶⣶⣦⣄⡀
⠄⢀⣾⣿⠿⠋⠉⠉⡿⢡⣿⣶⡀⠈⢆⢣⡀⠄⠄⢠⢎⡼⢡⣾⣿⠿⡘⡍⠉⠛⠿⣿⣦⡀ Don't stop/break me now!
⢠⣿⡿⠁⠄⠄⠄⡜⣱⠃⠘⢿⣿⡀⠈⢦⡱⠤⢴⢡⠌⢠⣿⡿⠁⠄⢣⠸⡀⠄⠄⠘⣿⣿⡀
⢸⣿⡇⠄⠄⣞⣟⠐⠓⠒⠒⠛⠛⠓⠒⡎⠐⣒⡆⢱⠄⢸⣿⡇⠄⠄⢸⢇⢻⣣⠄⠄⢸⣿⡇
⢸⣿⣇⠄⠄⠈⠻⠛⠉⠉⠉⣽⣿⠏⠉⠑⠮⣾⣷⠊⠄⠸⣿⣧⠄⠄⠈⠻⠛⠁⠄⠄⣼⣿⠇
⠄⢻⣿⣦⣀⠄⠄⠄⢀⣠⣾⣿⠏⠄⠄⠄⠄⠄⠿⠿⠗⠄⠹⣿⣷⣄⡀⠄⠄⢀⣀⣴⣿⠟
⠄⠄⠙⠻⢿⣿⣿⣿⣿⠿⠛⠁⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠈⠛⠿⣿⣿⣿⣿⡿⠟⠉


🌐 https://forum.epicnet.ru 📜 irc.epicnet.ru 6667 #Code | mIRC scripts, help, discuss, examples

Link Copied to Clipboard