BulleTTime Posted May 19, 2009 Posted May 19, 2009 Anyone knows why there are special character like "$" not working with the following code: gButtons.bet_input = guiCreateEdit( 0.605, 0.965, 0.07, 0.0225, "other", true ) guiEditSetMaxLength (gButtons.bet_input, 128 ) characterBlackList = {"Q","W","E","R","T","Y","U","I","O","P","A","S","D","F","G","H","J","K","L","M","N","B","V","C","X","Z","q","w","e","r","t","y","u","i","o","p","a","s","d","f","g","h","j","k","l","z","x","c","v","b","n","m","|","!","@","#","$","%","^","&","*","(",")","-","=","+","_" } addEventHandler("onClientGUIChanged", gButtons.bet_input, function(element) for c,l in ipairs (characterBlackList) do if (string.find(guiGetText(element),l)) then local text = string.gsub(guiGetText(element),l,"") guiSetText(element,text) end end end)
darkdreamingdan Posted May 20, 2009 Posted May 20, 2009 Because it accepts a Lua pattern, which means you'll need to escape it. Either way, you can save yourself a lot of code by simply doing this: addEventHandler("onClientGUIChanged", gButtons.bet_input, function(element) local text = guiGetText(element) if not tonumber( text ) then local changedText = string.gsub(text,"%D","") if changedText ~= text then guiSetText ( element, changedText ) end end 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