mIRC Home    About    Download    Register    News    Help

Print Thread
#129958 11/09/05 08:15 PM
Joined: Sep 2005
Posts: 6
T
thegimp Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
T
Joined: Sep 2005
Posts: 6
i'm working on a pickup bot and i'm having some problems with it. sometimes when a user types !remove it will devoice him but not take him out of the topic. also when i do !reset once in awhile it will leave 1 person voiced. also i need to find a better way to do !remove # so that i dont have to check how many lines is in players.txt for each #. here's the code..

Code:
on :TEXT:!add:#pickup.aq2:{
  if ($read(players.txt, w,  $nick)) { haltdef }
  elseif ($lines(players.txt) == 8) { haltdef }
  else {
    write players.txt $nick
    if ($lines(players.txt) == 8) {
      topic # AQ2 Pickup - ./././././././. - Type !add to join.
      mode # -vvvv $read(players.txt, 1) $read(players.txt, 2) $read(players.txt, 3) $read(players.txt, 4)
      mode # -vvvv $read(players.txt, 5) $read(players.txt, 6) $read(players.txt, 7) $read(players.txt, 8)
      write -c players.txt
      msg # Pickup starting now.. Players: $read(players.txt, 1) $+ , $read(players.txt, 2) $+ , $read(players.txt, 3) $+ , $read(players.txt, 4) $+ , $read(players.txt, 5) $+ , $read(players.txt, 6) $+ , $read(players.txt, 7) $+ , $read(players.txt, 8) $+ . Captains: $read(players.txt, $rand(1,4)) $read(players.txt, $rand(5,8))
      msg $read(players.txt, 1) Pickup starting.. %server $+ . Password is " $+ %password $+ ".
      msg $read(players.txt, 2) Pickup starting.. %server $+ . Password is " $+ %password $+ ".
      msg $read(players.txt, 3) Pickup starting.. %server $+ . Password is " $+ %password $+ ".
      msg $read(players.txt, 4) Pickup starting.. %server $+ . Password is " $+ %password $+ ".
      msg $read(players.txt, 5) Pickup starting.. %server $+ . Password is " $+ %password $+ ".
      msg $read(players.txt, 6) Pickup starting.. %server $+ . Password is " $+ %password $+ ".
      msg $read(players.txt, 7) Pickup starting.. %server $+ . Password is " $+ %password $+ ".
      msg $read(players.txt, 8) Pickup starting.. %server $+ . Password is " $+ %password $+ ".
      haltdef
    }
    if ($lines(players.txt) == 7) { topic # AQ2 Pickup - $read(players.txt, 1) $+ / $+ $read(players.txt, 2) $+ / $+ $read(players.txt, 3) $+ / $+ $read(players.txt, 4) $+ / $+ $read(players.txt, 5) $+ / $+ $read(players.txt, 6) $+ / $+ $read(players.txt, 7) $+ /. - Type !add to join. | mode # +v $nick | haltdef }
    if ($lines(players.txt) == 6) { topic # AQ2 Pickup - $read(players.txt, 1) $+ / $+ $read(players.txt, 2) $+ / $+ $read(players.txt, 3) $+ / $+ $read(players.txt, 4) $+ / $+ $read(players.txt, 5) $+ / $+ $read(players.txt, 6) $+ /./. - Type !add to join. | mode # +v $nick | haltdef }
    if ($lines(players.txt) == 5) { topic # AQ2 Pickup - $read(players.txt, 1) $+ / $+ $read(players.txt, 2) $+ / $+ $read(players.txt, 3) $+ / $+ $read(players.txt, 4) $+ / $+ $read(players.txt, 5) $+ /././. - Type !add to join. | mode # +v $nick | haltdef }
    if ($lines(players.txt) == 4) { topic # AQ2 Pickup - $read(players.txt, 1) $+ / $+ $read(players.txt, 2) $+ / $+ $read(players.txt, 3) $+ / $+ $read(players.txt, 4) $+ /./././. - Type !add to join. | mode # +v $nick | haltdef }
    if ($lines(players.txt) == 3) { topic # AQ2 Pickup - $read(players.txt, 1) $+ / $+ $read(players.txt, 2) $+ / $+ $read(players.txt, 3) $+ /././././. - Type !add to join. | mode # +v $nick | haltdef }
    if ($lines(players.txt) == 2) { topic # AQ2 Pickup - $read(players.txt, 1) $+ / $+ $read(players.txt, 2) $+ /./././././. - Type !add to join. | mode # +v $nick | haltdef }
    if ($lines(players.txt) == 1) { topic # AQ2 Pickup - $read(players.txt, 1) $+ /././././././.  - Type !add to join. | mode # +v $nick | haltdef }
  }
}
on :TEXT:!remove:#pickup.aq2:{
  if ($read(players.txt, w,  $nick)) {
    if ($lines(players.txt) == 1) { write -dl1 players.txt | topic # AQ2 Pickup - ./././././././.  - Type !add to join. | mode # -v $nick | haltdef }
    if ($lines(players.txt) == 2) { write -dl1 players.txt | topic # AQ2 Pickup - $read(players.txt, 1) $+ /././././././.  - Type !add to join. | mode # -v $nick | haltdef }
    if ($lines(players.txt) == 3) { write -dl1 players.txt | topic # AQ2 Pickup - $read(players.txt, 1) $+ / $+ $read(players.txt, 2) $+ /./././././. - Type !add to join. | mode # -v $nick | haltdef }
    if ($lines(players.txt) == 4) { write -dl1 players.txt | topic # AQ2 Pickup - $read(players.txt, 1) $+ / $+ $read(players.txt, 2) $+ / $+ $read(players.txt, 3) $+ /././././. - Type !add to join. | mode # -v $nick | haltdef }
    if ($lines(players.txt) == 5) { write -dl1 players.txt | topic # AQ2 Pickup - $read(players.txt, 1) $+ / $+ $read(players.txt, 2) $+ / $+ $read(players.txt, 3) $+ / $+ $read(players.txt, 4) $+ /./././. - Type !add to join. | mode # -v $nick | haltdef }
    if ($lines(players.txt) == 6) { write -dl1 players.txt | topic # AQ2 Pickup - $read(players.txt, 1) $+ / $+ $read(players.txt, 2) $+ / $+ $read(players.txt, 3) $+ / $+ $read(players.txt, 4) $+ / $+ $read(players.txt, 5) $+ /././. - Type !add to join. | mode # -v $nick | haltdef }
    if ($lines(players.txt) == 7) { write -dl1 players.txt | topic # AQ2 Pickup - $read(players.txt, 1) $+ / $+ $read(players.txt, 2) $+ / $+ $read(players.txt, 3) $+ / $+ $read(players.txt, 4) $+ / $+ $read(players.txt, 5) $+ / $+ $read(players.txt, 6) $+ /./. - Type !add to join. | mode # -v $nick | haltdef }
    if ($lines(players.txt) == 8) { write -dl1 players.txt | topic # AQ2 Pickup - $read(players.txt, 1) $+ / $+ $read(players.txt, 2) $+ / $+ $read(players.txt, 3) $+ / $+ $read(players.txt, 4) $+ / $+ $read(players.txt, 5) $+ / $+ $read(players.txt, 6) $+ / $+ $read(players.txt, 7) $+ /. - Type !add to join. | mode # -v $nick | haltdef }
  }
  else { haltdef }
}
on master:TEXT:!reset:#pickup.aq2:{
  mode # -vvvv $read(players.txt, 1) $read(players.txt, 2) $read(players.txt, 3) $read(players.txt, 4)
  mode # -vvvv $read(players.txt, 5) $read(players.txt, 6) $read(players.txt, 7) $read(players.txt, 8)
  write -c players.txt
  topic # AQ2 Pickup - ./././././././.  - Type !add to join.
}
on master:TEXT:!remove *:#pickup.aq2, ?:{
  if ($2 == 1) { mode # -v $read(players.txt, 1) | write -dl1 players.txt | haltdef }
  if ($2 == 2) { mode # -v $read(players.txt, 2) | write -dl2 players.txt | haltdef }
  if ($2 == 3) { mode # -v $read(players.txt, 3) | write -dl3 players.txt | haltdef }
  if ($2 == 4) { mode # -v $read(players.txt, 4) | write -dl4 players.txt | haltdef }
  if ($2 == 5) { mode # -v $read(players.txt, 5) | write -dl5 players.txt | haltdef }
  if ($2 == 6) { mode # -v $read(players.txt, 6) | write -dl6 players.txt | haltdef }
  if ($2 == 7) { mode # -v $read(players.txt, 7) | write -dl7 players.txt | haltdef }
  if ($2 == 8) { mode # -v $read(players.txt, 8) | write -dl8 players.txt | haltdef }
  else { haltdef }
}

#129959 12/09/05 12:52 AM
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
I have removed a "write -c" line that didnt make sence where it was, u may have to work to correct this.
I was going to add multiple targets MSG's but remarked them incase the irc server doesnt like them.
I also compacted the topic building into one line.
Your remove failed becuase you always removed line1 and not the line the $nick was on, i corrected this using $readn.
And used the compact topic builder, nb: "- Type !add to join." was at the end of the topic lines so this was left there.
Replaced the master:!remove script to use a INT value of $2 being 1 to 8 for the remove of player 1 to 8
Replaced HALTDEF with RETURN

Code:
on :TEXT:!add:#pickup.aq2:{
  if ($read(players.txt, w,  $nick)) { return }
  elseif ($lines(players.txt) == 8) { return }
  else {
    write players.txt $nick
    if ($lines(players.txt) == 8) {
      topic # AQ2 Pickup - ./././././././. - Type !add to join.
      mode # -vvvv $read(players.txt, 1) $read(players.txt, 2) $read(players.txt, 3) $read(players.txt, 4)
      mode # -vvvv $read(players.txt, 5) $read(players.txt, 6) $read(players.txt, 7) $read(players.txt, 8)
      [color:blue];write -c players.txt[/color]
      [color:red];^ REMOVED THIS LINE this is a mistake you clear the file then attempt to read the 8 lines that are in it.[/color] 
      msg # Pickup starting now.. Players: $read(players.txt, 1) $+ , $read(players.txt, 2) $+ , $read(players.txt, 3) $+ , $read(players.txt, 4) $+ , $read(players.txt, 5) $+ , $read(players.txt, 6) $+ , $read(players.txt, 7) $+ , $read(players.txt, 8) $+ . Captains: $read(players.txt, $rand(1,4)) $read(players.txt, $rand(5,8))
      msg $read(players.txt, 1) Pickup starting.. %server $+ . Password is " $+ %password $+ ".
      msg $read(players.txt, 2) Pickup starting.. %server $+ . Password is " $+ %password $+ ".
      msg $read(players.txt, 3) Pickup starting.. %server $+ . Password is " $+ %password $+ ".
      msg $read(players.txt, 4) Pickup starting.. %server $+ . Password is " $+ %password $+ ".
      msg $read(players.txt, 5) Pickup starting.. %server $+ . Password is " $+ %password $+ ".
      msg $read(players.txt, 6) Pickup starting.. %server $+ . Password is " $+ %password $+ ".
      msg $read(players.txt, 7) Pickup starting.. %server $+ . Password is " $+ %password $+ ".
      msg $read(players.txt, 8) Pickup starting.. %server $+ . Password is " $+ %password $+ ".
      [color:blue];msg $read(players.txt,1) $+ , $+ $read(players.txt,2) $+ , $+ $read(players.txt,3) $+ , $+ $read(players.txt,4) Pickup starting.. %server $+ . Password is " $+ %password $+ ".
      ;msg $read(players.txt,5) $+ , $+ $read(players.txt,6) $+ , $+ $read(players.txt,7) $+ , $+ $read(players.txt,8) Pickup starting.. %server $+ . Password is " $+ %password $+ ".[/color]
      [color:red];^ Remarked out some irc servers wont take multiple targets to a msg[/color]
      return
    }
    topic # AQ2 Pickup - $+($iif($read(players.txt,1),$v1,.),/,$iif($read(players.txt,2),$v1,.),/,$iif($read(players.txt,3),$v1,.),/,$iif($read(players.txt,4),$v1,.),/,$iif($read(players.txt,5),$v1,.),/,$iif($read(players.txt,6),$v1,.),/,$iif($read(players.txt,7),$v1,.),/,$iif($read(players.txt,8),$v1,.))
  }
}
on :TEXT:!remove:#pickup.aq2:{
  if ($read(players.txt, w,  $nick)) {
    write -dl $+ $readn players.txt
    topic # AQ2 Pickup - $+($iif($read(players.txt,1),$v1,.),/,$iif($read(players.txt,2),$v1,.),/,$iif($read(players.txt,3),$v1,.),/,$iif($read(players.txt,4),$v1,.),/,$iif($read(players.txt,5),$v1,.),/,$iif($read(players.txt,6),$v1,.),/,$iif($read(players.txt,7),$v1,.),/,$iif($read(players.txt,8),$v1,.)) - Type !add to join.
    mode # -v $nick
}
on master:TEXT:!reset:#pickup.aq2:{
  mode # -vvvv $read(players.txt, 1) $read(players.txt, 2) $read(players.txt, 3) $read(players.txt, 4)
  mode # -vvvv $read(players.txt, 5) $read(players.txt, 6) $read(players.txt, 7) $read(players.txt, 8)
  write -c players.txt
  topic # AQ2 Pickup - ./././././././.  - Type !add to join.
}
on master:TEXT:!remove *:#pickup.aq2, ?:{
  if ($2 isnum 1-8) {
    tokenize 32 $1 $int($2) $3-
    mode # -v $read(players.txt,$2) | write -dl $+ $2 players.txt }
    topic # AQ2 Pickup - $+($iif($read(players.txt,1),$v1,.),/,$iif($read(players.txt,2),$v1,.),/,$iif($read(players.txt,3),$v1,.),/,$iif($read(players.txt,4),$v1,.),/,$iif($read(players.txt,5),$v1,.),/,$iif($read(players.txt,6),$v1,.),/,$iif($read(players.txt,7),$v1,.),/,$iif($read(players.txt,8),$v1,.))
  } 
}


**** CODE IS UNTESTED, I did the edits in the forum editor so mistakes are possable ****

#129960 12/09/05 03:26 AM
Joined: Sep 2005
Posts: 6
T
thegimp Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
T
Joined: Sep 2005
Posts: 6
thx alot DaveC, the help is really appreciated. i learned alot from it smile

#129961 12/09/05 10:06 PM
Joined: Sep 2005
Posts: 6
T
thegimp Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
T
Joined: Sep 2005
Posts: 6
sorry for the stupid question but i didnt see it in the help file. what does return do?

#129962 12/09/05 10:10 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
It depends how you use it. It really has 2 uses, though they are really the same thing.

If used by itself, it can be used to exit a script. It's like halt, but it's been pointed out a little while back that halt isn't the best way to halt a script.

If used with a value after it it will return that value to the calling script. This is often done in custom identifiers.

Basic Example:
Code:
alias time {
  return $time(hh:nntt)
}


Type //echo -a $time and you will get the output of $time(hh:nntt). In this case, the calling "script" is //echo.


Invision Support
#Invision on irc.irchighway.net
#129963 12/09/05 10:12 PM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
In addition to what Riamus said, return is also responsible for filling the value of the identifier $result.

Example:

alias woot return woot

//woot | echo -a $result


Gone.
#129964 13/09/05 12:59 AM
Joined: Sep 2005
Posts: 6
T
thegimp Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
T
Joined: Sep 2005
Posts: 6
thx smile

#129965 13/09/05 05:58 AM
Joined: Aug 2005
Posts: 39
B
Ameglian cow
Offline
Ameglian cow
B
Joined: Aug 2005
Posts: 39
do you want to pickup chicks? if so, you don't need a mirc bot for that smile smile laugh grin


Link Copied to Clipboard