01.08.2012, 13:48
hello, how can i make a player join with a name of numeric get kicked from the server?
IsNumeric(const string[])
{
for (new i = 0, j = strlen(string); i < j; i++)
{
if (string[i] > '9' || string[i] < '0') return 0;
}
return 1;
}
public OnPlayerConnect(playerid)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,20);
for(new i=0;name[i]!-'\0';++i) if(name[i] >= '0' && name[i] <='9') {SendClientMessage(playerid,-1,"Number's not allowed");
Kick(playerid);
}
}
error 001: expected token: ";", but found "!"
warning 215: expression has no effect
error 001: expected token: ")", but found ";"
error 036: empty statement
fatal error 107: too many error messages on one line
for(new i=0;numname[i]!-'\0';++i)
IsAValidNick(playerid)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
if(strfind(name, "0", true) != -1 || strfind(name, "1", true) != -1 || strfind(name, "2", true) != -1 || strfind(name, "3", true) != -1 || strfind(name, "4", true) != -1 || strfind(name, "5", true) != -1 || strfind(name, "6", true) != -1 || strfind(name, "7", true) != -1 || strfind(name, "8", true) != -1 || strfind(name, "9", true) != -1)
{
return 0;
}
return 1;
}
public OnPlayerConnect(playerid)
{
if(IsAValidNick(playerid) == 0) {
Kick(playerid);
}
return 1;
}
public OnPlayerConnect(playerid)
{
static name[25];
GetPlayerName(playerid,name,25);
for(new i = 0; i != strlen(name); ++i)
{
if(name[i] >= '0' || name[i] < '9') return SendClientMessage(playerid,-1,"no numbers"),Kick(playerid);
}
return 1;
}
public OnPlayerConnect(playerid)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,20);
new bool:HasChar = false;
for(new i=0; name[i]!='\0'; ++i)
if((name[i] >= 'a' && name[i] <='z') || (name[i] >= 'A' && name[i] <='Z'))
{
HasChar = true;
break;
}
if(HasChar == false)
{
SendClientMessage(playerid,-1,"Your name must have an alphabet");
return Kick(playerid);
}
return 1;
}