stock IsARolePlayName(name[])
{
new
szLastCell,
bool: bUnderScore;
for(new i; i < strlen(name); i++)
{
if(name[i] == '_')
{
if(bUnderScore == true)
{
return 0;
}
bUnderScore = true;
}
else if(!szLastCell || szLastCell == '_') // Check if capitalized where it should be
{
if(name[i] < 'A' || name[i] > 'Z')
{
return 0;
}
}
else
{
if(name[i] < 'a' || name[i] > 'z')
return 0;
}
szLastCell = name[i];
}
if(bUnderScore == false)
return 0;
return 1;
}
Why this must be an include
![]() Btw, well done ![]() |
pawn Код:
![]() |
stock InvalidNick(playerid)
{
if(IsPlayerNPC(playerid)) return 0;
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(invalid == -1) invalid = strfind(name,"'",true);
if(name[0] < 65 || name[0] > 90)
{
SendClientMessage(playerid,COLOR,"* Server: Your name is invalid! The name must start from capital letter.");
SendClientMessage(playerid,COLOR,"* Server: Correct form would be:");
SendClientMessage(playerid,COLOR,"* Server: Name_Surname");
return 1;
}
if(name[where+1] < 65 || name[where+1] > 90)
{
SendClientMessage(playerid,COLOR,"* Server: Your name is invalid! The surname must start from capital letter.");
SendClientMessage(playerid,COLOR,"* Server: Correct form would be:");
SendClientMessage(playerid,COLOR,"* Server: Name_Surname");
return 1;
}
for(new i = 1; i < where-1; i++)
{
if(name[i] < 97 || name[i] > 122)
{
SendClientMessage(playerid,COLOR,"* Server: Your name is invalid! You have capital letters or numbers in the middle of the name.");
SendClientMessage(playerid,COLOR,"* Server: Correct form would be:");
SendClientMessage(playerid,COLOR,"* Server: Name_Surname");
return 1;
}
}
if(where == 0 || where == lenght || where==-1)
{
SendClientMessage(playerid,COLOR,"* Server: Your name is invalid!");
SendClientMessage(playerid,COLOR,"* Server: Correct form would be:");
SendClientMessage(playerid,COLOR,"* Server: Name_Surname");
return 1;
}
if(strlen(name[where])<4)
{
SendClientMessage(playerid,COLOR,"* Server: Your name is invalid! Your surname is too short.");
SendClientMessage(playerid,COLOR,"* Server: Correct form would be:");
SendClientMessage(playerid,COLOR,"* Server: Name_Surname");
return 1;
}
if(where<3)
{
SendClientMessage(playerid,COLOR,"* Server: Your name is invalid! Your name is too short.");
SendClientMessage(playerid,COLOR,"* Server: Correct form would be:");
SendClientMessage(playerid,COLOR,"* Server: Name_Surname");
return 1;
}
if(invalid != -1)
{
SendClientMessage(playerid,COLOR,"* Server: Your name is invalid! Illegal characters found.");
SendClientMessage(playerid,COLOR,"* Server: Correct form would be:");
SendClientMessage(playerid,COLOR,"* Server: Name_Surname");
return 1;
}
for(new i = where+2; i < MAX_PLAYER_NAME; i++)
{
if(name[i] < 97 || name[i] > 122)
{
if(name[i] == 0){i = MAX_PLAYER_NAME; return 0;}
SendClientMessage(playerid,COLOR,"* Server: Your name is invalid! Capital letters or numbers in the middle of the word.");
SendClientMessage(playerid,COLOR,"* Server: Correct form would be:");
SendClientMessage(playerid,COLOR,"* Server: Name_Surname");
return 1;
}
}
return 0;
}