mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jun 2015
Posts: 4
C
Self-satisified door
OP Offline
Self-satisified door
C
Joined: Jun 2015
Posts: 4
Recently I made a script that adds peoples nicknames to it like a list with the format being @nickname, so that it will append it on a single line. I was wondering if there was a way to delete only the text matching their nickname so if we have a list that it will only removing their nickname and not the whole line itself.

Here's the code that writes the list itself.

Code:
on *:TEXT:!addnick:#: {
  if (%nick == open) {
    if (!%addnick. $+ $nick) {
      set -u600 %addnick. $+ $nick on
      .write -al1w"@*" text.txt @ $+ $nick $+ , 
      .msg # @ $+ $nick $- Added to the list!
    }
  }
}

Joined: Dec 2008
Posts: 1,515
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,515
Try to use this code:

Before using this code change the "westor" to your nickname in lines if ($nick == westor)

Also be in mind that there is 600 seconds flood protection in each command per nick.

Commands:

!addnick <nickname>
!delnick <nickname>
!nicks
!totalnicks
!clearnicks

Code:
ON *:TEXT:!*:#: {
  tokenize 32 $strip($1-)
  if ($1 == !addnick) {
    if ($nick == westor) {
      if (!%addnick. [ $+ [ $nick ] ]) {
        if (!$2) { .msg $chan ( $+ $nick $+ ): Error, Please specify a nickname! | return }
         set -eu600 %addnick. $+ $nick on
        var %f = text.txt
        var %l = $read(%f,n,1)
        var %n = @ $+ $2
        if ($istok(%l,%n,44)) { .msg # ( $+ $nick $+ ): The $qt($2) nickname is already into the list! | return }
        var %l = $addtok(%l,%n,44)
        write -l1 $qt(%f) %l
        .msg # ( $+ $nick $+ ): The $qt(%n) has been added to the list!
      }
    }
    else { .msg # ( $+ $nick $+ ): Error, You have NOT access for this command! }
  }
  if ($1 == !delnick) {
    if ($nick == westor) { 
      if (!%delnick. [ $+ [ $nick ] ]) {
        if (!$2) { .msg $chan ( $+ $nick $+ ): Error, Please specify a nickname! | return }
         set -eu600 %delnick. $+ $nick on
        var %f = text.txt
        var %l = $read(%f,n,1)
        var %n = @ $+ $2
        if (!$istok(%l,%n,44)) { .msg # ( $+ $nick $+ ): The $qt($2) nickname is NOT into the list! | return }
        var %l = $remtok(%l,%n,1,44)
        write -l1 $qt(%f) %l
        .msg # ( $+ $nick $+ ): The $qt(%n) has been removed from the list!
      }
    }
    else { .msg # ( $+ $nick $+ ): Error, You have NOT access for this command! }
  }
  if ($1 == !nicks) {
    if ($nick == westor) { 
      if (!%allnick. [ $+ [ $nick ] ]) {
         set -eu600 %allnick. $+ $nick on
        var %f = text.txt
        var %l = $read(%f,n,1)
        if (!%l) { .msg $chan ( $+ $nick $+ ): There is NOT any nickname into the list! }
        elseif (%l) { .msg # ( $+ $nick $+ ): Nickname(s): %l }
      }
    }
    else { .msg # ( $+ $nick $+ ): Error, You have NOT access for this command! }
  }
  if ($1 == !totalnicks) {
    if ($nick == westor) { 
      if (!%totnick. [ $+ [ $nick ] ]) {
         set -eu600 %totnick. $+ $nick on
        var %f = text.txt
        var %l = $read(%f,n,1)
        if (!%l) { .msg $chan ( $+ $nick $+ ): There is NOT any nickname into the list! }
        elseif (%l) { .msg # ( $+ $nick $+ ): There are $qt($numtok(%l,44)) nicknames into the list! }
      }
    }
    else { .msg # ( $+ $nick $+ ): Error, You have NOT access for this command! }
  }
  if ($1 == !clearnicks) {
    if ($nick == westor) { 
      if (!%clearnick. [ $+ [ $nick ] ]) {
        set -eu600 %clearnick. $+ $nick on
        var %f = text.txt
        var %l = $read(%f,n,1)
        if (!%l) { .msg $chan ( $+ $nick $+ ): There is NOT any nickname into the list! }
        elseif (%l) {
          .remove $qt(%f)
          .msg # ( $+ $nick $+ ): All the nicknames have been cleared!
        }
      }
    }
    else { .msg # ( $+ $nick $+ ): Error, You have NOT access for this command! }
  }
}


Need Online mIRC help or an mIRC Scripting Freelancer? -> https://irc.chathub.org <-
Joined: May 2015
Posts: 249
Fjord artisan
Offline
Fjord artisan
Joined: May 2015
Posts: 249
But why do you need to use .txt and /write, why not %var and tokens?


Dont give a fish - teach to fish!
Joined: Jun 2015
Posts: 4
C
Self-satisified door
OP Offline
Self-satisified door
C
Joined: Jun 2015
Posts: 4
Thanks! I'm really new to mIRC so I didn't know about tokens and variables.

Works just for what I need it for.


Link Copied to Clipboard