Names _
#1

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
Reply
#2

Yes, use strfind for this.
Reply
#3

Код:
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;
	}
PS : if i helped you Dont forget to Rep
Reply
#4

Quote:
Originally Posted by BigBaws
Посмотреть сообщение
if(!NameIsRP(plname))
^fail. Where is this function, eh?
Код:
 
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;
}
put this onplayerconnect
Код:
 
if(!IsValidRPName(playerid))
{
		    SendClientMessage(playerid,0xFF000000, "Change name asshole, this is an RP server");
		    Kick(playerid);
}
Reply
#5

Made this quirckly, it gonna make their names valid's for rp servers.

pawn Код:
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);
Reply
#6

Are you aware that players can join with @, $ and dots in their name as well? Not to mention numbers.
Reply
#7

forgot about it.

pawn Код:
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;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)