01.08.2010, 10:50
(
Последний раз редактировалось Kyosaur; 11.08.2011 в 20:26.
)
IsRolePlayName(playerid, bool:alphaonly = true)
by Kyoshiro aka Kyosaur
Since i made the GetRolePlayName, i decided to make this as well. Basically it just tells you if the person is using an rp name (example: Josh_Smith). This function has an optional parameter called alphaonly which if enable will check for invalid characters and numbers (most functions like these will say 'kyo_test_lol' is valid, and even 'ke0h_t3st'...when they aren't). by Kyoshiro aka Kyosaur
Usage:
Код:
if(!IsRolePlayName(playerid)) { SendClientMessage(playerid,0xFF0000FF, "You have to have an rp name to play here ('firstname_lastname')!"); Kick(playerid); }
Code:
pawn Код:
stock IsRolePlayName(playerid, bool:alphaonly = true)
{
new trpn[MAX_PLAYER_NAME];
if(GetPlayerName(playerid,trpn,sizeof(trpn)))
{
new strd = strfind(trpn, "_", false);
if(strfind(trpn,"_",false,strd+1) == -1)
{
if(strd > 0)
{
if(trpn[strd-1] && trpn[strd+1])
{
if(alphaonly)
{
for(new a = 0, l = strlen(trpn); a < l; a++)
{
switch(trpn[a])
{
case '0' .. '9': return 0;
case 'a' .. 'z': continue;
case 'A' .. 'Z': continue;
case '_': continue; // easier than specifying every invalid char
default: return 0;
}
}
}
return 1;
}
}
}
}
return 0;
}