"IsRoleplayName();"-Function - 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: "IsRoleplayName();"-Function (
/showthread.php?tid=388803)
"IsRoleplayName();"-Function -
'Pawno. - 30.10.2012
Hello.
I'm searching for a little function to check if the string is a roleplay-name.
It also checks how many "_" or "." are in the String.
It should be only 1 "_" or "." ^^
And the first name must be 2 or more letters.
No numbers in the name.
Only "John_Smith", "Joe_Smith" ect.
The Function should be like this:
IsRoleplayName(name[]); - Return "true" if yes
or
IsRoleplayName(playerid); - Return "true" if yes
^^
Thanx :*
Re: "IsRoleplayName();"-Function -
[HK]Ryder[AN] - 30.10.2012
pawn Код:
new plname[MAX_PLAYER_NAME];
GetPlayerName(playerid, plname, sizeof(plname));
new namestring = strfind(plname, "_", true);
if(namestring == -1)
{
return false;
}
else
{
return true;
}
Untested
Re: "IsRoleplayName();"-Function -
tyler12 - 30.10.2012
PHP код:
stock IsRoleplayName(playerid)
{
new pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(pName));
new namestring = strfind(pName, "_", true);
if(namestring == -1)
{
SendClientMessage(playerid, 0xFF0000C8, "Your name isґnt a RP format.");
Kick(playerid);
}
return 1;
}
Re: "IsRoleplayName();"-Function -
'Pawno. - 30.10.2012
But then, they can do Names like:
_Sk1llz0r_
-.-
Re: "IsRoleplayName();"-Function -
[HK]Ryder[AN] - 30.10.2012
Use this stock then
pawn Код:
stock IsARolePlayName(name[])
{
new
szLastCell,
bool: bUnderScore;
for(new i; i < strlen(name); i++)
{
if(name[i] == '_')
{
if(bUnderScore == true)
{
return 0;
}
bUnderScore = true;
}
else if(!szLastCell || szLastCell == '_') // Check if capitalized where it should be
{
if(name[i] < 'A' || name[i] > 'Z')
{
return 0;
}
}
else
{
if(name[i] < 'a' || name[i] > 'z')
return 0;
}
szLastCell = name[i];
}
if(bUnderScore == false)
return 0;
return 1;
}
It returns 0 if false and 1 if true
Re: "IsRoleplayName();"-Function -
'Pawno. - 30.10.2012
Thanx
But what about using "_" and "." concurrently?