05.01.2012, 20:05
Hi how to make players only allow to use Name_Surname... ?
if(!IsRolePlayName(playerid))
{
SendClientMessage(playerid,0xFF0000FF, "That's not RolePlay Name! Example: Firstname_Lastname");
Kick(playerid);
}
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;
}
Add this somewhere under OnPlayerConnect:
PHP код:
PHP код:
|