Jump to content

Chat Repetitivo


Recommended Posts

1 hour ago, Rut said:

Se você deseja fazer um bate-papo personalizado, desative qualquer recurso que use o evento onPlayerChat

Eu estou desenvolvendo um servidor RP, consequentemente preciso de um chat RP para o mesmo, porém quando eu ativo o chat RP, ele duplica as mensagens. 

 

Há a possibilidade de criar um script de se no T, a mensagem não começar com / dar um outputchatbox de erro? 

Link to comment
15 minutes ago, +snts said:

Eu estou desenvolvendo um servidor RP, consequentemente preciso de um chat RP para o mesmo, porém quando eu ativo o chat RP, ele duplica as mensagens. 

 

Há a possibilidade de criar um script de se no T, a mensagem não começar com / dar um outputchatbox de erro? 

 

Se você tiver problemas com o seu código, você deve publicá-lo. Quanto ao bate-papo com a tecla T, você deve usar o evento 'onPlayerChat' com um outputChatBox e cancelar o evento. Aqui está um exemplo que fornece o mesmo wiki do MTA:

 

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

 

Link to comment
30 minutes ago, Rut said:

 

Se você tiver problemas com o seu código, você deve publicá-lo. Quanto ao bate-papo com a tecla T, você deve usar o evento 'onPlayerChat' com um outputChatBox e cancelar o evento. Aqui está um exemplo que fornece o mesmo wiki do MTA:

 


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

 

Existe a maneira de no próprio script do chat RP cancelar o envio repetitivo? 

Link to comment
2 hours ago, +snts said:

Existe a maneira de no próprio script do chat RP cancelar o envio repetitivo? 

se você não tiver dificuldade em ler, verá que eu lhe disse para cancelar o evento onPlayerChat para adicionar um outputChatBox e não repeti-lo com o chat padrão

Link to comment
  • Moderators

Pode ser um conflito entre dois resources com o evento onPlayerChat.

Para tirar essa dúvida você pode rodar esse código no servidor:

-- Lado server
function onPreFunction( sourceResource, eventName, eventSource, eventClient, luaFilename, luaLineNumber, ... )
    if eventName == "onPlayerChat" then
        local resname = sourceResource and getResourceName(sourceResource)
        local args = { ... }

        info = { resource = resname, event = eventName, script = luaFilename, linha = luaLineNumber, arguments = args }
        iprint( info )
    end
end
addDebugHook( "preEvent", onPreFunction)

Crie e ligue o resource com esse código, reproduza a duplicação no chat e veja as informações no seu debug (/debugscript 3). Você pode copiar as informações pelo Console (do cliente e do server).

Também será melhor você postar aqui o código do chat RP que você mesmo disse estar usando.

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