INVALID NICK. - 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)
+--- Thread: INVALID NICK. (
/showthread.php?tid=361539)
INVALID NICK. -
budelis - 21.07.2012
HI. Where is problem:
Код:
stock InvalidNickKick(playerid)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
new where = strfind(name,"_",true);
new lenght = strlen(name)-1;
new invalid = strfind(name,"[",true);
if(invalid == -1) invalid = strfind(name,"]",true);
if(where == 0 || where == lenght || where==-1)
{
SendClientMessage(playerid,COLOR_ORANGE,"* SERVER: Name_Lastname");
Kick(playerid);
return 1;
}
if(strlen(name[where])<4)
{
SendClientMessage(playerid,COLOR_ORANGE,"* SERVER: your lastname is too short");
Kick(playerid);
return 1;
}
if(where<3)
{
SendClientMessage(playerid,COLOR_ORANGE,"* SERVER: your firstname is too short");
Kick(playerid);
return 1;
}
if(invalid != -1)
{
SendClientMessage(playerid,COLOR_ORANGE,"* SERVER: invalids letters in your name");
Kick(playerid);
return 1;
}
return 0;
}
How to make player can come only with that name:
Because he can come with that nick:
Re: INVALID NICK. -
budelis - 21.07.2012
any help?
Re: INVALID NICK. -
Derelict - 21.07.2012
You need to split the string into individual names (splitting it by the _ in this case) and then ensure that only the first letter of each word (var[0]) is uppercase, and you'd do this by checking it against an array of valid uppercase characters.
Re: INVALID NICK. -
budelis - 22.07.2012
Can you do it?
Re: INVALID NICK. -
[MM]RoXoR[FS] - 22.07.2012
pawn Код:
stock InvalidNickKick(playerid)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
new where = strfind(name,"_",true);
new lenght = strlen(name)-1;
if(where == 0 || where == lenght || where==-1)
{
SendClientMessage(playerid,COLOR_ORANGE,"* SERVER: Name_Lastname");
Kick(playerid);
return 1;
}
if(where<3)
{
SendClientMessage(playerid,COLOR_ORANGE,"* SERVER: your firstname is too short");
Kick(playerid);
return 1;
}
if(length-where<4)
{
SendClientMessage(playerid,COLOR_ORANGE,"* SERVER: your lastname is too short");
Kick(playerid);
return 1;
}
new bool:invalid = false;
if(strfind(name,"[",true,0) != -1|| strfind(name,"]",true,0)!= -1)invalid = true;
if(invalid == true)
{
SendClientMessage(playerid,COLOR_ORANGE,"* SERVER: invalids letters in your name");
Kick(playerid);
return 1;
}
/* Use this if you want to get first and last name.
new fName[20],lName[20];
for(new i=0;name[i]!='_';++i)
{
fName[i] = name[i];
}
new j=0;
for(new i = where+1;name[i]!='\0';++i,++j)
{
lName[j] = name[i];
}
*/
return 0;
}