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)
Other Languages Moderators androksi Posted April 21, 2017 Other Languages Moderators Posted April 21, 2017 Use string.len if (string.len(name) <= 4) then
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.
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
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.
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