Vice City Multiplayer

VC:MP => mIRC/pawn Scripting => Topic started by: Amenine on March 02, 2009, 07:50:14 AM

Title: InVaLiD NiCk..
Post by: Amenine on March 02, 2009, 07:50:14 AM
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
  }

Title: Re: InVaLiD NiCk..
Post by: Windlord on March 02, 2009, 09:07:58 AM
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
Title: Re: InVaLiD NiCk..
Post by: thijn on March 02, 2009, 04:57:56 PM
If this is GUS with the old DLL, It's $1 ;)
Title: Re: InVaLiD NiCk..
Post by: Mex on March 02, 2009, 07:45:11 PM
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
}
Title: Re: InVaLiD NiCk..
Post by: Windlord on March 03, 2009, 10:12:24 AM
lol you don't need that extra bracket.
Title: Re: InVaLiD NiCk..
Post by: Amenine on March 03, 2009, 01:24:06 PM
Quote from: thijn on March 02, 2009, 04: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
Title: Re: InVaLiD NiCk..
Post by: thijn on March 03, 2009, 04:46:40 PM
No Problem ;)
Title: Re: InVaLiD NiCk..
Post by: Mex on March 03, 2009, 06:19:11 PM
Quote from: Windlord on March 03, 2009, 10:12:24 AM
lol you don't need that extra bracket.

Sometimes you do sometimes you dont.
Title: Re: InVaLiD NiCk..
Post by: Windlord on March 04, 2009, 09:26:49 AM
lol yes but we were only discussing the case for
Quote from: Amenine on March 02, 2009, 07: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
Title: Re: InVaLiD NiCk..
Post by: Mex on March 04, 2009, 02:34:57 PM
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?
Title: Re: InVaLiD NiCk..
Post by: VRocker on March 04, 2009, 03:15:29 PM
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.
Title: Re: InVaLiD NiCk..
Post by: Windlord on March 04, 2009, 03:58:46 PM
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.
Title: Re: InVaLiD NiCk..
Post by: Mex on March 07, 2009, 04:58:44 PM
nice explanation man,

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