mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Dec 2002
Posts: 111
E
Vogon poet
OP Offline
Vogon poet
E
Joined: Dec 2002
Posts: 111
Code:
menu nicklist {
  .Timed Ban: {
    set %reason $input(Enter Reason, e)
    set %timeb $input(Enter Time, e)
    echo %reason
    echo %timeb
    if (%reason == $null) { halt }
    if (%timeb == $null) { halt }
    if (%timeb isnum) {
      ban -kr $snick(#,1) $calc(%timeb * 60) 2 %reason (Banned for %timeb minute(s))
      halt
    }
    echo [ERROR] Time must be a number!
    halt
  }
}


what is the deal?

everytime i do that, and try to enter "1" for %reason or %timeb it returns this:

* /echo: insufficient parameters


it works just fine if i enter letters tho instead of numbers. Why?

Thanks for your help!

Joined: Dec 2002
Posts: 191
N
Vogon poet
Offline
Vogon poet
N
Joined: Dec 2002
Posts: 191
It's not a problem with the $input identifier it's with how you are trying to use the echo command,

/echo [color] [-deghiNtsaqlbfnmr] [#channel|[=]nick] <text>
Prints text in the specified window using the specified color (0 to 15).

echo -a %variable
should echo the number.

Joined: Feb 2003
Posts: 2,812
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,812
In addition, here are some tips for proper coding to make things easier.

  Use var %myvar = data instead of set %myvar data in situations where you don't intend to keep the data after the alias has completed. This creates a local and temporary variable that is faster to access and wont conflict with variables from other scripts. Note that = must be used for /var and must not be used for /set

  Instead of echoing each variable on its own for debugging, use the -s switch in /var or /set.

  You are using /ban incorrectly. Your statement would UNban the user while kicking them. You want to use ban -kuN instead.

  Avoid using /halt so much, instead, try scripting in a way where you always reach the end of the event. Exceptions to this may include user input error, but I would recommend getting used to /return, as /halt will completely end your script. (I know that doesn't apply to this particular script, but I'm refering to the unnecessary /halts used after /ban)

  In a situation where input must be supplied, use $$input() instead. The extra $ makes it work like $$1 where the event returns if no input is supplied.

Code:
menu nicklist {
  .Timed Ban: {
    var -s %reason = $$input(Enter Reason, e)
    var -s %timeb = $$input(Enter Time, e)
    if (%timeb !isnum) { echo $colour(info) -a * Timed Ban: Time must be a number! | return }
    ban -ku $+ $calc(%timeb * 60) $* 2 %reason (Banned for %timeb minute(s))
  }
}


Remember to remove the var -s flags when done.

- Raccoon


Well. At least I won lunch.
Good philosophy, see good in bad, I like!
Joined: Aug 2003
Posts: 1,831
I
Hoopy frood
Offline
Hoopy frood
I
Joined: Aug 2003
Posts: 1,831
Just a slight change smile
Code:
    if (%timeb !isnum [color:red]1-[/color]) { echo $colour(info) -a * Timed Ban: Time must be a number! | return }

Joined: Dec 2002
Posts: 111
E
Vogon poet
OP Offline
Vogon poet
E
Joined: Dec 2002
Posts: 111
ah sweet, thanks smile

Joined: Feb 2003
Posts: 2,812
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,812
A couple more changes you might enjoy,

Code:
menu nicklist {
  .Timed Ban: {
    var %reason = $input(Enter Reason, e, Timed Ban)
    var %timeb = $$input(Enter Time, e, Timed Ban, 5)
    if (%timeb !isnum 1-) { echo $colour(info) -a * Timed Ban: Time must be a number! | return }
    ban -ku $+ $calc(%timeb * 60) $* 2 %reason (Banned for %timeb minute(s))
  }
}


Here we made %reason optional by giving it only one $ for $input, and gave a default value of '5' minutes for
%timeb. This can be handy when trying to ban someone quickly.

You're welcome, grin

* Raccoon licks Iori.


Well. At least I won lunch.
Good philosophy, see good in bad, I like!

Link Copied to Clipboard