FoxG^ Posted March 16, 2019 Share Posted March 16, 2019 (edited) 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! Edited March 16, 2019 by joaolamar Link to comment
Jonas^ Posted March 16, 2019 Share Posted March 16, 2019 CancelEvent + OutputChatBox ? OBS: Poste na sessão correta da próxima vez. Link: Programação em Lua Link to comment
Blaack Posted March 19, 2019 Share Posted March 19, 2019 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
#DaNiLiN Posted March 19, 2019 Share Posted March 19, 2019 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) 1 Link to comment
#DeltaSCR Posted March 19, 2019 Share Posted March 19, 2019 @Sr Black Não seria mais fácil você utilizar um Chat Local na Letra "T"? 1 Link to comment
#DaNiLiN Posted March 19, 2019 Share Posted March 19, 2019 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 1 Link to comment
Blaack Posted March 20, 2019 Share Posted March 20, 2019 On 19/03/2019 at 11:17, #DaNiLiN said: Mais fácil seria, mas leia o que o garoto pediu Exato Link to comment
FoxG^ Posted March 27, 2019 Author Share Posted March 27, 2019 (edited) 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 March 27, 2019 by joaolamar Link to comment
#DeltaSCR Posted March 27, 2019 Share Posted March 27, 2019 (edited) Olá @joaolamar, pode me mostrar como está seu código? Edited March 27, 2019 by #DeltaSCR Link to comment
FoxG^ Posted March 27, 2019 Author Share Posted March 27, 2019 (edited) 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 March 27, 2019 by joaolamar Link to comment
#DeltaSCR Posted March 27, 2019 Share Posted March 27, 2019 usa o Evento onPlayerChat e cancela o chat original 1 Link to comment
FoxG^ Posted April 1, 2019 Author Share Posted April 1, 2019 (edited) 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 April 1, 2019 by joaolamar Link to comment
Blaack Posted April 1, 2019 Share Posted April 1, 2019 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
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