How to make a Roleplay name checker on PHP? - 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: How to make a Roleplay name checker on PHP? (
/showthread.php?tid=598174)
How to make a Roleplay name checker on PHP? -
SetPlayerNameTag - 09.01.2016
Hello there, I'm actually a starter on PHP. today I want to make a RP name checker for my UCP registration. I tried like 2 hours and searching randomly on ****** I can't find the shit.. Who can give me a help? and make a function for me?
I made a function but It does not working!!
PHP код:
function IsValidRPName($string)
{
if( stristr( $string , '_' ) )
$_explodedName = explode( "_" , $string );
else return false;
for ($i = 0; $i < $firstName; $i++)
{
if( !ctype_upper ( $_explodedName[ 0 ][ 0 ] ) )
return false;
else if( !$i )
continue;
else if( ctype_upper( $_explodedName[ 0 ][ $i ] ) )
return false;
}
for ($i = 0; $i < $lastName; $i++)
{
if(!ctype_upper($_explodedName[ 1 ][ 0 ] ) )
return false;
else if( !$i )
continue;
else if( ctype_upper( $_explodedName[ 1 ][ $i ] ) )
return false;
}
if( count( $_explodedName ) < 2 || strlen( $Name[ 0 ] ) < 1 || strlen($_explodedName[ 1 ]) < 1 || strlen( $string ) >= 25 )
return false;
else
return true;
}
Re: How to make a Roleplay name checker on PHP? -
SetPlayerNameTag - 09.01.2016
bump plzzzzzz
Re: How to make a Roleplay name checker on PHP? -
NoDi522 - 09.01.2016
This could help you out:
https://sampforum.blast.hk/showthread.php?tid=309062
Re: How to make a Roleplay name checker on PHP? -
Vince - 09.01.2016
This is not a PHP help forum. Regardless:
PHP код:
function IsValidName($name)
{
return preg_match("/^[A-Z]{1}[A-Za-z]+_[A-Z]{1}[A-Za-z]+$/", $name);
}
Test and experiment with regular expressions here:
http://regexr.com/ and read more about preg_match here:
http://php.net/manual/en/function.preg-match.php