SA-MP Forums Archive
Bad nick/name (RP name) - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Bad nick/name (RP name) (/showthread.php?tid=71827)



Bad nick/name (RP name) - Typhome - 04.04.2009

How i do .. ?

If anyone come to server nick: jack_kodama and will be kick, it need Jack_Kodama not jack_kodama
and hblddlld will be kick only Name_Lastname

How ?


Re: Bad nick/name (RP name) - HB - 04.04.2009

I'm not so sure about the capital letters. Though you might want to search for the firstname_lastname. I'm sure its mentioned somewhere.


Re: Bad nick/name (RP name) - Lastman - 04.04.2009

[font=courier new] From Carlitos RPG - Developer Norn. Firstname_Lastname
Code:
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];
}

RPName(name[],ret_first[],ret_last[])
{
	new len = strlen(name),
		point = -1,
		bool:done = false;
	for(new i = 0; i < len; i++)
	{
	  if(name[i] == '_')
	  {
	    if(point != -1) return 0;
	    else {
				if(i == 0) return 0;
				point = i + 1;
			}
	  } else if(point == -1) ret_first[i] = name[i];
	  else {
			ret_last[i - point] = name[i];
			done = true;
		}
	}
	if(!done) return 0;
	return 1;
}

public OnPlayerConnect(playerid)
{
new first[MAX_PLAYER_NAME], last[MAX_PLAYER_NAME];
if(RPName(PlayerName(playerid),first,last))
{
SendClientMessage(playerid,COLOR_YELLOW,"Welcome to My server");
}
else
{
KickPlayer(playerid,"System","Invalid Name, Correct Format: Firstname_lastname.");
}
return 1;
}