titan_boy Posted April 1, 2015 Posted April 1, 2015 (edited) function acceptedNames ( element ) local text = guiGetText ( element ):gsub ( "%p", "" ) guiSetText ( element, text ) end addEventHandler ( "onClientGUIChanged", theEdit, acceptedNames, false ) can anyone help me with a problem please? i dont want things like #*+=%€ and i use this code but i want to use @ and . in the edit box. but this code is disabling @ and . too Edited April 1, 2015 by Guest
Anubhav Posted April 1, 2015 Posted April 1, 2015 local dis = "# * + = % € $ ! ^ & * ( ) - + =" -- Seperate with space function cleanDisabledWords( str ) local result = str for i, v in ipairs( split( dis, " " ) ) do result = string.gsub( result, v, '' ) end return result end function acceptedNames ( element ) local text = guiGetText ( element ) local nt = cleanDisabledWords( text ) guiSetText ( element, nt ) end addEventHandler ( "onClientGUIChanged", theEdit, acceptedNames, false ) Not tested but should work.
titan_boy Posted April 1, 2015 Author Posted April 1, 2015 no its not working the error: WARNING: Script 'Scriptname\thefile' is not encoded in UTF-8. Loading as ANSI...
Castillo Posted April 1, 2015 Posted April 1, 2015 local dis = "# * + = % € $ ! ^ & * ( ) - + =" -- Seperate with space function cleanDisabledWords( str ) local result = str for i, v in ipairs( split( dis, " " ) ) do result = string.gsub( result, v, '' ) end return result end function acceptedNames ( element ) local text = guiGetText ( element ) local nt = cleanDisabledWords( text ) guiSetText ( element, nt ) end addEventHandler ( "onClientGUIChanged", theEdit, acceptedNames, false ) Not tested but should work. That'll cause a malformed pattern error.
Castillo Posted April 1, 2015 Posted April 1, 2015 local charsString = '#*+=%€$!^&()-+?¿/"' function removeChars ( str, chars ) local s = str:gsub ( "[".. tostring ( chars ) .."]", '' ) return s end function acceptedNames ( element ) local text = guiGetText ( element ) local nt = removeChars ( text, charsString ) guiSetText ( element, nt ) end addEventHandler ( "onClientGUIChanged", theEdit, acceptedNames, false ) This sort of work, but there are characters which don't get removed, such as %.
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