[HOWTO]Creating a little script.
#1

I need to create a little script that will kick every single person who joins the game, if he doesn't have an RP name -

Firstname_Lastname - The script should be able to check that.

If, the name is something else, /kickplayer ID for non RP name reason. Just to make automatic.

Thank you.
Reply
#2

so what is the cryteria for the name only a-z 2 names and sepperated by _ ?
Reply
#3

Quote:
Originally Posted by (SF)Noobanatior
so what is the cryteria for the name only a-z 2 names and sepperated by _ ?
Thats what he means yes. He means a name should look like this John_Doe and not john_doe or johndoe or JohnDoe etc etc.
Reply
#4

pawn Код:
public OnPlayerConnect( playerid )
{
    new
      playerName[ MAX_PLAYER_NAME ];
     
    GetPlayerName( playerid, playerName, MAX_PLAYER_NAME );
     
    if( strfind( PlayerName, "_", true) == -1)
    {
      Kick( playerid );
    }
   
    return 1;
}
Reply
#5

Will this work? Like if the name is John_Doe and not john_Doe neither John_doe.
Reply
#6

pawn Код:
stock Validrpname(rpname[]) {
    new len=strlen(rpname);
    new cstate=0;
    new i;
    for(i=0;i<len;i++) {
        if ((cstate==0 || cstate==1) && (rpname[i]>='A' && rpname[i]<='Z') || (rpname[i]>='a' && rpname[i]<='z'))continue;
    else {
    // Ok no A..Z,a..z
            if ((cstate==0) &&(rpname[i]=='_')) {
     // its an _ after the name, ok state=1;
            cstate=1;
            }
            else return false; // Its stuff which is not allowed
        }
    }
    if (cstate<1) return false;
    else if (len<6) return false; //name must be at least 6 char
    else return true;
}

public OnPlayerConnect( playerid )
{
    new playerName[ MAX_PLAYER_NAME ];
    GetPlayerName( playerid, playerName, MAX_PLAYER_NAME );
    if(!Validrpname(playername){
      Kick( playerid );
    }
   
    return 1;
}
it dont look for the caps at the start of name can add though
Reply
#7

Quote:
Originally Posted by (SF)Noobanatior
pawn Код:
stock Validrpname(rpname[]) {
    new len=strlen(rpname);
    new cstate=0;
    new i;
    for(i=0;i<len;i++) {
        if ((cstate==0 || cstate==1) && (rpname[i]>='A' && rpname[i]<='Z') || (rpname[i]>='a' && rpname[i]<='z'))continue;
    else {
   // Ok no A..Z,a..z
        if ((cstate==0) &&(email[i]=='_')) {
     // its an _ after the name, ok state=1;
            cstate=1;
        }
            else return false; // Its stuff which is not allowed
        }
    }
    if (cstate<1) return false;
    else if (len<6) return false; //name must be at least 6 char
    else return true;
}
it dont look for the caps at the start of name can add though
Ehh this kick players if there name is Jhon_Doe because it kicks on capitals.. (or I am crazy)
Reply
#8

should allow a-z A-Z and _ also name must be at leat 6 chars
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)