Jump to content

help please! i need your help!


Recommended Posts

  
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 by Guest
Link to comment
  
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
  
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
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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...