Lenny

IsARolePlayName with name filter

Dec 1st, 2011
570
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.03 KB | None | 0 0
  1. new DisallowedNames[][MAX_PLAYER_NAME] = {
  2.     "Harry_Potter",
  3.     "Barack_Obama",
  4.     "Michael_Jackson"
  5. };
  6.  
  7. stock IsARolePlayName(name[])
  8. {
  9.     new
  10.                 szLastCell,
  11.         bool:   bUnderScore;
  12.        
  13.     for(new i; i < strlen(name); i++)
  14.     {
  15.         if(name[i] == '_')
  16.         {
  17.             if(bUnderScore == true)
  18.             {
  19.                 return 0;
  20.             }
  21.            
  22.             bUnderScore = true;
  23.         }
  24.        
  25.         else if(!szLastCell || szLastCell == '_') // Check if capitalized where it should be
  26.         {
  27.             if(name[i] < 'A' || name[i] > 'Z')
  28.             {
  29.                 return 0;
  30.             }
  31.         }
  32.        
  33.         else
  34.         {
  35.             if(name[i] < 'a' || name[i] > 'z')
  36.                 return 0;
  37.         }
  38.        
  39.         szLastCell = name[i];
  40.     }
  41.    
  42.     if(bUnderScore == false)
  43.         return 0;
  44.        
  45.     for(new i; i < sizeof(DisallowedNames); i++)
  46.     {
  47.         if(!strcmp(name, DisallowedNames[i]))
  48.         {
  49.             return 0;
  50.         }
  51.     }
  52.    
  53.     return 1;
  54. }
  55.  
Advertisement
Add Comment
Please, Sign In to add comment