mojira.dev
BDS-23029

The .label method of the ModalFormData class is pushing null into the first index of the formValues[] array, leading to an error in the variable position.

The problem is in

formCreateClan.label("Preencha os campos abaixo para criar seu clã");

The problem is that the method is pushing the formValues array.

[2026-02-23 02:39:10:019 INFO] [Scripting] [null,"priem","segund",false]

I am an amateur programmer, but I believe it is unnecessary for the .label method to occupy the first index of the formValues array with null.

Follow my code to create a clan

Because const clanName = response.formValues[0]; was receiving undefined

const clanTag = response.formValues[1]; The clan name

const isPrivate = response.formValues[2]; Received the tag instead of a bool

const formCreateClan = new ModalFormData();

        formCreateClan.title("Criar Clã");
        formCreateClan.label("Preencha os campos abaixo para criar seu clã"); // Esse metodo ta empurrando o array do formValues[]
        formCreateClan.textField("Nome do Clã", "Digite o nome do seu clan"); //0
        formCreateClan.textField("Tag do Clan", "Digite a tag do seu clan"); //1
        formCreateClan.toggle("privar clan");//2
        //.toggle("Clan privado?", false) talves de para o futuro, por enquanto so tem clan publico
        formCreateClan.show(player).then((response) => {
            if (response.canceled) return;
            else {
            const clanName = response.formValues[0];
            const clanTag = response.formValues[1];
            const isPrivate = response.formValues[2];

            const clan_criado = {
                nome : clanName,
                tag : clanTag,
                isprivate : isPrivate
            }
            player.addTag(`clan_${clan_criado.tag}`);
            player.setDynamicProperty("doclan", clan_criado.nome);
            player.setDynamicProperty("nivelClan", 3);//nivel 3 para lider do clan
            
            console.log("Retorna " + typeof(clan_criado.nome));
            console.log("variavel " + typeof(clan_criado.nome), clanName);
            //save(clan_criado, "clan.json");
            player.sendMessage(`Você criou o clan ${clan_criado.nome} com a tag ${clan_criado.tag} e privacidade ${clan_criado.isprivate}`);
            }
            //aqui vai a logica para criar o clan, como verificar se o nome e tag ja existe, 
            // criar o clan no banco de dados, adicionar o jogador como lider do clan, etc
        });
        
    
    

Comments 0

No comments.

GhostLixo

(Unassigned)

Plausible

Retrieved