tosfera Posted May 21, 2014 Posted May 21, 2014 you can use gsub to replace something in a centain word or sentence, let say the players name for roleplay servers; local name = "angelica_mitten":gsub ( "_", " " ) This will replace _ with a space, transforming Angelica_Mitten into Angelica Mitten. You can use this as a bad word filter too. read all about it on the lua wiki; http://lua-users.org/wiki/StringLibraryTutorial
Karoffe Posted May 21, 2014 Author Posted May 21, 2014 Firstly if i am going to change everyone's name entering the server if he has a "_" to "" then how can i even check if he has "_", secondly how to apply this example on many typing characters, for example if i want to avoid everyone from typing numbers in mainchat ?
tosfera Posted May 21, 2014 Posted May 21, 2014 Well, the function itself already checks if there is a _ in the given string. So don't worry about that, you should rename players without the underscore. Just remove it while typing etc. To remove numbers you can use the parameter %W like this; local name = name:gsub ( "%W", "" );
Karoffe Posted May 21, 2014 Author Posted May 21, 2014 Well, actually i wanted if someone changing his nick to something that contains numbers then a gui shows telling him that he couldn't change his nick to that name. i wanted gsub to automatically change it without numbers So, how to check the entered nick if it contains numbers or not(without changing it)
csiguusz Posted May 21, 2014 Posted May 21, 2014 function containsNumber ( str ) if str:find ( "%d" ) then return true end return false end
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