mIRC Home    About    Download    Register    News    Help

Print Thread
#152230 28/06/06 10:27 PM
Joined: Jun 2006
Posts: 6
M
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
M
Joined: Jun 2006
Posts: 6
Code:
 on *:TEXT:!vote*:#: {
  if ($gettok(%daynight,1,32) == day) {
    var %x %plyrs
    while (%x > 0) {
      if ($nick == $gettok([ % $+ plyr $+ [ %x ] ],1,32)) {
        var %y %plyrs
        while (%y > 0) {
          if ($1 == $gettok([ % $+ [ plyr $+ [ %y ] ] ],1,32)) {
            msg $chan got to here
            $puttok([ % $+ plyr $+ [ %x ] ],$1,4,32)
            var %votes $gettok([ % $+ plyr $+ [ %y ] ],5,32)
            var %v $calc($gettok(%votes,1,46) + 1)
            var %votes $puttok(%votes,%v,1,46)
            var %votes $addtok(%votes,$nick,46)
            $puttok([ % $+ plyr $+ [ %y ] ],%votes,5,32)
          }
          dec %y 1
        }
      }
      dec %x 1
    }
  }
}
 

I was worried id mess up the syntax if I put all the token stuff in the middle on one line so I broke it up with local variables (I haven't tested it yet), but thats not my problem. I've narrowed it down to this line:
if ($1 == $gettok([ % $+ [ plyr $+ [ %y ] ] ],1,32))
This should compare the parameter with the first tok in %plyrY (whick would be someones nick). It doesnt return true though. I get:

* /if: insufficient parameters (line 86, script.ini)

I've tried using $+() $(,2) and various bracket combinations so I'm confused.

Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
A few things that I noticed:
1) Your variable assignments are missing the = sign.
2) You're comparing $1, which in the on text event will always bring back the command (in this case !vote)
3) your $puttok line is incorrectly configured, as you don't specify a variable name for the results of the puttok to be stored in.

Not an error, but my own preference (I find it easier to read), use $+(%,plyr,%x) in place of [ % $+ plyr $+ [ %x ] ]

Fix up the errors I listed above, then try your code again.

Joined: Jun 2006
Posts: 6
M
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
M
Joined: Jun 2006
Posts: 6
Thanks it works fine now. And variable assigments don't need the =.

Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
OK.. I wasn't aware that local variables could be set properly without the = sign. I know that global variables don't require it.

In any case, I'm glad you got the problem(s) resolved.

Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Ok sorry i thought the quick demo with $( ,2) and $+() would have been enough so heres how to use them
in your case you have variables named %plyr1 %plyr2 %plyr3, so you tring to access %plyrN N being a number from 1 to 3

The method to do that using [ ] is this %plyr [ $+ [ %n ] ] this however isnt the real method your ment to use, you have been using order of evalaton brakets to side step mircs normal phasing of a line.
The real method is something like this
step 1 create the varaible name using $+ its % $+ plyr $+ %n or using $+() its $+(%,plyr,%n), so now that makes you the variable name.
step2 (use only if u need the contents of the variable) then u add around it $( ,2) ie: $( $+(%,plyr,%n) ,2) this is needed to tell mirc evaluate this twice, once to make the var name then again to read the contents of the var.
example of where to use step2 and where not to
//set $+(%,plyr,%n) DaveC not needed
//echo -a $( $+(%,plyr,%n) ,2) needed

*one last thing the % and the plyr they must be joined up seperatly, becuase if you said $+(%plyr,%n) its gonna look inside a var named %plyr and a var named %n, and since %plyr is likely nothing your gonna end up with just %n's value




Ok onto your code
your problem line
if ($nick == $gettok([ % $+ plyr $+ [ %x ] ],1,32)) {
replace with
if ($nick == $gettok($($+(%,plyr,%x),2),1,32)) {


Now a however
Even if u made it into the IF yor gionna have real problems, you cant put a $puttok on a line on its own that value needs to be assigned to something


PS: using VAR without a = is just gonna cause u problems sooner or later, becuase it DOES NOT always work, but using VAR and = DOES always work


Link Copied to Clipboard