noonbr Posted May 28, 2020 Posted May 28, 2020 Quero remover a cor do nome dos jogadores que tentarem entrar no servidor, estou usando este código. addEventHandler("onPlayerJoin", getRootElement(), function() local nome = getPlayerName(source) local novoNome = removeHex(nome, 6) if (novoNome ~= nome) then setPlayerName(source, novoNome) end end Infelizmente não tive resultado satisfatório.
MrKAREEM Posted May 28, 2020 Posted May 28, 2020 (edited) usar string.gsub addEventHandler("onPlayerJoin", getRootElement(), function() local nome = getPlayerName(source) local novoNome = string.gsub( nome, '#%x%x%x%x%x%x', '' ) if (novoNome ~= nome) then setPlayerName(source, novoNome) end end Edited May 28, 2020 by MrKAREEM 1
Other Languages Moderators androksi Posted May 28, 2020 Other Languages Moderators Posted May 28, 2020 function removeHex(str) local nString = str while string.find(nString, "#%x%x%x%x%x%x") do nString = string.gsub(nString, "#%x%x%x%x%x%x", "") end return nString end Código correto que deve ser usado, para que os jogadores não possam burlar, usando duas cores. 2
noonbr Posted May 28, 2020 Author Posted May 28, 2020 Obrigado senhores, mas tem outro problema: o jogador pode alterar o nome quando quiser e pode colocar a cor do nome novamente, como faço para que quando ele tentar colocar a cor do nome, interceptá-lo?
Other Languages Moderators androksi Posted May 28, 2020 Other Languages Moderators Posted May 28, 2020 addEventHandler("onPlayerChangeNick", root, function(_, new) if string.find(new, "#%x%x%x%x%x%x") then -- Checa se contém código de cor cancelEvent() -- Cancela a alteração do nickname outputChatBox("* Não é permitido o uso de código de cor no nickname.", source, 255, 0, 0) end end) 1
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