players containing number nicks?

Started by Nihongo^, Jul 24, 2023, 04:21 PM

Previous topic - Next topic

Nihongo^

How do I kick players containing number nicks?
And nicks with weird symbols ( ,,,' ''''' """" )

vitovc

local names = ["12345", "1abcd", "abcd1", "a123e", "abcde"];
for(local i = 0; i < names.len(); i++){
    if(::regexp( @"^[0-9]+$" ).match( names[i] )){
      ::print(names[i] +" is fully numeric");
    } else if(::regexp( @"^[^0-9]+$" ).match( names[i] )){
      ::print(names[i] +" is not containing number");
    } else {
      ::print(names[i] +" is containing number");
    }
}
Result:
[SCRIPT] 12345 is fully numeric
[SCRIPT] 1abcd is containing number
[SCRIPT] abcd1 is containing number
[SCRIPT] a123e is containing number
[SCRIPT] abcde is not containing number
...::: vice city :::...
Useful things for vcmp: Relative position and finding an angle (in 3d), 3d line (like laser)

Nihongo^

Thanks btw I made this.

Quotelocal nickcheck = ( player.Name.len() < 4 ) || IsNum(player.Name)
    if (nickcheck) {
       
        print("nick not allowed");
    }

how do i include symbols players like such nick (```` ;;;; '''' ) joined every time

vitovc

for pure clean names you can use
if(::regexp( @"^[a-zA-Z]+$" ).match( names[i] )){to avoid any number or symbols. but many of players vcmp are using clan tags [MK] (RT) VU. =TnC= or ending with ^ like SuPer^Sens^, or "4" instead "A" so they wont be able to keep their names
for detectiong only-symbols
local names = ["12345", "1abcd", "::", "_$_!", "abcde", "", " "];
for(local i = 0; i < names.len(); i++){
    if(::regexp( @"^[^a-zA-Z]+$" ).match( names[i] )){
      ::print(names[i] +" has no letters");
    } else {
      ::print(names[i] +" has letters or its empty string");
    }
}
[SCRIPT] 12345 has no letters
[SCRIPT] 1abcd has letters or its empty string
[SCRIPT] :: has no letters
[SCRIPT] _$_! has no letters
[SCRIPT] abcde has letters or its empty string
[SCRIPT]  has letters or its empty string
[SCRIPT]  has no letters
...::: vice city :::...
Useful things for vcmp: Relative position and finding an angle (in 3d), 3d line (like laser)

habi

Quote from: Nihongo^ on Jul 24, 2023, 04:21 PMHow do I kick players containing number nicks?
And nicks with weird symbols ( ,,,' ''''' """" )
My Answer: The four characters ( , ), ( ' ), ( " ) and ( ` ) gets replaced by _ when player is connecting to server.
As vito said, some players use 4 for A and so on.
If the name contain more than 4 digits, you can kick him
local c=0;
for(local i=0;i<player.Name.len();i++)
{
  if(player.Name[i]>='0'&& player.Name[i]<='9')
  c++;
}
if(c>=4)
{
  MessagePlayer("Invalid Nick. Connect with  proper nick.", player);
  if(!rawin("KickById")
    KickById<-function(id){  if( FindPlayer( id ) ) FindPlayer( id ).Kick() }
  NewTimer( "KickById", 2000, 1, player.ID );
}