PauloCascus Posted July 31, 2014 Share Posted July 31, 2014 How i can disallow to use bad signs like: %^&*$#@ and etc when player use registration ? Link to comment
Callum Posted July 31, 2014 Share Posted July 31, 2014 input = input:gsub("[^%w]","") Where 'input' is the text the user input (collected with guiGetText). %w is the character class for alphanumeric characters. ^%w means all characters that aren't alphanumeric. Link to comment
PauloCascus Posted July 31, 2014 Author Share Posted July 31, 2014 input = input:gsub("[^%w]","") Where 'input' is the text the user input (collected with guiGetText). %w is the character class for alphanumeric characters. ^%w means all characters that aren't alphanumeric. thank you ) Link to comment
PauloCascus Posted July 31, 2014 Author Share Posted July 31, 2014 (edited) input = input:gsub("[^%w]","") Where 'input' is the text the user input (collected with guiGetText). %w is the character class for alphanumeric characters. ^%w means all characters that aren't alphanumeric. oh my god i have the problem, i'm stupid i need to add at the server side something like: if ( username == input:gsub("[^%w]","")) then .................. ............................................... else outputChatBox("Choose another username, you can't use signs like: )(*&^%$#@!" ...... end ? or if (username:gsub("[^%w]","")) then lol i have tested this like if ( username == username:gsud("[^%w]","")) then and when i'm tried to register username like Paulo, i've got, Choose another username When i have tried to use $%^&, i have registered When i use $%^&Paulo registered too Edited July 31, 2014 by Guest Link to comment
cheez3d Posted July 31, 2014 Share Posted July 31, 2014 Use %W instead of ^%w. As for your problem: if username:find("%W") then outputChatBox("Your name contains invalid characters!"); else -- Valid username; end; Link to comment
PauloCascus Posted July 31, 2014 Author Share Posted July 31, 2014 Use %W instead of ^%w.As for your problem: if username:find("%W") then outputChatBox("Your name contains invalid characters!"); else -- Valid username; end; if username:find("%w") then if (accountAdded) then exports.gtc:sendMessage("You have successfully registered. Username: " .. username .. ", password: " .. password .. " ",0,255,0, source ) triggerClientEvent(source,"hideRegisterWindow",getRootElement()) end else triggerClientEvent(source,"set_warning_text",getRootElement(),"MG:RP Register","Choose a different username or password.") end i have added this, i thought that's it's working but when i'm type only characters like: $%^, i've got error message that you name is invalid, but when i've used Paulo$%^, i 'm registered Link to comment
cheez3d Posted July 31, 2014 Share Posted July 31, 2014 if not username:find("%W") then if (accountAdded) then exports.gtc:sendMessage("You have successfully registered. Username: "..username..", Password: "..password,0,255,0,source); triggerClientEvent(source,"hideRegisterWindow",source); end; else triggerClientEvent(source,"set_warning_text",source,"MG:RP Register","Choose a different username or password."); end; 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