• Home
  • Servers
  • Chat
  • Channels
  • Commands
  • Forum
  • FAQ
  • Software
  • Quotes
Topic Options
Rate This Topic
#4563 - 03/19/09 07:56 PM !add, !append, & !del script
Freelancer Offline
newbie

Registered: 12/20/08
Posts: 44
Loc: USA
This is my second WyldRyde script.

It's simple, you can add simple triggers with !add. Add to the trigger with !append. Delete the trigger with !del.

-----------------------------------------------------------------

Code:
on *:TEXT:!*:#: {
  if ($nick isop $chan) {
    if ($1 == !add) {
      set %temp_commands [ %commands ]
      unset %commands
      set %commands [ %temp_commands ] $2
      unset %temp_commands
      set %command_ [ $+ [ $2 ] ] $3-
      /notice $nick Command added successfully.
    }
    if ($1 == !append) {
      if (%command_ [ $+ [ $2 ] ] != %null) {
        set %temp_command [ %command_ [ $+ [ $2 ] ] ]
        unset %command_ [ $+ [ $2 ] ]
        set %command_ [ $+ [ $2 ] ] [ %temp_command ] $3-
        unset %temp_command
        /notice $nick Command appended successfully.
      }
    }
    if ($1 == !del) {
      if (%command_ [ $+ [ $2 ] ] != %null) {
        unset %command_ [ $+ [ $2 ] ]
        /notice $nick Command deleted successfully.
      }
    }
  }
  if ($1 isin %commands) {
    /notice $nick %command_ [ $+ [ $1 ] ]
  }
}


Edited by Freelancer (03/19/09 07:57 PM)

Top
Sponsored Links
Sponsored Links
Member
*****

Registered: 27/08/04
Posts: 10136
Loc: Mountain View, CA
Top
#4564 - 03/19/09 09:31 PM Re: !add, !append, & !del script [Re: Freelancer]
FordLawnmower Offline
Over 100 posts

Registered: 02/15/09
Posts: 111
Loc: Ohio
Hey Freelancer, good to see you still at it smile
You have a bracket missing @ line 10-11 and an extra one @ line 15-16.
It's cool to use some global variables like this to keep track of important things in a script, but I'm not sure about making a whole script out of it. It's going to slow down mirc's reaction time if you add too many. Also there is an issue with using one variable (%commands) to keep track of the commands. Up until the latest releases of mirc, the variable length has been just over 900 characters. So, after you exceed that you would just get a, /set line too long, error. The new mirc will hold over 4000. Weeeeeeeeee. You will still eventually run out of variable even with 4000 though. You really need to look into hashtables smile
Awesome job, with a very limited command set. Very creative smile
I would have did it something like this
Code:
on *:TEXT:!*:#: {
  if ($nick isop $chan) {
    if ($1 == !add) { 
      if (!%command_ [ $+ [ $2 ] ] ) {
        set %commands %commands $2
        set %command_ $+ $2 $3-
        .notice $nick Command added successfully.
      }
      else { .notice $nick $2 already exists as [ %command_ [ $+ [ $2 ] ] ] $+ . You must first !remove $2 $+ . }        
    }
  }
  if ($1 == !append) {
    if (%command_ [ $+ [ $2 ] ] ) {
      set %command_ $+ $2 [ %command_ [ $+ [ $2 ] ] ] $3-
      .notice $nick Command appended successfully.
    }
    else { .notice $nick Can't append $2 $+ . It doesn't exist. Try !add !triggername some text here }
  }
  if ($1 == !remove) {
    if (%command_ [ $+ [ $2 ] ] ) {
      set %commands $remove(%commands,$2)
      unset %command_ $+ $2
      .notice $nick Command deleted successfully.
    }
    else { .notice $nick Can't remove $2 $+ . $2 doesn't exist! }
  }
  ;You didn't make any changes to %commands in !del so this will get an error on deleted records
  if ($1 isin %commands) {
    .notice $nick %command_ [ $+ [ $1 ] ]
  }
}

You didn't need all the %tem variables and I added some error lines and a line to remove the command from %commands, when you do !del. Which I renamed to !remove smile
_________________________
If you already know everything, You can never learn anything :P

Top
#4569 - 03/21/09 04:50 PM Re: !add, !append, & !del script [Re: Freelancer]
Freelancer Offline
newbie

Registered: 12/20/08
Posts: 44
Loc: USA
There isn't anything missing or extra. The first script is fine. I wasn't sure how to remove the command from %commands tho... Thx for the help!

What do you think about my topic script?


Edited by Freelancer (03/21/09 04:53 PM)

Top
#4570 - 03/21/09 05:06 PM Re: !add, !append, & !del script [Re: Freelancer]
FordLawnmower Offline
Over 100 posts

Registered: 02/15/09
Posts: 111
Loc: Ohio
I'll have a look at the Your topic script when I get a chance Freelancer smile I'll post a reply there. I'm not much for topics though. I just edit them in chan-central ;/
_________________________
If you already know everything, You can never learn anything :P

Top


Moderator:  Jeff, mandy, usrbingeek