Karoffe Posted May 21, 2014 Share Posted May 21, 2014 (edited) SOLVED Edited May 21, 2014 by Guest Link to comment
tosfera Posted May 21, 2014 Share 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 Link to comment
Karoffe Posted May 21, 2014 Author Share 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 ? Link to comment
tosfera Posted May 21, 2014 Share 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", "" ); Link to comment
Karoffe Posted May 21, 2014 Author Share 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) Link to comment
csiguusz Posted May 21, 2014 Share Posted May 21, 2014 function containsNumber ( str ) if str:find ( "%d" ) then return true end return false end 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