01.11.2010, 20:22
How would I go on about checking username format? So basically if username is in First_Last formart and if there is any numbers in the name?
public OnPlayerConnect(playerid)
{
new
name[24],
string[2];
GetPlayerName(playerid, name, sizeof(name)); // we need player's name
if(sscanf(name, "{p<_>s[12]s[12]}") != 0) // we check if there is a delimiter "_" splitting two strings (name and lastname)
{
SendClientMessage(playerid, 0xFFFFFFFF, "* You have been banned because your nickname didn't have a \"_\"!");
Ban(playerid); // we ban the player if there was no "_"
}
for(new i = 0; i < 10; i ++) // we make a loop from 0 to 9
{
format(string, sizeof(string), "%d", i); // we set "i" (the number being worked) to the string
if(strfind(name, string, true) != -1) // is there any number in "name"?
{
SendClientMessage(playerid, 0xFFFFFFFF, "* You have been banned because your nickname had a number!");
Ban(playerid); // if yes then BAN!!!!!!
}
}
return 1;
}