• Welcome to Vice City Multiplayer.
 

InVaLiD NiCk..

Started by Amenine, March 02, 2009, 06:50:14 AM

Previous topic - Next topic

0 Members and 4 Guests are viewing this topic.

Amenine

Hey i am trying to convert WSV little but getting problem here...about invalid nick gets a kick...but its kicking everyone in server with name as [CG]Amenine or with invalid name as !!35433%%#...Plz try to sort this out...

Here.
if ($len($3) < 3) || ($left($3,1) isnum) || ($chr(35) isin $3) || ($chr(36) isin $3) || ($chr(37) isin $3) || ($3 == none) {
    vcmp.say *** $3 has been auto-kicked. [Invalid Nick]
    vcmp.announce %id ~y~Please change your nick-name..
    .timer 1 2 /vcmp.kick %id
  }


Windlord

Are you sure $3 on your vcmp.join signal is the nick-name of the player that is joining?

It seems like you have removed IDs from the aliases and you may have done so in the signals as well.

Try $2




thijn

If this is GUS with the old DLL, It's $1 ;)


Mex

also you should put an extra pair of ( ) brackets around the massive conditional statement ;)


if (($len($3) < 3) || ($left($3,1) isnum) || ($chr(35) isin $3) || ($chr(36) isin $3) || ($chr(37) isin $3) || ($3 == none)) {
  vcmp.say *** $3 has been auto-kicked. [Invalid Nick]
  vcmp.announce %id ~y~Please change your nick-name..
  .timer 1 2 /vcmp.kick %id
}

Windlord

lol you don't need that extra bracket.




Amenine

Quote from: thijn on March 02, 2009, 03:57:56 PM
If this is GUS with the old DLL, It's $1 ;)
Yup Thijn is right ,its $1...
Now working fine ..
Nvm Thanks to all for their suggestions.. :P

thijn



Mex

Quote from: Windlord on March 03, 2009, 09:12:24 AM
lol you don't need that extra bracket.

Sometimes you do sometimes you dont.

Windlord

lol yes but we were only discussing the case for
Quote from: Amenine on March 02, 2009, 06:50:14 AM
if ($len($3) < 3) || ($left($3,1) isnum) || ($chr(35) isin $3) || ($chr(36) isin $3) || ($chr(37) isin $3) || ($3 == none) {
    vcmp.say *** $3 has been auto-kicked. [Invalid Nick]
    vcmp.announce %id ~y~Please change your nick-name..
    .timer 1 2 /vcmp.kick %id
  }


Were we not? :P




Mex

Indeed we were.

I can remember along time ago when I was having problems with brackets,
and I tried all possible bracket solutions for the statement, and the only one which worked was when I added an extra pair of ( )

So from now on I've always added them when I have a statement with more than 1 condition, and it's never let me down.

So unless you know when to add them or not, in my opinion it's best to add them anyway.

I'm assuming you know when to add them, perhaps you could explain?

VRocker

Just adding my small comment of the brackets thingy...

I remember reading ages ago that mirc scripts execute a bit faster if the entire if statement is in brackets. so if ( ( $1 == 1 ) && ( $2 == 2 ) ). Not sure how reliable this source was though.

Another reason for encapsulating it all in brackets would be that some complex if statements require it else they will just fail or not work as expected.


Windlord

I'm not very good at explaining stuff... but I'll try nonetheless.

When using the if/elseif conditionals,
The statement is checked by the script starting from the start of the line.

So if you have a line like;

if ($nick == Windlord) || ($chan == #windlord) && ($1 == !cmd)

The script will check if '$nick == Windlord' first.
Then it goes on to check the operator which is '||' in this case.
As '||' means; 'or' the script won't bother continuing to check the statement if the first conditional is already true.
By any chance, if '$nick != Windlord' the script will continue processing the statement.

If the operator is '&&' the script only continues checking if the first conditional is true. If it is false, there is no need to check the next conditional.

Now sometimes, we would want '!cmd' to work both for 'Windlord' and '#windlord' but since the script only processes the statements in the order they are written in, it is not possible to do so.
That's when you add in extra brackets so that the script can process additional conditionals included inside the main conditional.

If '!cmd' needs to be used by 'Windlord' as well as anyone on '#windlord, the script would need to be;

if (($nick == Windlord) || ($chan == #windlord)) && ($1 == !cmd)


And so on...

Hope this helps.




Mex

nice explanation man,

about what i said, i must have been thinking of a more advanced expression like the last one you posted