• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Meaningless Names

chucky91

Advanced OT User
Joined
Apr 8, 2010
Messages
284
Solutions
9
Reaction score
154
Meaningless names when creating characters!
Im using this script that prevents me from creating a character with repeated and equal syllables,
and triple characters, but it still needs improvements.
If anyone is willing to improve!


1689768955272.png

1689768941891.png


PHP:
if(!blockString($name) || !blockNames($name)){
        error_("Your name contains blocked words.");
        error_(Validator::getLastError());
    }

function blockString($texto) {
    $vog = array('a', 'e', 'i', 'o', 'u');
    $t = strlen($texto);
    $count_char = 0;
    $count_vog = 0;
    $t_vog = false;

    for ($i = 0; $i < $t; $i++) {
        $letraAtual = strtolower($texto[$i]);

        if (in_array($letraAtual, $vog)) {
            $t_vog = true;
            $count_vog++;
            $count_char = 0;

            if ($count_vog >= 3) {
                return false;
            }
        } else {
            $count_char++;
            $count_vog = 0;

            if ($count_char >= 3) {
                return false;
            }
        }
    }

    if (!$t_vog) {
        return false;
    }

    return true;
}
function blockNames($name) {
    
    $w1 = str_split($name, 2);
    $wordCount = array_count_values($w1);

    foreach ($wordCount as $word => $count) {
        if (strlen($word) === 2 && $count > 3) {
            return false;
        }
    }
    $w2 = explode(' ', $name);
    $wordCount2 = array_count_values($w2);

    foreach ($wordCount2 as $w2 => $count2) { // if one word more 4 char for repeat more 1, blocked.
        if (strlen($word) >= 2 && $count2 > 1) {
            return false;
        }
    }
    return true;
}
 
Back
Top