titan_boy Posted April 1, 2015 Share 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 Link to comment
Anubhav Posted April 1, 2015 Share 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. Link to comment
titan_boy Posted April 1, 2015 Author Share Posted April 1, 2015 @Anubhav thx i will test it. Link to comment
titan_boy Posted April 1, 2015 Author Share Posted April 1, 2015 no its not working the error: WARNING: Script 'Scriptname\thefile' is not encoded in UTF-8. Loading as ANSI... Link to comment
Castillo Posted April 1, 2015 Share 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. Link to comment
titan_boy Posted April 1, 2015 Author Share Posted April 1, 2015 Solidsnake14 you know how to make it? Link to comment
Castillo Posted April 1, 2015 Share 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 %. Link to comment
titan_boy Posted April 1, 2015 Author Share Posted April 1, 2015 oh ok Solidsnake14 thank you again! 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