Firstname_Lastname?
#9

I made one more advanced all-in-one checker. It detects all characters which roleplay name shouldn't have, make sure name has only one '_' in it and it also properly capitalizes name.

pawn Код:
forward NameValidator(playerid);
public NameValidator(playerid)
{
    if(IsPlayerConnected(playerid))
    {
      new pname[MAX_PLAYER_NAME],underline=0;
      GetPlayerName(playerid, pname, sizeof(pname));
      if(strfind(pname,"[",true) != (-1)) return 0;
      else if(strfind(pname,"]",true) != (-1)) return 0;
      else if(strfind(pname,"$",true) != (-1)) return 0;
      else if(strfind(pname,"(",true) != (-1)) return 0;
      else if(strfind(pname,")",true) != (-1)) return 0;
      else if(strfind(pname,"=",true) != (-1)) return 0;
      else if(strfind(pname,"@",true) != (-1)) return 0;
      else if(strfind(pname,"1",true) != (-1)) return 0;
      else if(strfind(pname,"2",true) != (-1)) return 0;
      else if(strfind(pname,"3",true) != (-1)) return 0;
      else if(strfind(pname,"4",true) != (-1)) return 0;
      else if(strfind(pname,"5",true) != (-1)) return 0;
      else if(strfind(pname,"6",true) != (-1)) return 0;
      else if(strfind(pname,"7",true) != (-1)) return 0;
      else if(strfind(pname,"8",true) != (-1)) return 0;
      else if(strfind(pname,"9",true) != (-1)) return 0;
      new maxname = strlen(pname);
      for(new i=0; i<maxname; i++)
      {
        if(pname[i] == '_') underline ++;
      }
      if(underline != 1) return 0;
    pname[0] = toupper(pname[0]);
        for(new x=1; x<maxname; x++)
        {
            if(pname[x] == '_') pname[x+1] = toupper(pname[x+1]);
            else if(pname[x] != '_' && pname[x-1] != '_') pname[x] = tolower(pname[x]);
        }
        SetPlayerName(playerid, "New_Name");
        SetPlayerName(playerid, pname);
        return 1;
    }
    return 0;
}
Reply


Messages In This Thread
Firstname_Lastname? - by FreddeN - 31.10.2009, 22:09
Re: Firstname_Lastname? - by member - 31.10.2009, 22:13
Re: Firstname_Lastname? - by GhOstY93 - 31.10.2009, 22:16
Re: Firstname_Lastname? - by saiberfun - 31.10.2009, 22:17
Re: Firstname_Lastname? - by member - 31.10.2009, 22:19
Re: Firstname_Lastname? - by saiberfun - 31.10.2009, 22:20
Re: Firstname_Lastname? - by member - 31.10.2009, 22:26
Re: Firstname_Lastname? - by saiberfun - 31.10.2009, 22:29
Re: Firstname_Lastname? - by Sergei - 31.10.2009, 22:38
Re: Firstname_Lastname? - by FreddeN - 01.11.2009, 00:20

Forum Jump:


Users browsing this thread: 1 Guest(s)