09.03.2019, 18:24
Estou tentando colocar para apenas o player logar com Nome_Sobrenome, se ele logar com outro formato desse vai ser kickado Ex: Nome_Sobrenome_ mas nгo estou conseguindo, alguйm pode me ajudar?
IsValidNick(const string[])
{
new UnderLine,Mark = 0;
for(new i; i < strlen(string); i++)
{
if((string[i] < 'A' || string[i] > 'Z') && (string[i] < 'a' || string[i] > 'z') && string[i] != '_')
return false;
if(string[i] == '_')
{
UnderLine++;
Mark = i+1;
if(UnderLine > 1)
return false;
}
}
if(UnderLine == 0)
return false;
if((string[Mark] < 'A' || string[Mark] > 'Z') && (string[Mark] < 'a' || string[Mark] > 'z'))
return false;
return true;
}
Invalidos: ArthuR_SandovAL Murilo_ Joao_Silva045 Validos: Arthur_Sandoval Murilo_Silva
public OnPlayerConnect(playerid)
{
new
nome[MAX_PLAYER_NAME];
GetPlayerName(playerid, nome, MAX_PLAYER_NAME);
if(CheckPlayerNick(nome) == 0){
SendClientMessage(playerid, -1, "Info: Vocк foi kickado pois seu nick nгo se encontra nos padrхes do servidor.");
SendClientMessage(playerid, -1, "Info: Nick padrгo 'Nome_Sobrenome'");
Kick(playerid);
}
return 1;
}
CheckPlayerNick(text[])
{
for(new a; a < strlen(text); ++a)
{
if(text[a] == '_') return 1;
}
return 0;
}