Renazz

Editar chat "t"

Recommended Posts

Posted (edited)

Olá estou criando um servidor 100% focado no RP puro. então para forçar os players a usarem o "Z" para falar e fazerem RP , eu queria saber como deixar o chat "T" unicamente para uso de comandos por exemplo:

O player quando escrever alguma palavra no chat ela não vai aparecer de jeito nenhum para o outro jogador ,

porém se ele usar um comando irá funcionar , se alguem poder me ajudar fico muito agradecido!

Edited by Renazz

Share this post


Link to post
Posted (edited)

Então, coloque o chat twitter como principal, onde nele você pode usar os comandos enviar mensagens normalmente etc, e o chat deepweeb pra conversar somente.

Edited by Jonas^
  • Thanks 1

Share this post


Link to post

1. Você deve achar aonde esta esse chat do 't' ai que você diz.

  • Thanks 1

Share this post


Link to post

Mas no chat 't' está saindo alguma mensagem quando você digita algo e da enter?

  • Thanks 1

Share this post


Link to post

sim , é o chat padrão do mta. eu aperto "t" digito e ai dou enter  e a mensagem aparece

Share this post


Link to post

Então, você tem que achar aonde ta esse código provavelmente esta no seu freeroam.

  • Thanks 1

Share this post


Link to post

consegui vlw!

consegui não , esse chat do twitter não dá pra usar comandos.

Share this post


Link to post

Aperte 't' e envie uma mensagem tire print e mostre aqui por favor, poste a print.

  • Thanks 1

Share this post


Link to post

chat_range=100 

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 MensagemTwitter(source, cmd, ...) 
    local MessagemT = table.concat ( { ... }, " " )
    local name = getPlayerName(source); 
for _,v in ipairs(getElementsByType("player")) do 
    outputChatBox("᠉  #00BFFFTwitter- #ffffff"..name.."#00BFFF - #FFFFFF"..MessagemT,v, 255, 255, 255, true) 
    end 
end 
addCommandHandler("Twitter",  MensagemTwitter)
  
addCommandHandler( "DeepWeb", function ( source, cmd, ... )            
    local message2 = #{...} > 0 and table.concat({...}," ") or nil
    if message2 then
        for _, p in ipairs (getElementsByType("player")) do
            if hasObjectPermissionTo(p, "command.mute", true) then
                outputChatBox("᠉ #696969 DeepWeb- #696969"..message2, p, 255, 255, 255, true)
            else
                outputChatBox("᠉ #696969 DeepWeb- #696969"..message2, p, 255, 255, 255, true)
            end
        end
    else
    end
end )

addEventHandler("onPlayerJoin", getRootElement(),  
function() 
  bindKey(source, "t", "down", "chatbox", "Twitter")
end 

addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), function() 
  for index,player in pairs(getElementsByType("player")) do 
        bindKey(player,"t", "down", "chatbox", "Twitter")
  end 
end 

addEventHandler("onPlayerJoin", getRootElement(),  
function() 
  bindKey(source, "u", "down", "chatbox", "DeepWeb")
end 

addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), function() 
  for index,player in pairs(getElementsByType("player")) do 
        bindKey(player,"u", "down", "chatbox", "DeepWeb")
  end 
end 

está junto com o outro chat (DeepWeb)

Share this post


Link to post
Posted (edited)

Tenta assim:

local chat_range = 100 

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 
 
addEventHandler ("onPlayerChat", root,
	function (msg, type)
		if type == 0 then
			cancelEvent ()
			local mainChatDelay = 1000
			if chatTime[source] and chatTime[source] + mainChatDelay > getTickCount() then
				return	outputChatBox ("Não floode....", source, 255, 50, 50, true)
			else
				chatTime[source] = getTickCount()
			end			
			if isObjectInACLGroup ("user."..getAccountName(getPlayerAccount(source)), aclGetGroup ("Everyone")) then
				outputChatBox("᠉  #00BFFFTwitter- #ffffff"..getPlayerName(source).."#00BFFF - #FFFFFF"..msg, root, 255, 255, 255, true) 
			end	
		end
	end
)
  
addCommandHandler ("DeepWeb", function (source, cmd, ...)            
	local message2 = #{...} > 0 and table.concat({...}," ") or nil
	if message2 then
		local everybody = getElementsByType("player")
		for _, p in ipairs (everybody) do
			if hasObjectPermissionTo(p, "command.mute", true) then
				outputChatBox("᠉ #696969 DeepWeb- #696969"..message2, p, 255, 255, 255, true)
			end	
		end
	end
end)

addEventHandler ("onPlayerJoin", getRootElement(),  
	function () 
		bindKey(source, "u", "down", "chatbox", "DeepWeb")
	end
) 

addEventHandler ("onResourceStart", resourceRoot, 
	function () 
		local everybody = getElementsByType("player")
		for index, player in pairs(everybody) do 
			bindKey(player,"u", "down", "chatbox", "DeepWeb")
		end 
	end
) 

 

Edited by Jonas^
Edit
  • Thanks 2

Share this post


Link to post
Posted (edited)

agora ficou sem funcionar nenhum.

ficou só o chat padrão.

Edited by Renazz

Share this post


Link to post

Editei, tente novamente, acho que você esta com o chat padrão do freeroam ativo, você tem que tirar ele colega.

  • Thanks 1

Share this post


Link to post

blz agora quando digito no chat padrão só vai os comandos e as palavras que eu escrevo não vai era isso que queria , mas agora voce removeu a tecla para abrir o chat twitter kk

Share this post


Link to post
local chat_range = 100 

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 
 
addEventHandler ("onPlayerChat", root,
	function (msg, type)
		if type == 0 then
			cancelEvent ()
		end	
	end
)
function MensagemTwitter (source, cmd, ...) 
	local MessagemT = table.concat ( { ... }, " " )
	local name = getPlayerName(source); 
	local everybody = getElementsByType("player")
	for _, v in ipairs(everybody) do 
		outputChatBox("᠉  #00BFFFTwitter- #ffffff"..name.."#00BFFF - #FFFFFF"..MessagemT, v, 255, 255, 255, true) 
	end 
end 
addCommandHandler ("Twitter", MensagemTwitter)

addCommandHandler ("DeepWeb", function (source, cmd, ...)            
	local message2 = #{...} > 0 and table.concat({...}," ") or nil
	if message2 then
		local everybody = getElementsByType("player")
		for _, p in ipairs (everybody) do
			if hasObjectPermissionTo(p, "command.mute", true) then
				outputChatBox("᠉ #696969 DeepWeb- #696969"..message2, p, 255, 255, 255, true)
			end	
		end
	end
end)

addEventHandler ("onPlayerJoin", getRootElement(),  
	function () 
		bindKey (source, "u", "down", "chatbox", "DeepWeb")
		bindKey (source, "o", "down", "chatbox", "Twitter")
	end
) 

addEventHandler ("onResourceStart", resourceRoot, 
	function () 
		local everybody = getElementsByType("player")
		for index, player in pairs(everybody) do 
			bindKey (player,"u", "down", "chatbox", "DeepWeb")
			bindKey (player,"o", "down", "chatbox", "Twitter")
		end 
	end
) 

 

  • Thanks 1

Share this post


Link to post
Posted (edited)
6 minutes ago, Renazz said:

exatamente isso , muito obrigado pela ajuda!

Se poder deixar um thanks como agradecimento em minhas respostas agradeço <=3

Só clicar no icone de coração xD

Edited by Jonas^
  • Thanks 1

Share this post


Link to post

com licença...falando em chat acho que o meu tem algo errado, nao funciona

 

-chat_client.lua

chatGUI = { 
    button = {x}, 
    edit = {},
}

chatbox = {
    {"Bem-vindo ao chat!","INFO"},
    {"Pressione 'X' para escrever "," INFO"},
    {"Nosso grupo -" ,"INFO"},
    {"Наш сайт: dayz-start.ru","INFO"},
}
local otChat = 0
local show = false
local show_gui = false
local sobbe = 1 --// 1 Global // 2 group // 3 radio
local sW,sH = guiGetScreenSize()
local chatRadius = 15

function startRollMessage(text, r, g, b)
    table.insert(chatbox,{text,"ATENÇÃO",133,53,53})
end
addEvent("onRollMessageStart", true)
addEventHandler("onRollMessageStart", getLocalPlayer(), startRollMessage)


function startRollMessage2(head,text, r, g, b)
    table.insert(chatbox,{text,"ATENÇÃO",133,53,53})
end
addEvent("displayClientInfo", true)
addEventHandler("displayClientInfo", getLocalPlayer(), startRollMessage2)

function drawChat()
    if not getElementData(getLocalPlayer(),"logedin") then return end

    if getKeyState("enter") == true and show_gui == true then
        sendMes()
    end    
    sY = 0
    for i=1, #chatbox do
        if i > 6 then
            table.remove(chatbox,1)
        end
        if getElementData ( localPlayer, "GPS" ) >= 1 then
        wm = dxGetTextWidth(chatbox[2],1.02,"default-bold")
        dxDrawRectangle(sW*0.005, sH*0.5+sY, wm+10, 17,tocolor(chatbox[3],chatbox[4], chatbox[5],230))
        nick = dxDrawText(chatbox[2]..": ",sW*0.007, sH*0.5+sY, 150, 30, tocolor ( 255,255,255,255), 1.02, "default" )-- apelido de saída
        wn = dxGetTextWidth(chatbox[2]..": ",1.02,"default-bold")
        dfx2 = dxDrawText(chatbox[1], sW*0.011+wn, sH*0.5+sY, 150, 30, tocolor ( 255,255,255,230), 1.02, "default-bold" )
        --guiSetProperty(chatGUI.button[2], "NormalTextColour", "FFAAAAAA")
        -- saída de mensagem    
        else
        
            wm = dxGetTextWidth(chatbox[2],1.02,"default-bold")
        dxDrawRectangle(sW*0.005, sH*0.8+sY, wm+10, 17,tocolor(chatbox[3],chatbox[4], chatbox[5],230))
        nick = dxDrawText(chatbox[2]..": ",sW*0.007, sH*0.8+sY, 150, 30, tocolor ( 255,255,255,255), 1.02, "default" )-- apelido de saída
        wn = dxGetTextWidth(chatbox[2]..": ",1.02,"default-bold")
        dfx2 = dxDrawText(chatbox[1], sW*0.011+wn, sH*0.8+sY, 150, 30, tocolor ( 255,255,255,230), 1.02, "default-bold" )
        
        
        
        
        --guiSetProperty(chatGUI.button[2], "NormalTextColour", "FFAAAAAA")
        -- saída de mensagem    
end        
        sY = sY + 20
    end 
end
addEventHandler("onClientRender",getRootElement(),drawChat)


bindKey("x","down",function()
    createdGUI()
    if show_gui == false then
        creatChat()
        sobbe = 1
    --else
        --closeChat()
    end    
end)


--[[bindKey("u","down",function()
local posX, posY, posZ = getElementPosition( source )
        local chatSphere = createColSphere( posX, posY, posZ, chatRadius )
        local nearbyPlayers = getElementsWithinColShape( chatSphere, "player" )
        destroyElement( chatSphere )
    createdGUI()
    if show_gui == false then
        creatChat()
        sobbe = 2
    end    
    for index, nearbyPlayer in ipairs( nearbyPlayers ) do
    if source == nearbyPlayer then
    table.insert(chatbox,{"Você não é um membro.!","",255,0,255,"","Servidor"})
    end
end)--]]

function createdGUI()
    if show == false then
      -- if getElementData ( localPlayer, "GPS" ) >= 1 then
        chatGUI.button[2] = guiCreateButton((sW/2-sW/2)+325, sH/2+70, sW*0.054, sH*0.022, "FECHAR", false)
        form1s = guiCreateLabel((sW/2-sW/2)+113, sH/2+50,sW*0.15, sH*0.022, "Digite a mensagem:", false)
        chatGUI.edit[1] = guiCreateEdit((sW/2-sW/2)+110, sH/2+70, sW*0.15, sH*0.022, "", false) 
                guiSetProperty(chatGUI.button[2], "NormalTextColour", "FFAAAAAA")

        --end
        --guiSetProperty(chatGUI.button[2], "NormalTextColour", "FFAAAAAA")
        guiSetInputMode("no_binds_when_editing")
        guiBringToFront( chatGUI.edit[1] )
        guiEditSetCaretIndex( chatGUI.edit[1], 1 )
        setTimer(function ()
        guiSetText ( chatGUI.edit[1], "" )
        end,50,1)
        show = true
        

        
        addEventHandler("onClientGUIClick",chatGUI.button[2],closeChat,false)
        guiEditSetMaxLength(chatGUI.edit[1],42)
    end
end

bindKey("enter","down",function()
sendMes()
end)

function sendMes()
    if show_gui == true then
        local text = guiGetText(chatGUI.edit[1])
        if otChat ~= 0 then return end
        if pregFind(text, "([0-9]{1,3})[^[:digit:]^[:cntrl:]]{1,3}([0-9]{1,3})[^[:digit:]^[:cntrl:]]{1,3}([0-9]{1,3})[^[:digit:]^[:cntrl:]]{1,3}([0-9]{1,3})") then return end
        if string.len(text) <= 0 then closeChat() return end
        triggerServerEvent("sendMessage",resourceRoot,getLocalPlayer(),"",text,sobbe)
        closeChat()
        otChat = 3
    end    
end
function updateChat()
    if otChat > 0 then 
        otChat = otChat - 1 
    end
end
setTimer(updateChat,1000,0)

function creatChat()
    guiSetVisible(chatGUI.button[2],true)
    guiSetVisible(chatGUI.edit[1],true)
    guiSetVisible(form1s,true)

        if getElementData ( localPlayer, "GPS" ) > 0 then
 guiSetPosition (chatGUI.button[2], sW*0.16, sH*0.47,false )
     guiSetPosition (form1s, sW*0.008, sH*0.45, false)
     guiSetPosition (chatGUI.edit[1], sW*0.006, sH*0.47, false )
     else
     
     
     
      guiSetPosition (chatGUI.button[2], sW*0.16, sH*0.77,false )
     guiSetPosition (form1s, sW*0.008, sH*0.75, false)
     guiSetPosition (chatGUI.edit[1], sW*0.006, sH*0.77, false )
     end--]]
    setElementData(getLocalPlayer(),"enteredChat",true)
    showCursor(true)
    show_gui = true
    guiBringToFront( chatGUI.edit[1] )
    guiEditSetCaretIndex( chatGUI.edit[1], 1 )
    guiSetAlpha ( chatGUI.edit[1], 0.7 )
setTimer(function ()
    guiSetText ( chatGUI.edit[1], "" )
        end,50,1)

end

function closeChat()

--guiSetVisible(chatGUI.button[1],false)
    guiSetVisible(chatGUI.button[2],false)
    guiSetVisible(chatGUI.edit[1],false)
    guiSetVisible(form1s,false)
    setElementData(getLocalPlayer(),"enteredChat",false)
    showCursor(false)
    show_gui = false
end

function addNewMessage(msg,name)
    table.insert(chatbox,{name,msg})
end
addEvent("addNewMessage",true)
addEventHandler("addNewMessage",getRootElement(),addNewMessage)

 

-chat_server.lua

function setNewChat(thePlayer, cmd, message, sobbe)
    msg = string.gsub(table.concat ( { message }, " " ),"","")
    local name =  string.gsub(getPlayerName(thePlayer),"#%x%x%x%x%x%x","")
    if sobbe == 1 then
        if (isObjectInACLGroup("user." ..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup("Admin"))) then
            r,g,b = 209,10,10
            triggerClientEvent(root,"addNewMessage",root,name,msg,r,g,b)
            outputServerLog("[Chat][Admin]"..name..": "..msg)
            outputConsole("[Chat][Admin]"..name..": "..msg)
        else
            r,g,b = 209,10,10
            if msg == "/kill" then
            triggerClientEvent(root,"addNewMessage",root,name,"está funcionando",r,g,b)
            end
            triggerClientEvent(root,"addNewMessage",root,name,msg,r,g,b)
            outputServerLog("[Chat]"..name..": "..msg)
            outputConsole("[Chat]"..name..": "..msg)
            --triggerClientEvent(root,"addNewMessage",root,name,msg,r,g,b,"","[-------------]")
        end
    elseif sobbe == 2 then
        local gangname = getElementData(thePlayer,"gang")
        if getElementData(thePlayer,"gang") == "None" then return end
        for i, player in ipairs(getElementsByType("player")) do
            if gangname == getElementData(player,"gang") then
                r,g,b = 255,255,0
                triggerClientEvent(root,"addNewMessage",root,name,msg,r,g,b,"","[Группа] ")
            end    
        end    
    end    
    cancelEvent()
end
addEvent("sendMessage",true)
addEventHandler("sendMessage",getRootElement(),setNewChat)

local root = getRootElement()
 
addEventHandler("onPlayerLogin", root,
    function()
        triggerClientEvent ( "onRollMessageStart", getRootElement(), getPlayerName(source).." logado!",255,255,255, "join")
    end
)

addEventHandler('onClientPlayerJoin', root,
    function()
        triggerClientEvent ( "onRollMessageStart", getRootElement(), getPlayerName(source).." juntou к игре!",255,255,255, "join")
    end
)


addEventHandler('onClientPlayerQuit', root,
    function()
            triggerClientEvent ( "onRollMessageStart", getRootElement(), getPlayerName(source).." fora do jogo!",255,255,255, "join")
    end
)

 

-meta

<meta>
  <info author="gabriel" type="misc" version="1.3.1" />
  <script src="chat_client.lua" />
  <script src="chat_server.lua" />

</meta>
 

 

 

 

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.