SHARE
TWEET

Untitled

a guest Jan 24th, 2020 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     function NickTag:CheckName (name)
  2.        
  3.         --> as nicktag only work internally in the guild, we think that is not necessary a work filter to avoid people using bad language.
  4.        
  5.         -- if (type (name) ~= "string") then
  6.         --  return false, LibStub ("AceLocale-3.0"):GetLocale ("NickTag-1.0")["STRING_ERROR_4"] --> error 4 = name isn't a valid string
  7.         -- end
  8.        
  9.         -- name = trim (name)
  10.        
  11.         -- --> limit nickname to 12 characters, same as wow.
  12.         -- local len = string.len (name)
  13.         -- if (len > 99) then
  14.         --  return false, LibStub ("AceLocale-3.0"):GetLocale ("NickTag-1.0")["STRING_ERROR_1"] --> error 1 = nickname is too long, max of 12 characters.
  15.         -- end
  16.        
  17.         -- --> check if contain any non allowed characters, by now only accpet letters, numbers and spaces.
  18.         -- --> by default wow do not accetp spaces, but here will allow.
  19.         -- --> tested over lua 5.2 and this capture was okey with accents, not sure why inside wow this doesn't work.
  20.         -- local notallow = string.find (name, "[^a-zA-Z�������%s]")
  21.         -- if (notallow) then
  22.         --  return false, LibStub ("AceLocale-3.0"):GetLocale ("NickTag-1.0")["STRING_ERROR_2"] --> error 2 = nickname only support letters, numbers and spaces.
  23.         -- end
  24.        
  25.         -- --> check if there is sequencial repeated characters, like "Jasooon" were repeats 3 times the "o" character.
  26.         -- --> got this from http://stackoverflow.com/questions/15608299/lua-pattern-matching-repeating-character
  27.         -- have_repeated = false
  28.         -- count_spaces = 0
  29.         -- string.gsub (name, '.', '\0%0%0'):gsub ('(.)%z%1','%1'):gsub ('%z.([^%z]+)', check_repeated)
  30.         -- if (count_spaces > 10) then
  31.         --  have_repeated = true
  32.         -- end
  33.         -- if (have_repeated) then
  34.         --  return false, LibStub ("AceLocale-3.0"):GetLocale ("NickTag-1.0")["STRING_ERROR_3"] --> error 3 = cant use the same letter three times consecutively, 2 spaces consecutively or 3 or more spaces.
  35.         -- end
  36.        
  37.         return true
  38.     end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top