Advertisement
Kwarde

"Has player RP name" script

Jun 28th, 2012
301
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.41 KB | None | 0 0
  1. stock RpName(playerid)
  2. {
  3.     new name[MAX_PLAYER_NAME],
  4.         strokeCount,
  5.         firstName[MAX_PLAYER_NAME],
  6.         lastName[MAX_PLAYER_NAME],
  7.         capCount;
  8.     GetPlayerName(playerid, name, MAX_PLAYER_NAME);
  9.     for (new i = 0; i < strlen(name); i++)
  10.     {
  11.         if (!IsLetter(name[0], true)) return false;
  12.         if (name[i] == '[' || name[i] == ']' || name[i] >= '0' && name[i] <= '9' || name[i] == '@') return false;
  13.         if (name[i] == '_')
  14.         {
  15.             strokeCount++;
  16.             if (name[i - 1] == '_' || name[i + 1] == '_') return false;
  17.             if (!IsLetter(name[i + 1], true)) return false;
  18.             strmid(firstName, name, 0, i);
  19.             strmid(lastName, name, i + 1, MAX_PLAYER_NAME);
  20.             for (new b = 0; b < strlen(firstName); b++)
  21.             {
  22.                 if (IsLetter(firstName[b], true))
  23.                     capCount++;
  24.                 if (capCount > 1)
  25.                     return false;
  26.             }
  27.             capCount = 0;
  28.             for (new b = 0; b < strlen(lastName); b++)
  29.             {
  30.                 if (IsLetter(lastName[b], true))
  31.                     capCount++;
  32.                 if (capCount > 1)
  33.                     return false;
  34.             }
  35.         }
  36.     }
  37.     return (strokeCount == 1);
  38. }
  39.  
  40. //And the 'IsLetter' function:
  41. stock IsLetter(const input, bool:capitalOnly = false, bool:lowerCaseOnly = false)
  42. {
  43.     if (capitalOnly)
  44.         return (input >= 'A' && input <= 'Z');
  45.     else if (lowerCaseOnly)
  46.         return (input >= 'a' && input <= 'z');
  47.     else return (input >= 'a' && input <= 'z' || input >= 'A' && input <= 'Z');
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement