InFerNo_01 Posted June 6, 2013 Share Posted June 6, 2013 Hello, I would like to check a string (in a name) to see if the name contains 2 capital letters like for exemple Charlie_Chapplin. I've already done that (it's for a RP server): addEventHandler("onPlayerJoin", root, function() local playerName = getPlayerName( source ) if string.find(playerName, "#") or not string.find(playerName, "_") then kickPlayer ( source, "Invalid Name" ) end spawn(source) end ) Thank's in advance Link to comment
Castillo Posted June 6, 2013 Share Posted June 6, 2013 addEventHandler ( "onPlayerJoin", root, function ( ) local playerName = getPlayerName ( source ) if string.find ( playerName, "#" ) or not string.find ( playerName, "_" ) then kickPlayer ( source, "Invalid Name" ) else local playerNameSplitted = split ( playerName, "_" ) if ( isStringFirstLetterUppercase ( playerNameSplitted [ 1 ] ) and isStringFirstLetterUppercase ( playerNameSplitted [ 2 ] ) ) then spawn ( source ) else kickPlayer ( source, "Invalid Name" ) end end end ) function isStringFirstLetterUppercase ( str ) local letter = str:sub ( 1, 1 ) return ( letter:upper ( ) == letter ) end Try it. Link to comment
InFerNo_01 Posted June 6, 2013 Author Share Posted June 6, 2013 It works, thanks a lot! Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now