mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Nov 2013
Posts: 9
N
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
N
Joined: Nov 2013
Posts: 9
Hey guys i'm trying to create a bot for my channel wih Point System, slotmachine and so on...
Now i would like to add a ranking system, therefor i wanted to use the same code as for the point system.
Every user gets a timer when they join and they get 1 point(i named it blobs, it's only for the code.) every 30 mins and when they reach 20 blobs they get a new rank but for now i only want to add the blobs to them.
I used CronkTV's Tutorial on Youtube for the point system and to get a feeling for the scripting, i will modify it in the future since i think it could be a lot easier whitout complicated topics in the .ini and so on.
There's a part i wanted to use but i cant understand how it words, he's using a command "add.pts" it's only used in the timer, nowhere else thats why i don't get it what he's doing.

I hope you could understand my explanation smile.

Now the code:

Okay, so heres the add.pts think and i dont know what it is doing.
And since i don't understand what happens there i just tried to do it my way, i thought i could just write the command after "$+(.timerpoints.,#,.,$nick) -o 0 10"
so i tried it with writeini but it only creates the Blobs section in the Ranks.ini whitout adding blobs, they are always 0.

Code:
on !*:join:#:{
  ;###PunkteSystem###
  $+(.timerpoints.,#,.,$nick) -o 0 10 add.pts $+(#,.,$nick)
  add.pts $+(#,.,$nick)
  ;###Begrüßung###
  msg $chan Hallo $nick $+ ,willkommen im Nuthouse!
  ;###Ranking###
  var %blobs $calc($readini(Ranks.ini,Blobs,$nick) + $1)
  $+(.timerpoints.,#,.,$nick) -o 0 10 (writeini -n Ranks.ini Blobs $nick %blobs) 
}
on !*:part:#:$+(.timerpoints.,#,.,$nick) off
alias -l add.pts {
  writeini -n Points.ini $1 Points $calc($readini(Points.ini,$1,Points) + 1)
}


And heres the rest of the code, maybe you need it.

Code:
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
}
alias dorempoints {
  var %topic $+($1,.,$2)
  remini -n Points.ini %topic Points
  echo -a Removed points for %topic
}
on *:text:!points:#:{
  if ((%floodpoints) || ($($+(%,floodpoints.,$nick),2))) { return }
  set -u10 %floodpoints On
  set -u30 %floodpoints. $+ $nick On
  msg # $nick hat $readini(Points.ini,n,$+($chan,.,$nick),Points) Pillen!
}
on $*:text:/!points (add|remove)/Si:#:{
  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))
}
on !*:join:#:{
  ;###PunkteSystem###
  $+(.timerpoints.,#,.,$nick) -o 0 10 add.pts $+(#,.,$nick)
  add.pts $+(#,.,$nick)
  ;###Begrüßung###
  msg $chan Hallo $nick $+ ,willkommen im Nuthouse!
  ;###Ranking###
  var %blobs $calc($readini(Ranks.ini,Blobs,$nick) + $1)
  $+(.timerpoints.,#,.,$nick) -o 0 10 (writeini -n Ranks.ini Blobs $nick %blobs) 
}
on !*:part:#:$+(.timerpoints.,#,.,$nick) off
alias -l add.pts {
  writeini -n Points.ini $1 Points $calc($readini(Points.ini,$1,Points) + 1)
}
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
  }
}
;Slotmachine#################################
on *:text:!pull:#:{
  if ((%floodpull) || ($($+(%,floodpull.,$nick),2))) { return }
  set -u10 %floodpull On
  set -u30 %floodpull. $+ $nick On
  /set %slotmachine $readini(Points.ini,n,$+($chan,.,$nick),Points)
  if ( %slotmachine <= 2) { msg $chan $nick Du brauchst mehr Pillen. | halt }
  else { 
    set %points $calc( $readini(Points.ini,n,$+($chan,.,$nick),Points) - 2 )
    /writeini -n Points.ini $+($chan,.,$nick) Points %points
    set %s1 $rand(1,3)
    set %s3 $rand(1,3)
    set %s2 $rand(1,3)
    /msg $chan $nick Pulls the Slot.. 
    /msg $chan %s1 - %s2 - %s3
  }
  if ( %s1 == %s2 ) && ( %s2 == %s3 ) {  
    set %tokenwin $rand(1,20)
    msg $chan Du gewinnst %tokenwin Pillen!       
    set %points $calc( $readini(Points.ini,n,$+($chan,.,$nick),Points) + %tokenwin )
    /writeini -n Points.ini $+($chan,.,$nick) Points %points
  }
}


Thank you very much!

Joined: Nov 2013
Posts: 9
N
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
N
Joined: Nov 2013
Posts: 9
OKay tried another way.

Code:
alias doaddblobs {
  if ($1 !isnum) { echo 2 -st $1 is not a number. It needs to be a number. | halt }
  var %blobs $calc($readini(Ranks.ini,Blobs,$nick) + $1)
  writeini -n Ranks.ini Blobs $nick %blobs
}
on !*:join:#:{
  ;###Ranking###
  timer $+ $nick -o 0 10 doaddblobs 1
}


What's wrong here ? I get this Error * "/writeini: insufficient parameters" but i cant figure out why i get this msg.

Last edited by NuthouseOfGaming; 16/11/13 03:25 PM.
Joined: Feb 2003
Posts: 3,432
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
Try debug your code, do $nick have a value, same goes for %blobs ?


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
Joined: Jul 2006
Posts: 4,144
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,144
It's certain that $nick doesn't have a value, you're calling the alias with a timer, local identifier such as $nick are lost there. You need to pass the $nick value as a parameter somehow, but a nice way to do it here is to use $ctimer, replace $nick by $ctimer in your alias and it should work.
Note that you may change the timer name in the future, which would break it, the typical way of handling it is to pass the nickname as a parameter of the alias.


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Nov 2013
Posts: 9
N
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
N
Joined: Nov 2013
Posts: 9
Thank you very much guys, this helped me a lot and it works now with $ctimer but is it possible that you give me an example on how to pass a parameter to an alias ? i found nothing with google and the only thing i could imagine was doaddblobs($nick) but thats probably completely wrong.

Is it possible to have more then one timer per $nick ?

For example :

timer $+ $nick -0 0 10 doaddpoints $chan $nick 1
timer $+ $nick -0 0 60 doaddblobs $chan $nick 1

Thank you.

Last edited by NuthouseOfGaming; 16/11/13 06:03 PM.
Joined: Oct 2012
Posts: 164
D
Vogon poet
Offline
Vogon poet
D
Joined: Oct 2012
Posts: 164
Originally Posted By: NuthouseOfGaming
Is it possible to have more then one timer per $nick?
Yes, but each timer must have a unique name.
$+(.timerpoints.,#,.,$nick)
$+(.timerblobs.,$nick)

Originally Posted By: NuthouseOfGaming
is it possible that you give me an example on how to pass a parameter to an alias ?
Pass parameters the same way as in the add.pts timer...

TimerName
Switches Repetitions Frequency command/alias parameter(s)
$+(.timerpoints.,#,.,$nick) -o 0 10 add.pts $+(#,.,$nick)
$+(.timerblobs.,$nick) -o 0 60 add.blobs $nick

Your original code modified as so...
Code:
on !*:join:#:{
  ;###PunkteSystem###
  $+(.timerpoints.,#,.,$nick) -o 0 10 add.pts $+(#,.,$nick)
  add.pts $+(#,.,$nick)
  ;###Begrüßung###
  msg $chan Hallo $nick $+ ,willkommen im Nuthouse!
  ;###Ranking###
  $+(.timerblobs.,$nick) -o 0 60 add.blobs $nick
}
on !*:part:#:{
  $+(.timerpoints.,#,.,$nick) off
  $+(.timerblobs.,$nick) off
}
alias -l add.pts {
  writeini -n Points.ini $1 Points $calc($readini(Points.ini,$1,Points) + 1)
}
alias -l add.blobs {
  writeini -n Ranks.ini Blobs $1 $calc($readini(Ranks.ini,Blobs,$1) + 1)
}
See that the part event now also halts the blobs timer.

Note also that this way $ctimer will NOT return the parameter you want ('nick') but will now return "blobs.nick"


Joined: Nov 2013
Posts: 9
N
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
N
Joined: Nov 2013
Posts: 9
Thank you guys.
This was all i need and i think i understand it now laugh.
Deega thanks for the example...
You also helped CronkTV with his code but i never understood what this add.pts means since there was no alias called add.pts only an addPoints alias.

Joined: Nov 2013
Posts: 9
N
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
N
Joined: Nov 2013
Posts: 9
Okay another Question related to timers.

I modified the script a lot now and every person in the channel gets a free pull on the slotmachine after 60mins.
Okay so they type !free amd when 60mins are over they get a free pull otherwise it just tells them that they have no more free pulls but it would be a lot better if they know how long it will take for the next free pull.

So all i want is to msg the remaining time of a timer.

I found the $timer and time command so if we have a timer called timerpoints it would be "$timer(points).time", correct ?

But now i have timers for every single person for example timerpoints.$nick how can i get the time for one of this kind?

$+($timer(points),.,$nick).time ?
$+($timer(points,.,$nick)).time ?
$timer(points).$nick.time ?

Found no solution yet, hope you guys can help me. Thank you!

Joined: Aug 2013
Posts: 81
I
Babel fish
Offline
Babel fish
I
Joined: Aug 2013
Posts: 81
$timer(points. $+ $nick).time

Joined: Oct 2012
Posts: 164
D
Vogon poet
Offline
Vogon poet
D
Joined: Oct 2012
Posts: 164
You probably want the .secs property rather than .time

$timer(points. $+ $nick).secs
$timer($+(points.,$nick)).secs


//.timertest 23:59 1 20 !
$timer(test).time will return 23:59

Joined: Nov 2013
Posts: 9
N
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
N
Joined: Nov 2013
Posts: 9
Thanks!

You are absolutely right!
I need .secs i misunderstood .timer.
I'll have to divide with 60 then to get the minutes left.
Thanks again!

Joined: Oct 2012
Posts: 164
D
Vogon poet
Offline
Vogon poet
D
Joined: Oct 2012
Posts: 164
Originally Posted By: NuthouseOfGaming

I'll have to divide with 60 then to get the minutes left.


Or use $duration() smile

$duration($timer(name).secs)
$duration($timer(name).secs,3)

Joined: Nov 2013
Posts: 9
N
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
N
Joined: Nov 2013
Posts: 9
Sounds a lot easier.
Thank you for your amazing help Deega!

Last edited by NuthouseOfGaming; 21/11/13 04:00 PM.

Link Copied to Clipboard