|
Joined: Sep 2015
Posts: 33
Ameglian cow
|
OP
Ameglian cow
Joined: Sep 2015
Posts: 33 |
Hi, so I have problem with point system, everytime I want to check my points my Mirc lags (don't respond for 10sec~). Maybe points.ini file size is too big? idk  on *:text:!gold:#:{
PRIVMSG $nick Tu turi $readini(Points.ini,$+(#,.,$nick),Points) tasku.
}
on !*:join:#:{
$+(.timerpoints.,#,.,$nick) 0 1800 add.pts $+(#,.,$nick)
add.pts $+(#,.,$nick)
}
on !*:part:#:$+(.timerpoints.,#,.,$nick) off
alias -l add.pts {
writeini -n Points.ini $1 Points $calc($readini(Points.ini,$1,Points) + 1)
}
|
|
|
|
Joined: Dec 2008
Posts: 1,515
Hoopy frood
|
Hoopy frood
Joined: Dec 2008
Posts: 1,515 |
How long is the points.ini database file?
|
|
|
|
Joined: Nov 2015
Posts: 14
Pikka bird
|
Pikka bird
Joined: Nov 2015
Posts: 14 |
try to make a echo with your event in the status windows. these are the steps: (change the *nameofyourchannel* and *yournick* to yours) 1.- Go to the status windows in your mirc 2.- type this: //echo -a $readini(Points.ini,$+(*nameofyourchannel*,.,*yournick*),Points) this will give you your points. Tell us if your mirc lag with this method. Nanito
|
|
|
|
Joined: Sep 2015
Posts: 33
Ameglian cow
|
OP
Ameglian cow
Joined: Sep 2015
Posts: 33 |
So I noticed that everything related to Points.ini file is lagging, for example if someone buys something with points, Mirc freezes and take some time to respond. Points.ini
|
|
|
|
Joined: Jan 2004
Posts: 1,361
Hoopy frood
|
Hoopy frood
Joined: Jan 2004
Posts: 1,361 |
You're incurring such latency because of the structure of your file. Instead of giving each user their own topic make all the entries items of a single [Points] topic, or at least a topic per channel. You can gain even more speed moving everything into hash tables. You can use this alias to import your existing file: alias points.import {
if (!$exists(Points.ini)) return
rename Points.ini Points.old.ini
filter -k Points.old.ini points.filter *
unset %prev
}
alias points.filter {
var %line = $1-
if (%line == $null) return
if ($regex(%line,^Points=(\d+))) {
var %points = $regml(1)
if ($regex(%prev,/^\[(#.+?)\.(.+?)\]/)) {
var %chan = $regml(1)
var %nick = $regml(2)
add.pts %chan %nick %points
}
}
%prev = %line
} This is the improved set of code implemented with hash tables. I've removed the line where you immediately gave people points for joining, I know in the past people have exploited this to gain points. There's a 5 second debounce on saving after points have been added, this can be changed to suit your needs or can be removed entirely to rely on the file being saved on exit. on *:text:!gold:#:{
PRIVMSG $nick Tu turi $get.pts(#,$nick) tasku.
}
on !*:join:#:$+(.timerpoints.,#,.,$nick) 0 1800 add.pts # $nick
on !*:part:#:$+(.timerpoints.,#,.,$nick) off
on *:exit:save.pts
alias -l add.pts {
var %chan = $$1, %nick = $$2, %points = $3, %table = points. $+ %chan, %file = Points.ini
noop $load.pts(%table,%file,%chan)
hinc %table %nick %points
.timeradd.pts. $+ %chan 1 5 hsave -i %table %file %chan
}
alias -l get.pts {
var %chan = $$1, %nick = $$2, %table = points. $+ %chan, %file = Points.ini
noop $load.pts(%table,%file,%chan)
return $hget(%table,%nick)
}
alias -l load.pts {
var %table = $1, %file = $2, %topic = $3
if (!$hget(%table)) {
hmake %table
hadd -m points.meta %table %topic
hsave -i points.meta %file meta
if ($ini(%file,%topic)) hload -i %table %file %topic
}
}
alias -l save.pts {
var %file = Points.ini, %i = 1
while ($hget(points.meta,%i).item) {
var %table = $v1, %topic = $hget(points.meta,%table)
hsave -i %table %file %topic
inc %i
}
}
Last edited by Loki12583; 28/12/15 08:42 PM.
|
|
|
|
Joined: Sep 2015
Posts: 33
Ameglian cow
|
OP
Ameglian cow
Joined: Sep 2015
Posts: 33 |
Second script is working, but what I need to do with first one? It doesn't transfer old points to new file. Maybe I do something wrong. New points saved in old file http://prntscr.com/9jizbb
|
|
|
|
Joined: Jan 2004
Posts: 1,361
Hoopy frood
|
Hoopy frood
Joined: Jan 2004
Posts: 1,361 |
All the scripts need to be in the same file (because of the local switch), then call /points.import from the command line. Make sure to call this only on the original Points.ini or edit the file path it's reading from.
|
|
|
|
Joined: Sep 2015
Posts: 33
Ameglian cow
|
OP
Ameglian cow
Joined: Sep 2015
Posts: 33 |
Everything works, all commands works without lag, Thanks a lot. But I have last question, is there they to delete all people who is inactive, for example people who have 1 point some period of time. And I think I need to redo this script to spend points cause Points.ini file was changed. on *:text:!permit:#:{
if ((%floodpermitas) || ($($+(%,floodpermitas.,$nick),2))) { return }
set -u1 %floodpermitas On
set -u3 %floodpermitas. $+ $nick On
var %topic = $+(#,.,$nick)
if ($readini(Points.ini,%topic,Points) >= 20) {
var %a = $v1 - 20
writeini Points.ini %topic Points %a
hadd -m $+(taskai.,#) $nick 1
msg $chan !permit $nick
}
else msg # Sry $nick , tu neturi pakankamai tasku. Tau reikia 20 tasku.
}
Last edited by Deerayn; 28/12/15 08:01 PM.
|
|
|
|
Joined: Jan 2004
Posts: 1,361
Hoopy frood
|
Hoopy frood
Joined: Jan 2004
Posts: 1,361 |
Adding a cleanup function required storing last-seen times which required a whole mess of things. I try to keep it as accurate as possible by tracking join, part, disconnect, and exit events. Right now it's set to delete anyone that hasn't been seen in 5 days time. In general to get points you use $get.pts(#,$nick) and to set use /add.pts # $nick %points. It's a bit of a misnomer but there is already support for negative points, so you can /add.pts somechan somenick -20. And if you take nothing else, note I've made a correction to the load.pts alias. on !*:join:#:{
$+(.timerpoints.,#,.,$nick) 0 1800 add.pts # $nick
set.login # $nick
}
on !*:part:#:{
$+(.timerpoints.,#,.,$nick) off
set.login # $nick
}
on me:*:join:#:{
noop $hash.load(login. $+ #,Login.ini,#)
noop $load.pts(points. $+ #,Points.ini,#)
}
on me:*:part:#:{
set.login.channel #
}
on *:disconnect:{
var %i = 1
while ($chan(%i)) {
var %chan = $v1, %table = points. $+ %chan
if ($hget(%table) != $null) {
set.login.channel %chan
}
inc %i
}
}
on *:exit:{
save.pts
}
alias clean.pts {
var %chan = $$1, %login.table = login. $+ %chan, %points.table = points. $+ %chan
var %login.file = Login.ini, %points.file = Points.ini
var %limit = 432000, %i = 1
var %threshold = $ctime - %limit
noop $hash.load(%login.table,%login.file,%chan)
noop $load.pts(%points.table,%points.file,%chan)
while ($hget(%points.table,%i).item) {
var %nick = $v1, %login = $hget(%login.table,%nick)
if (%nick ison %chan) || (%login == $null) {
set.login %chan %nick $ctime
}
elseif (%login < %threshold) {
hdel %login.table %nick
hdel %points.table %nick
}
inc %i
}
hsave -i %login.table %login.file %chan
hsave -i %points.table %points.file %chan
}
alias -l set.login {
var %chan = $$1, %nick = $$2, %time = $iif($3,$3,$ctime), %table = login. $+ %chan, %file = Login.ini
if (!$get.pts(%chan,%nick)) return
noop $hash.load(%table,%file,%chan)
hadd -m %table %nick %time
.timerset.login $+ %chan 1 5 hsave -i %table %file %chan
}
alias -l set.login.channel {
var %chan = $1, %table = login. $+ %chan, %file = Login.ini, %i = 1
while ($nick(%chan,%i)) {
set.login %chan $v1 $ctime
inc %i
}
hsave -i %table %file %chan
}
alias -l hash.load {
var %table = $1, %file = $2, %topic = $3
if (!$hget(%table)) {
hmake %table
if ($ini(%file,%topic)) hload -i %table %file %topic
}
}
alias -l add.pts {
var %chan = $$1, %nick = $$2, %points = $3, %table = points. $+ %chan, %file = Points.ini
noop $load.pts(%table,%file,%chan)
hinc %table %nick %points
.timeradd.pts. $+ %chan 1 5 hsave -i %table %file %chan
}
alias -l get.pts {
var %chan = $$1, %nick = $$2, %table = points. $+ %chan, %file = Points.ini
noop $load.pts(%table,%file,%chan)
return $hget(%table,%nick)
}
alias -l load.pts {
var %table = $1, %file = $2, %topic = $3
if (!$hget(%table)) {
hmake %table
hadd -m points.meta %table %topic
hsave -i points.meta %file meta
if ($ini(%file,%topic)) hload -i %table %file %topic
}
}
alias -l save.pts {
var %file = Points.ini, %i = 1
while ($hget(points.meta,%i).item) {
var %table = $v1, %topic = $hget(points.meta,%table)
hsave -i %table %file %topic
inc %i
}
}
|
|
|
|
Joined: Sep 2015
Posts: 33
Ameglian cow
|
OP
Ameglian cow
Joined: Sep 2015
Posts: 33 |
So I used this on *:text:!permitxxx:#:{
if (%floodpermitas || $($+(%, floodpermitas., $nick), 2)) {
return
}
set -u1 %floodpermitas On
set -u3 %floodpermitas. $+ $nick On
if ($readini(points.ini, #, $nick) >= 20) {
writeini Points.ini # $nick $calc($v1 - 20)
hadd -m $+(taskai., #) $nick 1
msg # !permit $nick
}
else {
msg # Sry $nick $+ , tu neturi pakankamai tasku. Tau reikia 20 tasku.
}
} So its little bit weird, and hard to explain, from start I was thinking everything is working, but I noticed that, then I check points with "!taskai" command its say same thing, I don't lose 20 points for using command, and points doesn't grow any more update: So I noticed that, I have 5 points, I use command "!permitxxx" (cost 5), it works, I looked up "Points.ini" file its says I have 0, and then I gain 1 point for being in chat and its says I have 6 points.
Last edited by Deerayn; 29/12/15 07:58 PM.
|
|
|
|
Joined: Jan 2004
Posts: 1,361
Hoopy frood
|
Hoopy frood
Joined: Jan 2004
Posts: 1,361 |
Do not access the ini file directly, use the hash table functions I have provided.
|
|
|
|
Joined: Sep 2015
Posts: 33
Ameglian cow
|
OP
Ameglian cow
Joined: Sep 2015
Posts: 33 |
Thanks a lot to Loki12583 And this is working script if someone will have similar problem. alias points.import {
if (!$exists(Points.ini)) return
rename Points.ini Points.old.ini
filter -k Points.old.ini points.filter *
unset %prev
}
alias points.filter {
var %line = $1-
if (%line == $null) return
if ($regex(%line,^Points=(\d+))) {
var %points = $regml(1)
if ($regex(%prev,/^\[(#.+?)\.(.+?)\]/)) {
var %chan = $regml(1)
var %nick = $regml(2)
add.pts %chan %nick %points
}
}
%prev = %line
}
on *:text:!taskai:#:{
if (%floodtaskai || $($+(%, floodtaskai., $nick), 2)) {
return
}
set -u3 %floodtaskai On
set -u45 %floodtaskai. $+ $nick On
PRIVMSG $nick Tu turi $get.pts(#,$nick) tasku.
}
on !*:join:#:{
$+(.timerpoints.,#,.,$nick) 0 1800 add.pts # $nick
set.login # $nick
}
on !*:part:#:{
$+(.timerpoints.,#,.,$nick) off
set.login # $nick
}
on me:*:join:#:{
noop $hash.load(login. $+ #,Login.ini,#)
noop $load.pts(points. $+ #,Points.ini,#)
}
on me:*:part:#:{
set.login.channel #
}
on *:disconnect:{
var %i = 1
while ($chan(%i)) {
var %chan = $v1, %table = points. $+ %chan
if ($hget(%table) != $null) {
set.login.channel %chan
}
inc %i
}
}
on *:exit:{
save.pts
}
alias clean.pts {
var %chan = $$1, %login.table = login. $+ %chan, %points.table = points. $+ %chan
var %login.file = Login.ini, %points.file = Points.ini
var %limit = 432000, %i = 1
var %threshold = $ctime - %limit
noop $hash.load(%login.table,%login.file,%chan)
noop $load.pts(%points.table,%points.file,%chan)
while ($hget(%points.table,%i).item) {
var %nick = $v1, %login = $hget(%login.table,%nick)
if (%nick ison %chan) || (%login == $null) {
set.login %chan %nick $ctime
}
elseif (%login < %threshold) {
hdel %login.table %nick
hdel %points.table %nick
}
inc %i
}
hsave -i %login.table %login.file %chan
hsave -i %points.table %points.file %chan
}
alias -l set.login {
var %chan = $$1, %nick = $$2, %time = $iif($3,$3,$ctime), %table = login. $+ %chan, %file = Login.ini
if (!$get.pts(%chan,%nick)) return
noop $hash.load(%table,%file,%chan)
hadd -m %table %nick %time
.timerset.login $+ %chan 1 5 hsave -i %table %file %chan
}
alias -l set.login.channel {
var %chan = $1, %table = login. $+ %chan, %file = Login.ini, %i = 1
while ($nick(%chan,%i)) {
set.login %chan $v1 $ctime
inc %i
}
hsave -i %table %file %chan
}
alias -l hash.load {
var %table = $1, %file = $2, %topic = $3
if (!$hget(%table)) {
hmake %table
if ($ini(%file,%topic)) hload -i %table %file %topic
}
}
alias -l add.pts {
var %chan = $$1, %nick = $$2, %points = $3, %table = points. $+ %chan, %file = Points.ini
noop $load.pts(%table,%file,%chan)
hinc %table %nick %points
.timeradd.pts. $+ %chan 1 5 hsave -i %table %file %chan
}
alias -l get.pts {
var %chan = $$1, %nick = $$2, %table = points. $+ %chan, %file = Points.ini
noop $load.pts(%table,%file,%chan)
return $hget(%table,%nick)
}
alias -l load.pts {
var %table = $1, %file = $2, %topic = $3
if (!$hget(%table)) {
hmake %table
hadd -m points.meta %table %topic
hsave -i points.meta %file meta
if ($ini(%file,%topic)) hload -i %table %file %topic
}
}
alias -l save.pts {
var %file = Points.ini, %i = 1
while ($hget(points.meta,%i).item) {
var %table = $v1, %topic = $hget(points.meta,%table)
hsave -i %table %file %topic
inc %i
}
}
on *:text:!permit:#:{
if (%floodpermitas || $($+(%, floodpermitas., $nick), 2)) {
return
}
set -u10 %floodpermitas On
set -u45 %floodpermitas. $+ $nick On
if ($get.pts(#,$nick) >= 20) {
add.pts # $nick -20)
hadd -m $+(taskai., #) $nick 1
msg # !permit $nick
}
else {
msg # Sry $nick $+ , tu neturi pakankamai tasku. Tau reikia 20 tasku.
}
}
on *:text:!pirkti permit:#:{
if (%floodpermitas2 || $($+(%, floodpermitas2., $nick), 2)) {
return
}
set -u10 %floodpermitas2 On
set -u45 %floodpermitas2. $+ $nick On
if ($get.pts(#,$nick) >= 20) {
add.pts # $nick -20)
hadd -m $+(taskai., #) $nick 1
msg # !permit $nick
}
else {
msg # Sry $nick $+ , tu neturi pakankamai tasku. Tau reikia 20 tasku.
}
}
|
|
|
|
|