Advertisement
Guest User

Untitled

a guest
Apr 27th, 2017
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1.  
  2. local bad_names = {
  3. con = true,
  4. prn = true,
  5. aux = true,
  6. nul = true,
  7. }
  8.  
  9. for i=1,9 do
  10. bad_names["com" .. tostring(i)] = true
  11. bad_names["lpt" .. tostring(i)] = true
  12. end
  13.  
  14. local bad_characters = { "<", ">", ":", "\"", "/", "\\", "|", "?", "*" }
  15.  
  16. local function has_bad_character(name)
  17. for _, char in ipairs(bad_characters) do
  18. if name:find(char, 1, true) then
  19. return true
  20. end
  21. end
  22. return false
  23. end
  24.  
  25. local function is_bad_name(name)
  26. return bad_names[string.lower(name)] or has_bad_character(name)
  27. end
  28.  
  29. minetest.register_on_prejoinplayer(function(name)
  30. if is_bad_name(name) then
  31. return "No meme names allowed"
  32. end
  33. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement