|
Joined: Apr 2014
Posts: 19
Pikka bird
|
OP
Pikka bird
Joined: Apr 2014
Posts: 19 |
I'm really new to this stuff and I was hoping someone could help me with this. I was hoping there was a script to display who has the top 10 points for the point system I have setup. Also, it would be greatly appreciated if it could be set so that only I can use it.
This is what I have setup so far:
alias -l addPoints { if ($1 !isnum) { echo 2 -st $1 is not a number. It needs to be a number. | halt } var %topic $+($chan,.,$nick) var %points $calc($readini(Points.ini,%topic,Points) + $1) writeini -n Points.ini %topic Points %points return %points }
alias -l lookUpPoints { var %topic $+($chan,.,$nick) var %points $readini(Points.ini,%topic,Points) return %points } alias doaddpoints { if ($3 !isnum) { echo 2 -st $3 is not a number. It needs to be a number. | halt } var %topic $+($1,.,$2) var %points $calc($readini(Points.ini,%topic,Points) + $3) writeini -n Points.ini %topic Points %points echo -a Added points for %topic }
alias dorempoints { var %topic $+($1,.,$2) remini -n Points.ini %topic Points echo -a Removed points for %topic }
on *:text:!stars:#:{ if ((%floodstars) || ($($+(%,floodstars.,$nick),2))) { return } set -u10 %floodstars On set -u30 %floodstars. $+ $nick On msg # $nick has $readini(Points.ini,$+(#,.,$nick),Points) Ninja Stars! } on $*:text:/!stars (add|remove)/Si:#uminokaiju:{ if ($nick isop #) { if ($0 < 3) { msg # Insufficient parameters: Use !points <add|remove> <user> [number] | return } writeini -n Points.ini $+(#,.,$3) Points $calc($readini(Points.ini,$+(#,.,$3),Points) $iif($2 == add,+,-) $iif($4 isnum,$4,1)) { msg $chan $3 now has $readini(Points.ini,$+(#,.,$3),Points) Ninja Stars! } } else { msg $chan This command is only available to Rapid and Holly. } } on !*:join:#uminokaiju:{ $+(.timerpoints.,#,.,$nick) 0 60 add.pts $+(#,.,$nick) add.pts $+(#,.,$nick) } raw 366:*:{ var %i = 1 while ($timer(%i)) { if ($+(points.,$2,.,*) iswm $v1) { var %a = $v2 if ($gettok(%a,-1,46) !ison $2) { .timer $+ %a off | continue } } inc %i } } on !*:part:#uminokaiju:$+(.timerpoints.,#,.,$nick) off alias -l add.pts { writeini -n Points.ini $1 Points $calc($readini(Points.ini,$1,Points) + 1) } on *:text:!check *:#:{ if ($nick isop #) { if ((%floodcheck) || ($($+(%,floodcheck.,$2),2))) { return } set -u10 %floodcheck On set -u30 %floodcheck. $+ $nick On msg # $2 has $readini(Points.ini,$+(#,.,$2),Points) Ninja Stars! } if ($nick !isop #) { msg $chan $nick -> You don't have permission to do that, Sorry. } }
|
|
|
|
Joined: Apr 2014
Posts: 191
Vogon poet
|
Vogon poet
Joined: Apr 2014
Posts: 191 |
This is how i do it. Change YOURNICKHERE with your nick. Use: !top10 to show the result.
on *:TEXT:!top10:#:{
if $nick == YOURNICKHERE { top10 # }
else { msg # You are not allowed to use !top10. }
}
alias -l top10 {
window -h @. | var %i 1
while $gettok($remove($read(points.ini,w,$+(*,$1,*),%i),[,]),2,46) {
var %n $v1, %p $gettok($read(points.ini,$calc($readn + 1)),2,61)
aline @. %n %p
var %i $calc($readn + 1)
}
filter -cetuww 2 32 @. @.
var %i 1 | while %i <= 10 {
var %list $addtok(%list,$line(@.,%i),44)
inc %i
}
msg $1 Top 10 point are: $replace(%list,$chr(44),$+($chr(44),$chr(32)))
window -c @.
}
|
|
|
|
Joined: Apr 2014
Posts: 191
Vogon poet
|
Vogon poet
Joined: Apr 2014
Posts: 191 |
As i can see, you run the bot in 17 channels. Points.ini would be contains huge data, so yes, it may crashes mIRC.
Previously, i tested it with dummy points.ini that contains only 50 data and it works fine. After you said it crashes mIRC, i tested it again with 1000 data and it crashes.
I cant figured out better way unless you using other code that has better structure. Imo, point system that you've using now storing data with bad structure. It is difficult to manage.
|
|
|
|
Joined: Jul 2006
Posts: 4,222
Hoopy frood
|
Hoopy frood
Joined: Jul 2006
Posts: 4,222 |
Can you both clarify if mIRC is crashing (this means mirc.exe is closed) or if mIRC is freezing (the program is unresponsive with "not responding" in the titlebar) mIRC crashing would be a bug, freezing would be normal.
edit: I should have looked at the screenshot, it's not a crash but a freeze. the code is using filter which is great, however in order for /filter to work, it needs a nicely formatted data, which doesn't exist prior the top10. You create that nicely formatted data with @. but for that you're using a while loop, that loop is very slow.
Last edited by Wims; 30/04/14 09:06 AM.
#mircscripting @ irc.swiftirc.net == the best mIRC help channel
|
|
|
|
Joined: Apr 2014
Posts: 191
Vogon poet
|
Vogon poet
Joined: Apr 2014
Posts: 191 |
It is freezing because script proccess huge data and takes time. with 1000 data, it takes about 32secs to complete.
|
|
|
|
Joined: Apr 2014
Posts: 18
Pikka bird
|
Pikka bird
Joined: Apr 2014
Posts: 18 |
Hey blessing, i saw your answer in this thread sadly too late  perhaps you can change your script a little that it can read my .ini too I have a ".ini" file for my coins, it save the "money" like this: [Nickname1]
Money=100
[Nickname2]
Money=299
[Nickname3]
Money=500
[Nickname4]
Money=387
[Nickname5]
Money=120 I changed the script as far as i could do! ^^on *:TEXT:!top5:#:{
top5 #
}
alias -l top5 {
window -h @. | var %i 1
while $gettok($remove($read(Casino.ini,w,$+(*,$1,*),%i),[,]),2,46) {
var %n $v1, %p $gettok($read(Casino.ini,$calc($readn + 1)),2,61)
aline @. %n %p
var %i $calc($readn + 1)
}
filter -cetuww 2 32 @. @.
var %i 1 | while %i <= 5 {
var %list $addtok(%list,$line(@.,%i),44)
inc %i
}
msg $1 Top 5: $replace(%list,$chr(44),$+($chr(44),$chr(32)))
window -c @.
} But i dont know what i have to change exactly to read my points!  Would be awesome.
Last edited by Kawalli; 30/04/14 09:07 AM.
|
|
|
|
Joined: Jul 2006
Posts: 4,222
Hoopy frood
|
Hoopy frood
Joined: Jul 2006
Posts: 4,222 |
Yeah, I edited my post, that's because of your loop, which is poorly written because of how the data is (poorly too) initially stored, but still you should be using $readini and $ini and not $read Using: while $ini(points.ini,%i) {
if ($1.* iswm $v1) {
aline @. $gettok($v2,-1,46) $readini(points.ini,$v2,points)
}
inc %i
} should be much much much much faster
Last edited by Wims; 30/04/14 09:40 AM.
#mircscripting @ irc.swiftirc.net == the best mIRC help channel
|
|
|
|
Joined: Apr 2014
Posts: 191
Vogon poet
|
Vogon poet
Joined: Apr 2014
Posts: 191 |
Thank you but output needs to be filtered by channelname. i dont see it on your code. Also data need to be sorted is item, not section of .ini How to do that in fastest way with that structure of .ini file.
Last edited by blessing; 30/04/14 09:25 AM.
|
|
|
|
Joined: Jul 2006
Posts: 4,222
Hoopy frood
|
Hoopy frood
Joined: Jul 2006
Posts: 4,222 |
I edited the code, forgot to filter out the channel, $readini read the data, not the item, $ini can be used to find all sections/items If you want the fastest, you could try to use /filter (with -k) for that too, which would read the file faster, but you would have to match something like [*] to grab all the sections first, then use $readini(file,<matched_section>,points) anyway
edit: something like:
//filter -kgff points.ini mycallback /^\[ $+ $1.+\..+\]$/ alias mycallback aline @. $left($gettok($1-,-1,46),-1) $readini(points.ini,$1-,points)
Last edited by Wims; 30/04/14 09:40 AM.
#mircscripting @ irc.swiftirc.net == the best mIRC help channel
|
|
|
|
Joined: Jul 2006
Posts: 4,222
Hoopy frood
|
Hoopy frood
Joined: Jul 2006
Posts: 4,222 |
You only need to change the loop that is reading the file, since you don't have channel name involved, it's easier: while $ini(points.ini,%i) {
aline @. $v1 $readini(points.ini,$v1,money)
inc %i
}
#mircscripting @ irc.swiftirc.net == the best mIRC help channel
|
|
|
|
Joined: Apr 2014
Posts: 191
Vogon poet
|
Vogon poet
Joined: Apr 2014
Posts: 191 |
Well done. thank you Wims. Proper code should be like this. Tested with 3000 data and takes 3-4secs to complete. much faster than my previous code.
on *:TEXT:!top10:#:{
if $nick == YOURNICKHERE { top10 # }
else { msg # You are not allowed to use !top10. }
}
alias top10 {
window -h @. | var %i 1
while $ini(points.ini,%i) {
var %n $v1
if ($+(*,$1,*) iswm %n) {
aline @. $gettok($remove(%n,[,]),2,46) $readini(points.ini,%n,points)
}
inc %i
}
filter -cetuww 2 32 @. @.
var %i 1 | while %i <= 10 {
var %list $addtok(%list,$line(@.,%i),44)
inc %i
}
msg $1 Top 10 point are: $replace(%list,$chr(44),$+($chr(44),$chr(32)))
window -c @.
}
|
|
|
|
Joined: Jul 2006
Posts: 4,222
Hoopy frood
|
Hoopy frood
Joined: Jul 2006
Posts: 4,222 |
I edited my code later but $gettok(,2,46) is wrong, should be -1 for N because channel name can have dot in their name. $+(*,$1,*) is also not the best, you do know the section's name start with the channel so puttin that * in front is just making it slower, if ($1* iswm %n) is just better and faster (could be $1 $+ * is you want, but you can stick anything to $N identifiers as long as it's not a '-' or a number), the less you evaluate, the fastest it is. $ini returns the name of the section without the [ ], which are just symbols used as a syntax for parsing, you don't need to remove them from %n Using a variable here is fine (%n), but not using it like I did is just going to be faster, you can rely on $v1 and $v2 as a way not to lose the value
Last edited by Wims; 30/04/14 09:59 AM.
#mircscripting @ irc.swiftirc.net == the best mIRC help channel
|
|
|
|
Joined: Apr 2014
Posts: 191
Vogon poet
|
Vogon poet
Joined: Apr 2014
Posts: 191 |
Thank you Wims. I can edit it right away, but I think i would leave it as it is so other can learn from it.
|
|
|
|
Joined: Apr 2014
Posts: 18
Pikka bird
|
Pikka bird
Joined: Apr 2014
Posts: 18 |
Hmm i dont get it work with that code, the bot didnt send a message: on *:TEXT:!top5:#:{
top10 #
}
alias top10 {
window -h @. | var %i 1
while $ini(casino.ini,%i) {
aline @. $v1 $readini(casino.ini,$v1,money)
inc %i
}
filter -cetuww 2 32 @. @.
var %i 1 | while %i <= 5 {
var %list $addtok(%list,$line(@.,%i),44)
inc %i
}
echo -agt msg # Top 5: $replace(%list,$chr(44),$+($chr(44),$chr(32)))
window -c @.
} I have no channel name into my .ini file! Only:
Last edited by Kawalli; 30/04/14 10:28 AM.
|
|
|
|
Joined: Apr 2014
Posts: 191
Vogon poet
|
Vogon poet
Joined: Apr 2014
Posts: 191 |
I forgot to remove echo -agt from the code while i tested it. It should be: msg $1 Top 5: $replace(%list,$chr(44),$+($chr(44),$chr(32)))
|
|
|
|
Joined: Apr 2014
Posts: 18
Pikka bird
|
Pikka bird
Joined: Apr 2014
Posts: 18 |
Aaaaand its working Thanks!
|
|
|
|
Joined: Feb 2015
Posts: 2
Bowl of petunias
|
Bowl of petunias
Joined: Feb 2015
Posts: 2 |
Can u help me maybe with top10 script ?  Sorry its dont work at me :\ My Points.ini looks like this. [#myChannel] 1234mrt=0 aethersprite1710=166 amphetamintv=185 austriasabrina=62 avyn86=4 backiie=14 bender21888=8 bosco4u=4 chickohd=166 chuckymo=0 cokemaster_exe=2 cptpiccolo=0 craftidog2000=4 crckdns=50 Regards Chris
|
|
|
|
Joined: Dec 2008
Posts: 1,515
Hoopy frood
|
Hoopy frood
Joined: Dec 2008
Posts: 1,515 |
As Wims have post above use this code, create a new file on your mirc bot on "Remotes" tab and paste this code: on *:TEXT:!top10:#:{ run_top10 # }
alias run_top10 {
window -h @. | var %i 1
while $ini(points.ini,%i) {
var %n $v1
if ($+(*,$1,*) iswm %n) {
aline @. $gettok($remove(%n,[,]),2,46) $readini(points.ini,%n,points)
}
inc %i
}
filter -cetuww 2 32 @. @.
var %i 1 | while %i <= 10 {
var %list $addtok(%list,$line(@.,%i),44)
inc %i
}
msg $1 Top 10 point are: $replace(%list,$chr(44),$+($chr(44),$chr(32)))
window -c @.
}
Last edited by westor; 10/02/15 02:22 PM.
|
|
|
|
Joined: Feb 2015
Posts: 2
Bowl of petunias
|
Bowl of petunias
Joined: Feb 2015
Posts: 2 |
this dont work at me... look (*.ini,%n,points) (* is my) but he cant read it... i do it to (*.ini,$1,%n)
but the bot cant read it :\
|
|
|
|
|