bad nickname - 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 nickname (
/showthread.php?tid=204308)
bad nickname -
dud - 29.12.2010
i need some code or filterscript if player dont have RP nickname
if he have Name_Surename he can play
everything else get kick
anyone know some script for this?
Re: bad nickname -
TouR - 29.12.2010
if oyu search you gonna find about 50 thread which will help you
Re: bad nickname -
KotoK - 29.12.2010
Use this.
Код:
new namestring = strfind(plname, "_", true);
if(namestring == -1)
{
SendClientMessage(playerid, colorid, "Your name must be in the Name_Surname format.");
Kick(playerid);
return 1;
}
Re: bad nickname -
dud - 29.12.2010
dude i search i dont find nothing i find something like
nick_nick kick
if dont have _ kick
but kick evrything except Nick_Nick i dont find
Re: bad nickname -
Voldemort - 29.12.2010
Here is one realy badass non RP name Kicker
It kicks, who dont have _ in name, name lenght shorter than 6, if there will any number, or wont be name first letter capital and surname first letter capital.
pawn Код:
new username[24];
GetPlayerName(playerid,username,sizeof(username));
new name1 = strfind(username, "kill", true);
new name2 = strfind(username, "__", true);
new name3 = strfind(username, "123", true);
new name4 = strfind(username, "asd", true);
new name5 = strfind(username, "xx", true);
if(name1 != -1 || name2 != -1 || name3 != -1 || name4 != -1 || name5 != -1)
{
SendClientMessage(playerid,COLOR_WARN,"WARNING: You don't have valid Role Play Name, in SA:MP client change it to right format: Name_Surname.");
Kick(playerid);
return 1;
}
pawn Код:
IsValidRPName(rpname[])
{
if(strfind(rpname,"_",true) == -1) { return 0; }
if(strlen(rpname) < 6) { return 0; }
new pos;
while(pos <= strlen(rpname))
{
new str[5];
for(new lenght = 0; lenght < 10; lenght++)
{
format(str,sizeof(str),"%d",lenght);
if(strfind(rpname[pos],str,true) != -1)
{
return 0;
}
}
pos++;
}
new part[2][12];
new name,surname;
split(rpname,part,'_');
if(part[0][0] >= 'A' && part[0][0] <= 'Z')
{
name = 1;
}
if(part[1][0] >= 'A' && part[1][0] <= 'Z')
{
surname = 1;
}
if(name == 1 && surname == 1)
{
return 1;
}
else
{
return 0;
}
}
Example
pawn Код:
if(!IsValidRPName(username))
{
SendClientMessage(playerid,COLOR_WARN,"WARNING: You don't have valid Role Play Name, in SA:MP client change it to right format: Name_Surname.");
Kick(playerid);
return 1;
}
Re: bad nickname -
Nero_3D - 29.12.2010
Just wrote that as improved version of the above code now
- Each name must start with a capital and go on with lower case letters
- Names are separted with underscores
- No limit with names, means "Don_Fernando_Flores" as example is valid
pawn Код:
stock IsValidRPName(name[])
{ //Nero_3D © 12.2010
new idx = strfind(name, "_", false);
if((idx != -1) && ('A' <= name[0] <= 'Z') && ('A' <= name[idx + 1] <= 'Z')) {
new i = 1;
while(i != idx) {
switch(name[i]) {
case 'a'..'z': i++;
default: return 0;
}
}
for(i += 2; ; ) {
switch(name[i]) {
case 'a'..'z': i++;
case '_': return IsValidRPName(name[idx + 1]);
case EOS: return 1;
default: return 0;
}
}
}
return 0;
}