Jump to content

Duvida De como cria um chat local


Recommended Posts

Posted

Então to fazendo um script de chat,eu fiz e deu tudo certo,só não conseguir fazer o local ,alguem poderia me ajudar como fazer um chat local?

Posted

Exemplo: (Acabei de fazer)

 

addCommandHandle("local", function(source, commandName, ...)
local msg = table.concat({...}, " ")
if not (...) then return end
	for i, v in ipairs(getElementsByType("player")) do
		if v ~= source then
			local x, y, z = getElementPosition(source)
			local x2, y2, z2 = getElementPosition(v)
			if getDistanceBetweenPoints3D(x, y, z, x2, y2, z2) < 3 then
				outputChatBox("[MENSAGEM LOCAL] "..getPlayerName(source)..": "..msg, v, 255, 255, 255, true)
			end
		end
	end
end

Obs: E nescessario testar

Posted

Edit: O outputChatBox pode bugar por estar sendo usado dentro de um for, vc pode usar esta função para pegar os players proximos

 

function pegarPlayersProximos(elemento)
    if isElement(elemento) and getElementType(elemento) then
        for i, v in ipairs(getElementsByType("player")) do
            if v ~= elemento then
                local x, y, z = getElementPosition(elemento)
                local x2, y2, z2 = getElementPosition(v)
                if getDistanceBetweenPoints3D(x, y, z, x2, y2, z2) < 3 then
                end
                return v
            end
        end
    end
end

          

 

Posted (edited)

Ainda é possível usar o evento onPlayerChat para fazer um sistema simples de chat local. Na página do evento na wiki há um exemplo que faz exatamente o que você quer, @BVO. Observe o 1° exemplo.

Edit¹: Com comando também é uma ótima forma, assim como o @Augusto apresentou.

Edited by KronoS Lettify

Dê um THANKS se minha ajuda ou comentário foi útil para você.   spacer.png 

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