21.05.2016, 18:46
pawn Код:
public OnPlayerConnect(playerid)
{
new NombreP[MAX_PLAYER_NAME];
GetPlayerName(playerid, NombreP, sizeof(NombreP));
if(!NameCheck(NombreP))
{
SendClientMessage(playerid, -1, "Tu nombre debe contener el formato: Nombre_Apellido.");
SetTimerEx("Expulsar", 500, 0, "i", playerid);
return 1;
}
return 1;
}
forward Expulsar(playerid);
public Expulsar(playerid)
{
if(IsPlayerConnected(playerid)) Kick(playerid);
}
stock NameCheck(const source[]) // Hecho por Konstantinos.
{
new length = strlen(source);
if (!(3 <= length <= 20)) return 0;
new pos = strfind(source, "_");
if (pos == -1) return 0;
new us_count;
for (new i; i != length; ++i)
{
switch (source[i])
{
case '_': ++us_count;
}
if (!i || i == pos + 1)
{
switch (source[i])
{
case 'A' .. 'Z': continue;
default: return 0;
}
}
else if (i && i != pos && i != pos + 1)
{
switch (source[i])
{
case 'a' .. 'z': continue;
default: return 0;
}
}
}
return (us_count == 1 && source[length - 1] != '_');
}