25.07.2017, 02:57
Useful
Example
PHP код:
stock IsValidRPName(name[]) //credits: zLink and base Larceny
{
if(('A' <= name[0] <= 'Z') && ('a' <= name[1] <= 'z'))
{
if(IsValidRPInput(name))
{
if(strfind(name, "_") != -1)
{
new underline = strfind(name, "_"), pos = underline +1;
if(('A' <= name[pos] <= 'Z') && ('a' <= name[pos +1] <= 'z'))
{
for(new i; i < strlen(name); ++i)
{
if(('A' <= name[i] <= 'Z') && (i != 0) && (i != pos)) return 0;
else if((name[i] == '_') && (i != underline)) return 0;
else continue;
}
return 1;
}
}
}
}
return 0;
}
IsValidRPInput(const ipstr[]) //credits: zLink and base PT
{
for(new i = 0; ipstr[i] != EOS; ++i)
{
switch(ipstr[i])
{
case 'A'..'Z', 'a'..'z','_': continue;
default: return 0;
}
}
return 1;
}
Код:
CMD:test(playerid, params[]) { if(isnull(params)) return SendClientMessage(playerid, 0xFF0000FF,"use: /test [your name]"); if(IsValidRPName(params)) { //is valid } else { //not is valid } return 1; }