mIRC Home    About    Download    Register    News    Help

Print Thread
Help, I've fallen and I can't get up. #122667 13/06/05 11:12 PM
Joined: Jun 2005
Posts: 30
_
_DuDe_ Offline OP
Ameglian cow
OP Offline
Ameglian cow
_
Joined: Jun 2005
Posts: 30
Ok, so I made a bot recently, and I was making a !ban script. I can not get it to stop after it hits a notice. I have it set uo to message you if you try and ban an Op, but it dosn't not ban it.

Code:
 on *:TEXT:!ban*:*: {
  if ($2 == $me) { notice $nick I will not Ban my self. }
  if ($nick isop $chan) {
    if ($2 isop $chan) { notice $nick $2 is protected, sorry. | .halt }
    if ($2 !isop $chan) { mode $chan +b $address($2 ,9) }
  }
  if ($nick !isop $chan) { notice $nick You do not have permission to my commands. }
}
  


Anyhelp would be greatful. Also, I am running on 32 hours of no sleep, so don't laugh if the answer is simple.

Re: Help, I've fallen and I can't get up. #122668 13/06/05 11:22 PM
Joined: Sep 2003
Posts: 4,230
D
DaveC Offline
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Without changing any of your code (besides removing a halt) you could do this...

Code:
on *:TEXT:!ban*:*: {
  if ($2 == $me) { notice $nick I will not Ban my self. }
  elseif ($nick isop $chan) {
    if ($2 isop $chan) { notice $nick $2 is protected, sorry. }
    elseif ($2 !isop $chan) { mode $chan +b $address($2 ,9) }
  }
  elseif ($nick !isop $chan) { notice $nick You do not have permission to my commands. }
}


It can be improved alot still, but i need more coffee myself.

Re: Help, I've fallen and I can't get up. #122669 13/06/05 11:27 PM
Joined: Jun 2005
Posts: 30
_
_DuDe_ Offline OP
Ameglian cow
OP Offline
Ameglian cow
_
Joined: Jun 2005
Posts: 30
I figured it out. I had forgotten my old script on there that had no restrictions to who it could ban, and it was looking for !b*. LoL
Thanks Though!

Re: Help, I've fallen and I can't get up. #122670 13/06/05 11:57 PM
Joined: Sep 2004
Posts: 200
I
IR_n00b Offline
Fjord artisan
Offline
Fjord artisan
I
Joined: Sep 2004
Posts: 200
editing your code, to make it better:
Code:
 on *:TEXT:!ban *:#: {

  if ($nick isop $chan) {
  if ($address($2,2) == $address($me,2)) .notice $nick I will not ban myself.
    elseif ($2 isop $chan) notice $nick $2 is protected, sorry.
    elseif ($2 !isop $chan) ban $chan $2 9
  }
  else notice $nick You do not have permission to my commands.
}

This should work a little bit faster, the { braket is a command that searches for a } braket, then executes everything inbetween them.
also using /halt is bad. you should use /return, because /halt may cause other events after it to stop, and if its an alias it stops the script from continuing to be processed.

Re: Help, I've fallen and I can't get up. #122671 14/06/05 12:17 AM
Joined: Sep 2003
Posts: 4,230
D
DaveC Offline
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Quote:
because /halt may cause other events after it to stop


Halt doesnt have this effect. if it did what would the purpose of $halted be?

Re: Help, I've fallen and I can't get up. #122672 14/06/05 12:22 AM
Joined: Jun 2005
Posts: 30
_
_DuDe_ Offline OP
Ameglian cow
OP Offline
Ameglian cow
_
Joined: Jun 2005
Posts: 30
AHHHH, now I can't get the other stuf to function.

Code:
on@ *:TEXT:!kick*:*: {
  if ($2 == $me) { notice $nick I will not kick my self. }
  elseif ($nick isop $chan) {
    if ($2 isop $chan) { notice $nick $2 is protected, sorry. }
    elseif ($2 !isop $chan) { kick $chan $2 $3- }
  }
  elseif ($nick !isop $chan) { notice $nick You do not have permission to my commands. }
}

on@ *:TEXT:!ban*:*: {
  if ($2 == $me) { notice $nick I will not Ban my self. }
  elseif ($nick isop $chan) {
    if ($2 isop $chan) { notice $nick $2 is protected, sorry. }
    elseif ($2 !isop $chan) { mode $chan +b $address($2 ,9) }
  }
  elseif ($nick !isop $chan) { notice $nick You do not have permission to my commands. }
}

on@ *:TEXT:!unban*:*: {
  if ($2 == $me) { notice $nick I am not banned. }
  elseif ($nick isop $chan) {
    if ($2 isop $chan) { mode $chan -b $address($2 ,9) }
    elseif ($2 !isop $chan) { mode $chan -b $address($2 ,9) }
  }
  elseif ($nick !isop $chan) { notice $nick You do not have permission to my commands. }
}

on@ *:TEXT:!op*:*: {
  if ($2 == $me) { notice $nick I am already op'ed. }
  elseif ($nick isop $chan) {
    if ($2 isop $chan) { notice $nick $2 is already op'ed }
    elseif ($2 !isop $chan) { mode $chan +o $2 }
  }
  elseif ($nick !isop $chan) { notice $nick You do not have permission to my commands. }
}

on@ *:TEXT:!deop*:*: {
  if ($2 == $me) { notice $nick I will not deop my self. }
  elseif ($nick isop $chan) {
    if ($2 isop $chan) { mode $chan -o $2 }
    elseif ($2 !isop $chan) { notice $nick $2 is not even op'ed. }
  }
  elseif ($nick !isop $chan) { notice $nick You do not have permission to my commands. }
}
  

Re: Help, I've fallen and I can't get up. #122673 14/06/05 12:50 AM
Joined: Sep 2003
Posts: 4,230
D
DaveC Offline
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
might be

on@ *:

replace with

on @*:

Re: Help, I've fallen and I can't get up. #122674 14/06/05 12:54 AM
Joined: Jun 2005
Posts: 30
_
_DuDe_ Offline OP
Ameglian cow
OP Offline
Ameglian cow
_
Joined: Jun 2005
Posts: 30
Thanks a bunch, it fixed it. You guys rock!

B.T.W.: If you ever wanna join my server, I would be glad to give you NetAdmin. Either of you. You can find my server in my profile.

Re: Help, I've fallen and I can't get up. #122675 14/06/05 01:12 AM
Joined: Feb 2004
Posts: 2,019
FiberOPtics Offline
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Quote:
This should work a little bit faster, the { braket is a command that searches for a } braket, then executes everything inbetween them.

It's advisable to never advise against using both brackets + braces, as that's a very good scripting habit to use.

You're wrong in that it's going to save time or work faster in this case of a simple on text event. It would only save time if you'd issue the code several thousands of iterations in a row, and even then it would still maybe differ just a few milliseconds. Completely neglectible, and not worth it to not use braces when coding.

Let me guess, you've read Yochai's scripting tips... If that's the case you should remember that those tips were written for special occasions like in case of 10k+ iterations. Not a simple on text event.

Additionally, using braces to group multiple commands actually works faster than for example piping the commands on one line. (not the case with this code but I mention it anyway)

Btw I'm not criticizing the way you code, as that's a personal choice, but I do feel no one should ever advise against using braces for nearly unexistant speed gains.


Gone.
Re: Help, I've fallen and I can't get up. #122676 14/06/05 01:17 AM
Joined: Sep 2004
Posts: 200
I
IR_n00b Offline
Fjord artisan
Offline
Fjord artisan
I
Joined: Sep 2004
Posts: 200
i made a script like this for someone, it goes:
Code:
on *:text:!*:#: {
  if ($nick isop $chan) {
    if ($1 == !op) {
      if ($2 == $null) .notice $nick Syntax: !op <nickname>
      elseif ($2 !ison $chan) .notice $nick $2 is not in $+($chan,.)
      elseif ($2 isop $chan) .notice $nick $2 is already an op in $+($chan,.)
      else { cs op $chan $2 }
    }
    elseif ($1 == !deop) {
      if ($2 == $null) .notice $nick Syntax: !deop <nickname>
      elseif ($2 !ison $chan) .notice $nick $2 is not in $+($chan,.)
      elseif ($2 !isop $chan) .notice $nick $2 is not an op in $+($chan,.)
      else { cs deop $chan $2 }
    }
    elseif ($1 == !halfop) {
      if ($2 == $null) .notice $nick Syntax: !halfop <nickname>
      elseif ($2 !ison $chan) .notice $nick $2 is not in $+($chan,.)
      elseif ($2 ishop $chan) .notice $nick $2 is already an halfop in $+($chan,.)
      else { cs halfop $chan $2 }
    }
    elseif ($1 == !dehalfop) {
      if ($2 == $null) .notice $nick Syntax: !halfop <nickname>
      elseif ($2 !ison $chan) .notice $nick $2 is not in $+($chan,.)
      elseif ($2 !ishop $chan) .notice $nick $2 is not an halfop in $+($chan,.)
    else  {cs dehalfop $chan $2 }
  }
  if (($nick isop $chan) || ($nick ishop $chan)) { 
    if ($1 == !voice) {
      if ($2 == $null) .notice $nick Syntax: !voice <nickname>
      elseif ($2 !ison $chan) .notice $nick $2 is not in $+($chan,.)
      elseif ($2 isvoice $chan) .notice $nick $2 is already an voice in $+($chan,.)
      else { cs voice $chan $2  }
    }
    elseif ($1 == !devoice) {
      if ($2 == $null) .notice $nick Syntax: !devoice <nickname>
      elseif ($2 !ison $chan) .notice $nick $2 is not in $+($chan,.)
      elseif ($2 !isvoice $chan) .notice $nick $2 is not an voice in $+($chan,.)
      else { cs devoice $chan $2 }
    }
    elseif ($1 == !kick) {
      if ($2 == $null) .notice $nick Syntax: !kick <nickname> [reason]
      elseif ($2 !ison $chan) .notice $nick $2 is not in $+($chan,.)
      elseif ($nick($chan,$nick,~)) kick $chan $2 Requested: $nick $iif($3 == $null,,$+([,$3-,]))
      elseif ($nick($chan,$nick,&)) {
        if (($nick($chan,$2,&)) || ($nick($chan,$2,~))) .notice $nick You may not kick $2 $+ .
        else { kick $chan $2 Requested: $nick $iif($3 == $null,,$+([,$3-,])) }
      }
      elseif ($nick isop $chan) {
        if (($nick($chan,$2,&)) || ($nick($chan,$2,~))) .notice $nick You may not kick $2 $+ .
        else { kick $chan $2 Requested: $nick $iif($3 == $null,,$+([,$3-,])) }
      }
      elseif ($nick ishop $chan) {
        if (($nick($chan,$2,&)) || ($nick($chan,$2,~)) || ($nick isop $chan)) .notice $nick You may not kick $2 $+ .
        else { kick $chan $2 Requested: $nick $iif($3 == $null,,$+([,$3-,])) }
      }
    }
    elseif ($1 == !help) {
      if (($nick($chan,$2,&)) || ($nick($chan,$2,~)) || ($nick isop $chan)) .notice $nick Commands avaliable to you: !op,!deop,!voice,!devoice,!halfop, !dehalfop, !kick, !ban, !unban, !help, !kickban, !kb. Say !command for more help.
      else { .notice $nick Commands avaliable to you: !voice, !devoice, !kick, !ban, !unban, !help, !kickban, !kb. Say !command for more help. }
    }
    elseif ($1 == !ban) {
      if ($2 == $null) .notice $nick Syntax: !ban <nickname>
      elseif ($2 !ison $chan) .notice $nick $2 is not in $+($chan,.)
      elseif ($nick($chan,$nick,~)) {
        mode $chan +b $address($2,12)
        writeini ban.ini bans $2 $address($2,5)
      }
      elseif ($nick($chan,$nick,&)) {
        if (($nick($chan,$2,&)) || ($nick($chan,$2,~))) .notice $nick You may not ban $2 $+ .
        else {
          mode $chan +b $address($2,12)
          writeini ban.ini bans $2 $address($2,5)
        }
      }
      elseif ($nick isop $chan) {
        if (($nick($chan,$2,&)) || ($nick($chan,$2,~))) .notice $nick You may not ban $2 $+ .
        else {
          mode $chan +b $address($2,12)
          writeini ban.ini bans $2 $address($2,5)
        }  
      }
      elseif ($nick ishop $chan) {
        if (($nick($chan,$2,&)) || ($nick($chan,$2,~)) || ($nick isop $chan)) .notice $nick You may not kick $2 $+ .
        else {
          mode $chan +b $address($2,12)
          writeini ban.ini bans $2 $address($2,5)
        }    
      }
    }
    elseif ($1 == !unban) {
      if ($readini(ban.ini,bans,$2) == $null) .notice $nick I dont remember $+($2,'s) address.
      else {
        var %address = $readini(ban.ini,bans,$2)
        var %n = $ibl($chan,0)
        while (%n > 0) {
          if ($ibl($chan,%n) iswm %address) { 
            mode $chan -b $ibl($chan,%n)
            var %try = true
          }
          dec %n
        }
        var %n = $ibl($chan,0)
        var %address = $replace(%address,1,?,2,?,3,?,4,?,5,?,6,?,7,?,8,?,9,?,0,?)
        while (%n > 0) {
          if ($ibl($chan,%n) iswm %address) { 
            mode $chan -b $ibl($chan,%n)
            var %try = true
          }
          dec %n
        }
        if (%try != true) .notice $nick $2 is not banned. It may be a ~c:#channel ban.
        else msg $chan $2 has been unbaned.
      }
    }
    elseif (($1 == !kb) || ($1 == !kickban)) {
      if ($2 == $null) .notice $nick Syntax: <!kb|!kickban> <nickname> [reason]
      elseif ($2 !ison $chan) .notice $nick $2 is not in $+($chan,.)
      elseif ($nick($chan,$nick,~)) {
        mode $chan +b $address($2,12)
        writeini ban.ini bans $2 $address($2,5)
      }
      elseif ($nick($chan,$nick,&)) {
        if (($nick($chan,$2,&)) || ($nick($chan,$2,~))) .notice $nick You may not ban $2 $+ .
        else {
          mode $chan +b $address($2,12)
          writeini ban.ini bans $2 $address($2,5)
          kick $chan $2 Requested: $nick $iif($3 == $null,,$+([,$3-,]))
        }
      }
      elseif ($nick isop $chan) {
        if (($nick($chan,$2,&)) || ($nick($chan,$2,~))) .notice $nick You may not ban $2 $+ .
        else {
          mode $chan +b $address($2,12)
          writeini ban.ini bans $2 $address($2,5)
          kick $chan $2 Requested: $nick $iif($3 == $null,,$+([,$3-,]))
      }      }
      elseif ($nick ishop $chan) {
        if (($nick($chan,$2,&)) || ($nick($chan,$2,~)) || ($nick isop $chan)) .notice $nick You may not kick $2 $+ .
        else {
          mode $chan +b $address($2,12)
          writeini ban.ini bans $2 $address($2,5)
          kick $chan $2 Requested: $nick $iif($3 == $null,,$+([,$3-,]))
        }    
      }
    }
  }
}
on *:join:#:/writeini ban.ini bans $nick $address($nick,5)

say !help in a channel and it should PM you all the commands it has also you can use !unban in channel to unban someone that has joined while the bot was runnning this script, i made it for unreadircd servers, but comment out the commands you dont need and remove them from !help smile

Re: Help, I've fallen and I can't get up. #122677 23/06/05 05:45 PM
Joined: Jun 2005
Posts: 30
_
_DuDe_ Offline OP
Ameglian cow
OP Offline
Ameglian cow
_
Joined: Jun 2005
Posts: 30
Help again!!!!

I made an attack section, and when someone with a Strike of say 100,000,000 attacks someone with a defense of 1,000, the attacker makes an unbelievable ammount of gold, example 3,000,000,000, and the defender only has around 20,000 gold. It gives the attacker all 3,000,000,000 gold, and only takes away 3/4's of the defenders gold. I am so lost.

Code:
on *:TEXT:!attack*:*: {
  if ($2 == $null) { /msg $nick Please type !attack <nick> to attack someone | .halt
  }
  if ($2 != $null) && ( $readini( $2 $+ .ini, THINGS, gold) == $null) { /msg $nick Please attack someone that has gold. | .halt
  }
  if ($2 != $null) && ( $readini( $2 $+ .ini, THINGS, gold) != $null) {
    /msg $nick Attacking $2
    var %attack = $readini( $nick $+ .ini, THINGS, strike)
    var %defense = $readini( $2 $+ .ini, THINGS, defense)
    var %result = $calc( %attack - %defense )
  }
  if ( %result > 0 ) {
    var %loot = $round( $calc( $readini( $nick $+ .ini, THINGS, gold) + $calc( $readini( $2 $+ .ini, THINGS, gold) * .75 )) , 0)
    writeini $nick $+ .ini THINGS gold %loot
    writeini $2 $+ .ini THINGS gold $round( $calc( $readini( $2 $+ .ini, THINGS, gold) - $calc( $readini( $2 $+ .ini, THINGS, gold) * .75 )) , 0)
    msg $nick You Won  $bytes( %loot , b )  !
  }
  elseif ( %result <= 0 ) { msg $nick You Lost. }
}