06.08.2012, 13:33
Hey can I do something that when a player connects to the server if he have _ between his name like James_Mcay he can register or login but if his name is like James Mcay or James or Doriftar something it kicks him
Public OnPlayerConnect(playerid) { LoggedTime[playerid] = 0; new string[256]; gPlayerLogged[playerid] = 0; gAdminLogged[playerid] = 0; new plname[MAX_PLAYER_NAME],tmpvar; GetPlayerName(playerid, plname, sizeof(plname)); if(!NameIsRP(plname)) { SendClientMessage(playerid, COLOR_WHITE, "Your ServerName: Your name is not applicable on Test Server Dare Devil."); SendClientMessage(playerid, COLOR_YELLOW2, "HINT: Your name must be in the format of Firstname_Lastname."); Kick(playerid); //yes, use Kick here because theres no data to save . ( this is lets player to be kicked after the message (Dare Devil) return 1; }
stock IsValidRPName(playerid) { new name[MAX_PLAYER_NAME]; if(IsPlayerConnected(playerid)) { GetPlayerName(playerid, name, sizeof(name)); for(new i = 0; i < MAX_PLAYER_NAME; i++) { if (name[i] == '_') return 1; if (name[i] == ']' || name[i] == '[') return 0; } } return 0; }
if(!IsValidRPName(playerid)) { SendClientMessage(playerid,0xFF000000, "Change name asshole, this is an RP server"); Kick(playerid); }
stock validname(playerid)
{
static i = -1,name[25];
GetPlayerName(playerid,name,sizeof(name));
while(++i < strlen(name))
{
if(name[i] == '_' && name[i] == '[' && name[i] == ']') strdel(name,i,i+1);
}
return SetPlayerName(playerid,name),i = 0;
}
// just do that on onplayerconnect
validname(playerid);
stock validname(playerid)
{
static i = -1,name[25];
GetPlayerName(playerid,name,sizeof(name));
while(++i < strlen(name))
{
if(name[i] == '_' && name[i] == '[' && name[i] == ']' && name[i] == '@' && name[i] == '$' && name[i] == '.' && name[i] >= '0' && name[i] <= '9') strdel(name,i,i+1);
}
return SetPlayerName(playerid,name),i = 0;
}