fairyoggy Posted August 20, 2019 Share Posted August 20, 2019 Used dgs tools and there is such an opportunity: https://wiki.multitheftauto.com/wiki/DgsEditSetWhiteList but how to use the same for gui edit ? Link to comment
fairyoggy Posted August 20, 2019 Author Share Posted August 20, 2019 How to do it when you write in guiEdit, for example, the character "A" and it is not written? Link to comment
Rockyz Posted August 20, 2019 Share Posted August 20, 2019 * Not tested local blacklisted = {"A", "a"} local edit = guiCreateEdit(...) function editCheck() local chars = table.concat(blacklisted, ""):gsub("[%(%)%.%%%+%-%*%?%[%^%$]", "%%%1") local editText = guiGetText(source) local replacedText = editText:gsub("["..chars.."]", "") if editText ~= replacedText then guiSetText(source, replacedText) end end addEventHandler("onClientGUIChanged", edit, editCheck, false) 1 Link to comment
fairyoggy Posted August 20, 2019 Author Share Posted August 20, 2019 @#,xiRocKyz local zifr = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0} addEventHandler("onClientGUIChanged", editMoney, function(element) local chars = table.concat(zifr, ""):gsub("[%(%)%.%%%+%-%*%?%[%^%$]", "%%%1") local editText = guiGetText(editMoney) local replacedText = editText:gsub("["..chars.."]", "") if editText == replacedText then guiSetText(source, "") playSoundFrontEnd(2) end end) Used your example. If you type numbers(zifr) into the edit. numbers are displayed - fine If you use other characters, the characters will not be displayed and sound will be played. - fine BUT If you type "1A" , "213FSDFSFS" and etc - It will work. How to fix it? Other characters except "zifr" should not be displayed Link to comment
Rockyz Posted August 20, 2019 Share Posted August 20, 2019 If you want to whitelist the values that is in the table use this code: local zifr = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "0"} function editCheck() local chars = table.concat(zifr, ""):gsub("[%(%)%.%%%+%-%*%?%[%^%$]", "%%%1") local editText = guiGetText(source) local replacedText = editText:gsub("[^"..chars.."]", "") if editText ~= replacedText then guiSetText(source, replacedText) playSoundFrontEnd(2) end end addEventHandler("onClientGUIChanged", editMoney, editCheck, false) If you want to simply whitelist all the numbers use this code: function editCheck() local editText = guiGetText(source) local replacedText = editText:gsub("[^0-9]", "") if editText ~= replacedText then guiSetText(source, replacedText) playSoundFrontEnd(2) end end addEventHandler("onClientGUIChanged", editMoney, editCheck, false) * Both codes are not tested 1 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