InFerNo_01 Posted June 6, 2013 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
Castillo Posted June 6, 2013 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. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Castillo Posted June 6, 2013 Posted June 6, 2013 You're welcome. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
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