INVALID NICK.
#1

HI. Where is problem:

Код:
stock InvalidNickKick(playerid)
{
    new name[MAX_PLAYER_NAME];
	GetPlayerName(playerid,name,sizeof(name));
    new where = strfind(name,"_",true);
    new lenght = strlen(name)-1;
    new invalid = strfind(name,"[",true);
    if(invalid == -1) invalid = strfind(name,"]",true);

    if(where == 0 || where == lenght || where==-1)
    {
	    SendClientMessage(playerid,COLOR_ORANGE,"* SERVER: Name_Lastname");
	    Kick(playerid);
	    return 1;
	}

	if(strlen(name[where])<4)
 	{
  		SendClientMessage(playerid,COLOR_ORANGE,"* SERVER: your lastname is too short");
  		Kick(playerid);
  		return 1;
 	}

	if(where<3)
 	{
  		SendClientMessage(playerid,COLOR_ORANGE,"* SERVER: your firstname is too short");
  		Kick(playerid);
  		return 1;
 	}
 	
	if(invalid != -1)
 	{
  		SendClientMessage(playerid,COLOR_ORANGE,"* SERVER: invalids letters in your name");
  		Kick(playerid);
		return 1;
 	}
 	return 0;
}
How to make player can come only with that name:

Код:
Aasdas_Asdasd
Because he can come with that nick:

Код:
AASDAS_ASDASD
Reply
#2

any help?
Reply
#3

You need to split the string into individual names (splitting it by the _ in this case) and then ensure that only the first letter of each word (var[0]) is uppercase, and you'd do this by checking it against an array of valid uppercase characters.
Reply
#4

Can you do it?
Reply
#5

pawn Код:
stock InvalidNickKick(playerid)
{
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,sizeof(name));
    new where = strfind(name,"_",true);
    new lenght = strlen(name)-1;
    if(where == 0 || where == lenght || where==-1)
    {
        SendClientMessage(playerid,COLOR_ORANGE,"* SERVER: Name_Lastname");
        Kick(playerid);
        return 1;
    }
    if(where<3)
    {
        SendClientMessage(playerid,COLOR_ORANGE,"* SERVER: your firstname is too short");
        Kick(playerid);
        return 1;
    }
    if(length-where<4)
    {
        SendClientMessage(playerid,COLOR_ORANGE,"* SERVER: your lastname is too short");
        Kick(playerid);
        return 1;
    }
    new bool:invalid = false;

    if(strfind(name,"[",true,0) != -1|| strfind(name,"]",true,0)!= -1)invalid = true;
   
    if(invalid == true)
    {
        SendClientMessage(playerid,COLOR_ORANGE,"* SERVER: invalids letters in your name");
        Kick(playerid);
        return 1;
    }
   
/* Use this if you want to get first and last name.
new fName[20],lName[20];
    for(new i=0;name[i]!='_';++i)
    {
        fName[i] = name[i];
    }
   
    new j=0;
    for(new i = where+1;name[i]!='\0';++i,++j)
    {
        lName[j] = name[i];
    }
*/

    return 0;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)