25.08.2011, 22:52
Title says it all...
stock IsValidName(playerid)
{
if (IsPlayerConnected(playerid))
{
new player[24];
GetPlayerName(playerid,player,24);
for(new n = 0; n < strlen(player); n++)
{
if (player[n] == '_') return 1;
if (player[n] == ']' || player[n] == '[') return 0;
}
}
return 0;
}
PHP код:
|
You got to be kidding me.....
There are much better exmples else where on the forum. Your function considers anything with a _ as a vailid name, everything thing else fails, as your script does. |
public IsValidName(playerid)
{
new pname[MAX_PLAYER_NAME],underline=0;
GetPlayerName(playerid, pname, sizeof(pname));
if(strfind(pname,"[",true) != (-1)) return 0;
else if(strfind(pname,".",true) != (-1)) return 0;
else if(strfind(pname,"]",true) != (-1)) return 0;
else if(strfind(pname,"$",true) != (-1)) return 0;
else if(strfind(pname,"(",true) != (-1)) return 0;
else if(strfind(pname,")",true) != (-1)) return 0;
else if(strfind(pname,"=",true) != (-1)) return 0;
else if(strfind(pname,"@",true) != (-1)) return 0;
else if(strfind(pname,"1",true) != (-1)) return 0;
else if(strfind(pname,"2",true) != (-1)) return 0;
else if(strfind(pname,"3",true) != (-1)) return 0;
else if(strfind(pname,"4",true) != (-1)) return 0;
else if(strfind(pname,"5",true) != (-1)) return 0;
else if(strfind(pname,"6",true) != (-1)) return 0;
else if(strfind(pname,"7",true) != (-1)) return 0;
else if(strfind(pname,"8",true) != (-1)) return 0;
else if(strfind(pname,"9",true) != (-1)) return 0;
new maxname = strlen(pname);
for(new i=0; i<maxname; i++) { if(pname[i] == '_') underline ++; }
if(underline != 1) return 0;
pname[0] = toupper(pname[0]);
for(new x=1; x<maxname; x++)
{
if(pname[x] == '_') pname[x+1] = toupper(pname[x+1]);
else if(pname[x] != '_' && pname[x-1] != '_') pname[x] = tolower(pname[x]);
}
SetPlayerName(playerid, "New_Name");
SetPlayerName(playerid, pname);
return 1;
}
Mhm, My script eh ?, Thats what i have in my Script
PHP код:
|