Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- stock RpName(playerid)
- {
- new name[MAX_PLAYER_NAME],
- strokeCount,
- firstName[MAX_PLAYER_NAME],
- lastName[MAX_PLAYER_NAME],
- capCount;
- GetPlayerName(playerid, name, MAX_PLAYER_NAME);
- for (new i = 0; i < strlen(name); i++)
- {
- if (!IsLetter(name[0], true)) return false;
- if (name[i] == '[' || name[i] == ']' || name[i] >= '0' && name[i] <= '9' || name[i] == '@') return false;
- if (name[i] == '_')
- {
- strokeCount++;
- if (name[i - 1] == '_' || name[i + 1] == '_') return false;
- if (!IsLetter(name[i + 1], true)) return false;
- strmid(firstName, name, 0, i);
- strmid(lastName, name, i + 1, MAX_PLAYER_NAME);
- for (new b = 0; b < strlen(firstName); b++)
- {
- if (IsLetter(firstName[b], true))
- capCount++;
- if (capCount > 1)
- return false;
- }
- capCount = 0;
- for (new b = 0; b < strlen(lastName); b++)
- {
- if (IsLetter(lastName[b], true))
- capCount++;
- if (capCount > 1)
- return false;
- }
- }
- }
- return (strokeCount == 1);
- }
- //And the 'IsLetter' function:
- stock IsLetter(const input, bool:capitalOnly = false, bool:lowerCaseOnly = false)
- {
- if (capitalOnly)
- return (input >= 'A' && input <= 'Z');
- else if (lowerCaseOnly)
- return (input >= 'a' && input <= 'z');
- else return (input >= 'a' && input <= 'z' || input >= 'A' && input <= 'Z');
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement