Jump to content

como bloqueia os codigos de cores na mensagem do chat?


Recommended Posts

function removeHex(s)
    if type(s) == "string" then
        while(string.find(s, "#%x%x%x%x%x%x")) do
            s = string.gsub(s, "#%x%x%x%x%x%x","")
        end
    end
    return s
end

addEventHandler('onPlayerChangeNick', root, function(old, new)
    local noHex = removeHex(new)
    if noHex ~= new then
        cancelEvent()
    end
end)

addEventHandler('onPlayerJoin', root, function()
    local pName = getPlayerName(source)
    local newNick = removeHex(pName)
    if newNick ~= pName then
        setPlayerName(source, newNick)
    end
end)

Essas funções eu usei para bloquear os codigos de cores Hex do nome dos players no chat, Só que eu não tou conseguindo bloquear as cores das binds dos players e tirar aquele monte de letra colorida horrível do chat usando essas mesma função, alguem pode me ajudar ?

Edited by OrrutoSCR
Link to comment
function removeHex(s)
    if type(s) == "string" then
        while(string.find(s, "#%x%x%x%x%x%x")) do
            s = string.gsub(s, "#%x%x%x%x%x%x","")
        end
    end
    return s
end

addEventHandler('onPlayerChangeNick', root, function(old, new)
    local noHex = removeHex(new)
    if noHex ~= new then
        cancelEvent()
    end
end)

addEventHandler('onPlayerJoin', root, function()
    local pName = getPlayerName(source)
    local newNick = removeHex(pName)
    if newNick ~= pName then
        setPlayerName(source, newNick)
    end
end)

addEventHandler("onPlayerChat", root, function(message, messageType)
	if message and messageType == 0 then
		cancelEvent()
		outputChatBox(removeHex(getPlayerName(source))..": #FFFFFF"..removeHex(message), root, 255, 255, 255, true )
	end
end)

EDIT: Não testei

  • Thanks 1
Link to comment
15 minutes ago, Tommy. said:

function removeHex(s)
    if type(s) == "string" then
        while(string.find(s, "#%x%x%x%x%x%x")) do
            s = string.gsub(s, "#%x%x%x%x%x%x","")
        end
    end
    return s
end

addEventHandler('onPlayerChangeNick', root, function(old, new)
    local noHex = removeHex(new)
    if noHex ~= new then
        cancelEvent()
    end
end)

addEventHandler('onPlayerJoin', root, function()
    local pName = getPlayerName(source)
    local newNick = removeHex(pName)
    if newNick ~= pName then
        setPlayerName(source, newNick)
    end
end)

addEventHandler("onPlayerChat", root, function(message, messageType)
	if message and messageType == 0 then
		cancelEvent()
		outputChatBox(removeHex(getPlayerName(source))..": #FFFFFF"..removeHex(message), root, 255, 255, 255, true )
	end
end)

EDIT: Não testei

Testei aqui, não deu certo n tbm

56 minutes ago, MesaDowN said:

Cara, posta o código do chat, não tem como te ajudar sem o codigo completo..

-- Config do Chat Local

function removeHex(s)
    if type(s) == "string" then
        while(string.find(s, "#%x%x%x%x%x%x")) do
            s = string.gsub(s, "#%x%x%x%x%x%x","")
        end
    end
    return s
end

addEventHandler('onPlayerChangeNick', root, function(old, new)
    local noHex = removeHex(new)
    if noHex ~= new then
        cancelEvent()
    end
end)

addEventHandler('onPlayerJoin', root, function()
    local pName = getPlayerName(source)
    local newNick = removeHex(pName)
    if newNick ~= pName then
        setPlayerName(source, newNick)
    end
end)

addEventHandler("onPlayerChat", root, function(message, messageType)
	if message and messageType == 0 then
		cancelEvent()
		outputChatBox(removeHex..(getPlayerName(source))..": #FFFFFF"..removeHex..(message), root, 255, 255, 255, true )
	end
end)

addEventHandler("onPlayerChat", root, function(tresc, msgtype)
if (msgtype == 0) then
    cancelEvent()
	local x,y,z = getElementPosition(source)
	for key, gracze in ipairs(getElementsByType("player")) do
	local x2,y2,z2 = getElementPosition(gracze)

	if getElementData (source, "ChatLocal:Delay", true) then 
	outputChatBox ( MensagemFalandoRapidoDemaisLocal, source, 255, 255, 255, true ) return end 

	if ( getDistanceBetweenPoints3D ( x, y, z, x2, y2, z2 ) < DistanciaDoChatLocal ) then
	local int = getElementInterior   ( source )
	local dim = getElementDimension  ( source )
	local int2 = getElementInterior  ( gracze )
	local dim2 = getElementDimension ( gracze )
	if ( int == int2 and dim == dim2 ) then
	
	conta = getAccountName ( getPlayerAccount ( source ) )

	if isObjectInACLGroup ("user."..conta, aclGetGroup ( "Console" ) ) then
	outputChatBox("* #FF7F00("..hours..":"..minutes..":"..second..")  #FF7F00- #ffffff"..getPlayerName(source).. "("..getElementData(source, "ID")..")#FF7F00 - #FF7F00 "..tresc, gracze, 255, 255, 255, true)

esse ai é o meu chat

Link to comment
6 minutes ago, Tommy. said:

Tenta isso:
 


	outputChatBox("* #FF7F00("..hours..":"..minutes..":"..second..")  #FF7F00- #ffffff"..getPlayerName(source).. "("..getElementData(source, "ID")..")#FF7F00 - #FF7F00 "..removeHex(tresc), gracze, 255, 255, 255, true)

 

Nicee! Deu certooo, se eu colocar..removehex tbm no global e anonimo ele funciona tbm ? 

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...