Strfind [Issue] [0.3c]
#1

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.
Код:
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;
}
This was used in OnPlayerLogin:
Код:
if(GetPlayerInvalidCharacterName(playerid))
{
	SendClientMessage(playerid, COLOR_LIGHTRED, "[SERVER] Your username contains characters which aren't       allowed on this server.");
	Kick(playerid);
}
And this was used to get the seperate firstname and lastname of a player:
Код:
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];
}
Reply


Messages In This Thread
Strfind [Issue] [0.3c] - by Berky - 17.12.2011, 17:21
Re: Strfind [Issue] [0.3c] - by MP2 - 17.12.2011, 17:24
Re: Strfind [Issue] [0.3c] - by Berky - 17.12.2011, 17:27
Re: Strfind [Issue] [0.3c] - by Berky - 17.12.2011, 21:05
Re: Strfind [Issue] [0.3c] - by cessil - 17.12.2011, 22:02
Re: Strfind [Issue] [0.3c] - by Berky - 17.12.2011, 22:27
Re: Strfind [Issue] [0.3c] - by Babul - 17.12.2011, 22:49
Re: Strfind [Issue] [0.3c] - by Berky - 18.12.2011, 16:15
Re: Strfind [Issue] [0.3c] - by Berky - 19.12.2011, 17:50

Forum Jump:


Users browsing this thread: 1 Guest(s)