Jump to content

Duvida De como cria um chat local


Recommended Posts

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

Link to comment

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

          

 

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