mIRC Home    About    Download    Register    News    Help

Print Thread
#250591 22/01/15 08:49 PM
Joined: Jan 2015
Posts: 12
T
Pikka bird
OP Offline
Pikka bird
T
Joined: Jan 2015
Posts: 12
Hi guys, I'm using a points system for my twitch channel and I wanted to create a command that can show viewers who have the most points. So I created a command called !toppoints and it's working fine. However, I really really don't like how I coded it and I would like to know how I can improve the code so I can specify a number to the command. Ex: !toppoints 5 (Will display the 5 viewers who have the most points)

Goals:
  • Cleanup the code
  • Add a number parameter so the code can be more flexible

Thanks for any of your help! smile

Code

Joined: Sep 2014
Posts: 259
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Sep 2014
Posts: 259
You probably need a bunch of while loops, for example for the dynamic number of variables.

Code:
if ($2 isnum) {
var %i = 1
while (%i <= $2) {
var %max $+ %i = 0
var %name $+ %i = unknown
inc i%
  } 
}

Joined: Jan 2015
Posts: 12
T
Pikka bird
OP Offline
Pikka bird
T
Joined: Jan 2015
Posts: 12
Thanks for your reply, I'll try to change the code! I'll post an update when it will be done!

Joined: Jan 2015
Posts: 12
T
Pikka bird
OP Offline
Pikka bird
T
Joined: Jan 2015
Posts: 12
I tried to create a new code with the information you gave me but without success... I don't understand how I can use these variables. When I try to output them, I only see the value of %i and not all the 0 that were initialize with.

Thanks for your help!

Joined: Sep 2014
Posts: 259
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Sep 2014
Posts: 259
There were some mistakes in that, this should work

Code:
  if ($2 isnum) && ($2 < 50) {

    var %i = 1
    while (%i <= $2) {
      var %name [ $+ [ %i ] ] unknown
      var %max [ $+ [ %i ] ] 0
      inc %i    
    } 
 }

Joined: Jan 2015
Posts: 12
T
Pikka bird
OP Offline
Pikka bird
T
Joined: Jan 2015
Posts: 12
It is now working! Thanks a lot for your help smile

Code is available for those who wants it : Code

Last edited by Trahanqc; 24/01/15 12:43 AM. Reason: Added code link

Link Copied to Clipboard