AnnaBelle Posted April 21, 2017 Posted April 21, 2017 function nameCod(source) name = getPlayerName(source) if (#name >= 4) then cancelEvent() outputChatBox("Seu nome muito curto, minimo 4 letras.", source, 255, 0, 0,true) return end end) addEventHandler("onPlayerJoin",root,nameCod) addEventHandler("onPlayerChangeNick",root,nameCod) addEventHandler("onPlayerConnect",root,nameCod)
androksi Posted April 21, 2017 Posted April 21, 2017 Use string.len if (string.len(name) <= 4) then Hello, world. Tutorial sobre interação de BOTs do Discord com o seu servidor - Visitar (Brazilian Portuguese) Tutorial sobre tabelas - Visitar (Brazilian Portuguese) Tutorial sobre banco de dados - Visitar (Brazilian Portuguese)
DNL291 Posted April 21, 2017 Posted April 21, 2017 O símbolo # também pega o comprimento da string. Só trocar >= (maior ou igual) para < (menor), já que 4 caracteres nesse caso é aceito. Também, remova 'source' do parâmetro e o evento 'onPlayerConnect' é desnecessário. Please do not PM me with scripting related question nor support, use the forums instead.
AnnaBelle Posted April 22, 2017 Author Posted April 22, 2017 testei nos dois modo funcionou,mas na hr de por um nome maior que 4 letras não foi function nameCod() name = getPlayerName(source) if (string.len(name) <= 4) then cancelEvent() outputChatBox("Seu nome muito curto, minimo 4 letras.", source, 255, 0, 0,true) return end end addEventHandler("onPlayerJoin",root,nameCod) addEventHandler("onPlayerChangeNick",root,nameCod)
DNL291 Posted April 22, 2017 Posted April 22, 2017 (edited) Faltou fazer a parte da linha 3, que eu disse: if (#name < 4) then Edited April 22, 2017 by DNL291 Please do not PM me with scripting related question nor support, use the forums instead.
DNL291 Posted April 22, 2017 Posted April 22, 2017 3 minutes ago, DNL291 said: Faltou fazer a parte da linha 3, que eu disse: if (#name < 4) then Se você usar dessa forma, só vai executar a ação se o novo nick for menor que 4 caracteres, não percebi nenhum erro no código. Obs: use /debugscript 3 sempre que testar. Please do not PM me with scripting related question nor support, use the forums instead.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now