mIRC Home    About    Download    Register    News    Help

Print Thread
script ignoring variables #152194 28/06/06 07:30 AM
Joined: Jun 2006
Posts: 6
M
Matjoeman Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
M
Joined: Jun 2006
Posts: 6
Code:
  on *:TEXT:!mmafia out:#:{
  var %x
  if (%plyr1 == $nick) set %x 1
  else if (%plyr2 == $nick) set %x 2
  else if (%plyr3 == $nick) set %x 3
  while (%x < 3) {
    set [ % $+ plyr $+ [ %x ] ] [ % $+ plyr $+ $calc(%x + 1) ]
    inc %x
  }
  set [ % $+ plyr $+ [ %x ] ] none
  notice $nick You are no longer signed up.
  dec %plyrs
}

%plyr1 %plyr2 and %plyr3 should have a string value equal to someones nick or none. whenever someone with a nick equal to one of em types !mmafia out, it'll remove them from the list and cascade any one above them down. So it should output:
(assuming it was plyr1 who typed !mmafia out)
%plyr1 (whatever %plyr2 was)
%plyr2 (whatever %plyr3 was)
%plyr3 none
for some reason the set line in the loop sets it as just %x + 1 so i get:

%plyr1 2
%plyr2 3
%plyr3 none

I've tried lots of bracket combinations and various $+ arrangements and i still get same results. I think the same problem is occuring in this line:

Code:
  notice [ % $+ plyr $+ [ %x ] ] You are mafia.


which sends the notice to whatever X is.

Re: script ignoring variables #152195 28/06/06 07:57 AM
Joined: Sep 2003
Posts: 4,230
D
DaveC Offline
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
heres code that should work, I dont use [ ] becuase they are really for something else, i use $+( ) to conenct the needed parts, and $( ,2) to evaluate to the vars contents
I was also a bit concerned about you switching from var %x to set %x which i wasnt sure if its going to use the local var one or the global set one, when accessing %x
Lastly i added a else { return } becuase u dont want to do the rest if the $nick doing the line isnt in the game at all.

Code:
on *:TEXT:!mmafia out:#:{
  var %x
  if (%plyr1 == $nick) { var %x = 1 }
  elseif (%plyr2 == $nick) { var %x = 2 }
  elseif (%plyr3 == $nick) { var %x = 3 }
  else { return }
  while (%x < 3) {
    set $+(%,plyr,%x) $($+(%,plyr,$calc(%x + 1)),2)
    inc %x
  }
  set $+(%,plyr,%x) none
  notice $nick You are no longer signed up.
  dec %plyrs
}

However considering your just using 3 players, i would hardcode the changes.
Code:
  on *:TEXT:!mmafia out:#:{
  if (%plyr1 == $nick) { set %plyr1 %plyr2 | set %plyr2 %plyr3 | set %plyr3 none }
  elseif (%plyr2 == $nick) { set %plyr2 %plyr3 | set %plyr3 none }
  elseif (%plyr3 == $nick) { set %plyr3 none }
  else { return }
  notice $nick You are no longer signed up.
  dec %plyrs
}

Re: script ignoring variables #152196 28/06/06 08:25 AM
Joined: Jun 2006
Posts: 6
M
Matjoeman Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
M
Joined: Jun 2006
Posts: 6
I added the $($+(%,plyr,$calc(%x + 1)),2) part and it worked, but what does $(,2) do? and I'm not going to hard code it, because as soon as I get it all working I'll increase the player support.

Re: script ignoring variables #152197 28/06/06 09:18 AM
Joined: May 2006
Posts: 10
E
evolish Offline
Pikka bird
Offline
Pikka bird
E
Joined: May 2006
Posts: 10
$(,2) is the exact same thing as $eval(,2) meaning it evaluates it twice.


Best Regards,

evol