mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Apr 2014
Posts: 170
Bramzee Offline OP
Vogon poet
OP Offline
Vogon poet
Joined: Apr 2014
Posts: 170
I have a script for points (common one found on the forums) and I basically have been trying to add a part in for people that are on the "regulars list" to earn a few more points than the normal viewers. I'll post what I believe is where the code should be added in and then my entire script. Any help and/or suggestions are, as always, VERY much appreciated.

add points alias (where I believe should be where it's added in)

Code:
alias -l add.pts {
  if %point.off { return } { 
    writeini -n Points.ini $1 Points $calc($readini(Points.ini,$1,Points) + 1)
  }
  if ($read(reglist.txt,nw,$nick)) {
  writeini -n Points.ini $1 Points $calc($readini(Points.ini,$1,Points) +4) } 
}


This still only add's 1 point to people on the regs list. I've also tried with the "if ($read(reglist.txt,nw,$nick))" portion above the first "writeini" That still only added 1 point.

Entire points script:

Code:
alias -l add.pts {
  if %point.off { return } { 
    writeini -n Points.ini $1 Points $calc($readini(Points.ini,$1,Points) + 1)
  }
  if ($read(reglist.txt,nw,$nick)) {
  writeini -n Points.ini $1 Points $calc($readini(Points.ini,$1,Points) +4) } 
}
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:/^!points (on|off)/:#:{
  if $nick != mynickhere { return }
  if $2 == off { 
    set -e %point.off 1 
    msg # The ability to earn points is no longer available! 
  }
  else { 
    unset %point.off 
    msg # Points are now available to earn! 
  }
}

on *:text:!pointcheck:#:{
  if ((%floodpointcheck) || ($($+(%,floodpointcheck.,$nick),2))) { return }
  set -u10 %floodpointcheck On
  set -u30 %floodpointcheck. $+ $nick On
  msg # $nick you have $readini(Points.ini,$+(#,.,$nick),Points) total points.
}

on *:text:!pointcheck *:#:{
  if ((%floodcheck) || ($($+(%,floodcheck.,$2),2))) { return }
  set -u10 %floodcheck On
  set -u30 %floodcheck. $+ $nick On 
  msg # $2 has $readini(Points.ini,$+(#,.,$2),Points) total points. 
}

on $*:text:/!points (add|remove)/Si:#:{
  if ($nick == mynickhere) {
    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) total points. }
  }
  else { msg $chan This command is only available to the owner of this channel. }
}
on !*:join:#:{
  $+(.timerpoints.,#,.,$nick) 0 300 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: May 2014
Posts: 13
S
Pikka bird
Offline
Pikka bird
S
Joined: May 2014
Posts: 13
I believe the problem is here:

Code:
if ($read(reglist.txt,nw,$nick)) {
  writeini -n Points.ini $1 Points $calc($readini(Points.ini,$1,Points) +4) } 


should be

Code:
if ($read(reglist.txt,nw,$1)) {
  writeini -n Points.ini $1 Points $calc($readini(Points.ini,$1,Points) +4) } 


haven't tested it, though.

Last edited by Shakar; 06/05/14 12:57 AM.
Joined: Apr 2014
Posts: 170
Bramzee Offline OP
Vogon poet
OP Offline
Vogon poet
Joined: Apr 2014
Posts: 170
Thanks for the suggestion Shakar. However it still only gave one point to them smirk

Joined: Apr 2014
Posts: 191
B
Vogon poet
Offline
Vogon poet
B
Joined: Apr 2014
Posts: 191
As you can see, you have 2 add.pts aliases in your script. You may need to remove one of them.

And for the alias, it should be like this:
Code:
alias -l add.pts {
  if %point.off { return } 
  if ($read(reglist.txt,nw,$gettok($1,-1,46))) {
    writeini -n Points.ini $1 Points $calc($readini(Points.ini,$1,Points) + 4) 
  } 
  else {
    writeini -n Points.ini $1 Points $calc($readini(Points.ini,$1,Points) + 1)
  }
}

Joined: Apr 2014
Posts: 170
Bramzee Offline OP
Vogon poet
OP Offline
Vogon poet
Joined: Apr 2014
Posts: 170
worked, thank you very much... If you wouldn't mind explaining the "if ($read(reglist.txt,nw,$gettok($1,-1,46)))" a bit? I just enjoy learning and would like to know mainly what the ($1,-1,46) means. Thanks again for helping me out smile

Joined: Jan 2004
Posts: 1,358
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,358
Then /help $gettok and /help $read

Joined: Apr 2014
Posts: 191
B
Vogon poet
Offline
Vogon poet
B
Joined: Apr 2014
Posts: 191
As you already know, value of $1 that passed to add.pts alias is $+(#,.,$nick).
If # is #channel and $nick is nickname, then $1 will be #channel.nickname.
If you use $read(reglist.txt,nw,$nick), it will return $null because $nick itself is not passed to add.pts alias.
If you use $read(reglist.txt,nw,$1), it will return $null as well because #channel.nickname is not exists in reglist.txt. reglist.txt contains only nickname list.

So we need to use $gettok(string,N,C) to 'catch' the nickname from #channel.nickname.
$gettok() is token identifier. Token is a string that separated by any single unique character.

As you can see string #channel.nickname is separated by dot(.) as a single unique character.
So if you //echo $gettok(#channel.nickname,1,46) you will get #channel as token 1, and //echo $gettok(#channel.nickname,2,46) you will get nickname as token 2.
Why not use $gettok(#channel.nickname,2,.)? Because mSL by design use ascii value of dot(.) which is 46 instead of character itself.
You can find out ascii value using //echo $asc(.)

So to catch nickname from $1, we use $gettok($1,2,46) or $gettok($1,-1,46).
If you use positive value for N, it will catch token from left to right. Negative value will catch token from right to left.

I don't use $gettok($1,2,46) because #channelname can has dot(.) as part of channelname.
For example, if your channelname is #cool.bramzee then $1 will be #cool.bramzee.nickname.
$gettok($1,2,46) will return bramzee as token 2 which is giving wrong result.
So use $gettok($1,-1,46) will be better for your case.

You may want to read help file /help $gettok or google "$gettok mirc tutorial" to understand better.


Joined: Apr 2014
Posts: 170
Bramzee Offline OP
Vogon poet
OP Offline
Vogon poet
Joined: Apr 2014
Posts: 170
Thanks for the explanation smile And I will definitely google it some more.


Link Copied to Clipboard