17.12.2011, 17:21
I tried making this to prevent people from replacing the character 'l' with an capitalized 'i'. Unfortunally it didn't go like I expected it to go. I used to code below to make it work and got kicked everytime, even when I used a random name which didn't even have the 'I' or 'i' included.. I basically got the player's first and lastname seperately and checked them for a capitalized 'I', when the 'I' was used but not as first letter it would end up being invalid and result in a kick.
This was used in OnPlayerLogin:
And this was used to get the seperate firstname and lastname of a player:
Код:
stock GetPlayerInvalidCharacterName(playerid) { if(strfind(GetPlayerFirstName(playerid), "I", true) != 0) { printf("Firstname %s.", GetPlayerFirstName(playerid)); printf("Firstname %d.", strfind(GetPlayerFirstName(playerid), "I") != 0); return 1; } if(strfind(GetPlayerLastName(playerid), "I", true) != 0) { printf("Firstname %s.", GetPlayerLastName(playerid)); printf("Lastname %d.", strfind(GetPlayerLastName(playerid), "I") != 0); return 1; } return 0; }
Код:
if(GetPlayerInvalidCharacterName(playerid)) { SendClientMessage(playerid, COLOR_LIGHTRED, "[SERVER] Your username contains characters which aren't allowed on this server."); Kick(playerid); }
Код:
stock GetPlayerFirstName(playerid) { new namestring[2][MAX_PLAYER_NAME]; new name[MAX_PLAYER_NAME]; GetPlayerName(playerid,name,MAX_PLAYER_NAME); split(name, namestring, '_'); return namestring[0]; } stock GetPlayerLastName(playerid) { new namestring[2][MAX_PLAYER_NAME]; new name[MAX_PLAYER_NAME]; GetPlayerName(playerid,name,MAX_PLAYER_NAME); split(name, namestring, '_'); return namestring[1]; }