PHP код:
stock IsValidRoleplayName(const name[]) {
if (!name[0] || strfind(name, "_") == -1)
return 0;
else for (new i = 0, len = strlen(name); i != len; i ++) {
if ((i == 0) && (name[i] < 'A' || name[i] > 'Z'))
return 0;
else if ((i != 0 && i < len && name[i] == '_') && (name[i + 1] < 'A' || name[i + 1] > 'Z'))
return 0;
else if ((name[i] < 'A' || name[i] > 'Z') && (name[i] < 'a' || name[i] > 'z') && name[i] != '_' && name[i] != '.')
return 0;
}
return 1;
}
PHP код:
public OnPlayerConnect(playerid)
{
new Name[128];
GetPlayerName(playerid, Name, sizeof(Name));
if(!IsValidRoleplayName(Name))
{
SendClientMessage(playerid, -1, "You were kicked because of your name. The server only accepts character names, i.e Kendrick_Lamar.");
KickEx(playerid);
return false;
}
return true;
}