Hey there, I've got a challenge where I need to verify whether a string consists only of letters from a predefined alphabet. If not, my bot kicks players from the game. I've come up with the following script:
var letters =
"a b c d e f g h i j k l m n o p q r s t u v w x y z";
var arrayLetters = letters.split(/ +/);
var allLetters = arrayLetters.map((x) => x.toLowerCase());
if (!allLetters.some((x) => player.name.includes(x)) {
room.kickPlayer("Your name can't have strange fonts");
}
While this code works for names that don't contain any letters at all, it falls short when dealing with names that contain a mix of valid and invalid characters.
For instance, πππ§ππ
would be kicked out, but ππnda
wouldn't because it includes some valid letters from the predefined array. How can I modify this script to account for this scenario and keep players with valid names in the game?
Appreciate any suggestions or solutions you may have!