Jump to content

Not Allowed Characters in Player's Nickname


'LinKin

Recommended Posts

Posted

Hello,

I want to make a validation so that if a character that is NOT accepted by MTA as a possible player's nick part it outputs an error.

So like this:

if theNick:find("%W") then 

In that case, it will detect if there are non-alphanumerical characters present.

But how could I make an exeption so that it accepts some non-alphanumerical characters that are allowed by MTA?

For example a player can set his nick to |SW|'~(L)inKin. and MTA will accept it as the player's nick, but it does contain non-alphanumerical characters. Accepted symbols are: \|@#~!"$%&/()[]=?+*-.'

However player's nick cannot contain these symbols: º ñ ç · and some others

So which pattern for string.find should I use in this case?

Thanks

Need a clanwar script? Click here!

Do you want some free scripts for your DD server? Visit my website.

Posted

I'm not sure if this would work (don't have time to test it) but you could atleast try it.

  
local charTable = {["\\"] = true, ["|"] = true, ["/"] = true, ["@"] = true, ["#"] = true, ["~"] = true, ["!"] = true, ["\""] = true, ["$"] = true, ["%"] = true, ["&"] = true, ["("] = true, [")"] = true, ["["] = true, ["]"] = true, ["="] = true, ["?"] = true, ["+"] = true, ["-"] = true, ["*"] = true, ["."] = true, ["'"] = true} 
if newNick:find("%W") and not charTable[newNick:find("%W")] then 
  

Basically you add all the allowed characters in a table, and then check that if a non-alphanumerical character is found and it's not in the table then you cancel it.

  • Like 1

Yes, this is infact a signature.

Posted

Tested these two examples but any of them is giving a 100% result.

So I was thinking to make a custom table in which I'd put the symbols that are accepted, but how can I check if a character from a string matches with any of the symbols previously defined?

Basically, how can I loop character by character into an string?

Need a clanwar script? Click here!

Do you want some free scripts for your DD server? Visit my website.

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...