Jump to content

Bloquear Mensagens say


Recommended Posts

function BloquearChat(message)
				outputChatBox("#FF0000[ERRO] #FFFFFF Chat desativado! Use o somente o chat local! Apertando a letra 'U' ", source, 255, 255, 255, true)
				cancelEvent()
end
addEventHandler("onPlayerChat", root, BloquearChat)

 Tenta ai (Freeroam desativado please)

Link to comment

Recomendo deixar apenas pra funcionar no chat "say"

function Block_Chat (_, messageType)
	if messageType == 0 then
		cancelEvent()      
		outputChatBox ("#00ff00✘ #ffffffINFO #00ff00✘➺ #ffffffImpossivel Utilizar o #00ff00T #ffffffComo Chat, Utilize A Tecla #00FF00U #ffffffPara Se Comunicar com Jogadores Local", source, 255,255,255,true)
	end
end
addEventHandler("onPlayerChat", root, Block_Chat)

 

  • Thanks 1
Link to comment
On 16/03/2019 at 01:55, joaolamar said:

Quando o cara mandar uma mensagem no say a mensagem não ia aparecer a mensagem ia ser bloqueada e ia aparecer somente pra ele uma mensagem ex: CHAT LOCAL APERTANDO "U"  HELP!

Mais fácil seria, mas leia o que o garoto pediu :D 

  • Like 1
Link to comment
On 19/03/2019 at 10:12, #DeltaSCR said:

@Sr Black Não seria mais fácil você utilizar um Chat Local na Letra "T"?

Sim até fiz um chat local mas os / estão aparecendo no chat ex: aperto a letra "T" pra colocar uma senha de base ai aparece lá, Queria tipo um chat local que com os comandos que vc da nao aparece vc consegue?

Edited by joaolamar
Link to comment
1 hour ago, #DeltaSCR said:

Olá @joaolamar, pode me mostrar como está seu código?

chat_range=50
  
addEventHandler("onPlayerJoin",getRootElement(), 
function () 
bindKey(source,"t","down","chatbox","LocalChat") 
end) 
  
addEventHandler("onResourceStart",getResourceRootElement(getThisResource()), 
function () 
for index, player in pairs(getElementsByType("player")) do 
bindKey(player,"t","down","chatbox","LocalChat") 
  end 
end) 
  
function isPlayerInRangeOfPoint(player,x,y,z,range) 
   local px,py,pz=getElementPosition(player) 
   return ((x-px)^2+(y-py)^2+(z-pz)^2)^0.5<=range 
end 
  
function onChat(player,_,...) 
  local px,py,pz=getElementPosition(player) 
  local msg = table.concat({...}, " ") 
  local nick=getPlayerName(player) 
local r,g,b = getTeamColor(getPlayerTeam(player)) 
  for _,v in ipairs(getElementsByType("player")) do 
    if isPlayerInRangeOfPoint(v,px,py,pz,chat_range) then 
      outputChatBox("#838B83[ #FF0000Chat Local #838B83] "..nick..": #ffffff"..msg,v,r,g,b,true) 
    end 
  end 
end 
addCommandHandler("LocalChat",onChat) 

 

Edited by joaolamar
Link to comment
On 27/03/2019 at 09:32, #DeltaSCR said:

usa o Evento onPlayerChat e cancela o chat original

Vc pode me mandar certinho por favor? não sou muito experiente em .lua sou apenas iniciante ! 

Se puder mandar o codigo certinho pra mim ficarei agradecido TMJ!

Codigo:

chat_range=50
  
addEventHandler("onPlayerJoin",getRootElement(), 
function () 
bindKey(source,"t","down","chatbox","LocalChat") 
end) 
  
addEventHandler("onResourceStart",getResourceRootElement(getThisResource()), 
function () 
for index, player in pairs(getElementsByType("player")) do 
bindKey(player,"t","down","chatbox","LocalChat") 
  end 
end) 
  
function isPlayerInRangeOfPoint(player,x,y,z,range) 
   local px,py,pz=getElementPosition(player) 
   return ((x-px)^2+(y-py)^2+(z-pz)^2)^0.5<=range 
end 
  
function onChat(player,_,...) 
  local px,py,pz=getElementPosition(player) 
  local msg = table.concat({...}, " ") 
  local nick=getPlayerName(player) 
local r,g,b = getTeamColor(getPlayerTeam(player)) 
  for _,v in ipairs(getElementsByType("player")) do 
    if isPlayerInRangeOfPoint(v,px,py,pz,chat_range) then 
      outputChatBox("#838B83[ #FF0000Chat Local #838B83] "..nick..": #ffffff"..msg,v,r,g,b,true) 
    end 
  end 
end 
addCommandHandler("LocalChat",onChat) 

 

Edited by joaolamar
Link to comment

Exemplo que está na wiki:

 

-- define our chat radius
local chatRadius = 20 --units

-- define a handler that will distribute the message to all nearby players
function sendMessageToNearbyPlayers(message, messageType)
    -- we will only send normal chat messages, action and team types will be ignored
    if messageType == 0 then
        -- get the chatting player's position
        local posX1, posY1, posZ1 = getElementPosition(source)

        -- loop through all player and check distance
        for id, player in ipairs(getElementsByType("player")) do
            local posX2, posY2, posZ2 = getElementPosition(player)
            if getDistanceBetweenPoints3D(posX1, posY1, posZ1, posX2, posY2, posZ2) <= chatRadius then
                outputChatBox(message, player)
            end
        end
    end
    -- block the original message by cancelling this event
    cancelEvent()
end
-- attach our new chat handler to onPlayerChat
addEventHandler( "onPlayerChat", getRootElement(), sendMessageToNearbyPlayers )

Se ler a wiki, conseguirá fazer facil... tem vários exemplos lá!

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...