Jump to content

Duvida texto em marker


Recommended Posts

Estou desenvolvendo um script de dominação de territórios, nele gostaria de adicionar um texto contendo quem dominou aquele território.

Exemplo: Imagem

Sei que tenho que utilizar (setElementData, getElementData e setTimer), porém não achei uma forma de encaixar o getElementData no dxDrawText para mostrar o nick do jogador.

Link to comment

Tentei da primeira forma, mas não obtive exito. 

O texto é independente do marker:

function texto()
	if ( getDistanceBetweenPoints3D ( 2454.69, -913.07, 115.17, getElementPosition ( localPlayer ) ) ) < 20 then
		local coords = { getScreenFromWorldPosition ( 2454.69, -913.07, 115.17 ) }
			if coords[1] and coords[2] then
			dxDrawText("Area dominada por: N/A", coords[1], coords[2], coords[1], coords[2], tocolor(255, 255, 255, 255), x*1.20, "default-bold", "center", "center", false, false, false, true, false)
		end
	end 
end
addEventHandler("onClientRender", root, texto)

 

Link to comment
  • Other Languages Moderators

Desculpe reviver este tópico, mas o que você precisa pra fazer isso é bem simples.

- Quando o jogador dominar aquele território, use: setElementData para salvar o nickname do jogador. Exemplo: setElementData(marker, "playerName", tostring(getPlayerName(player)))

- Já no client-side, você deve fazer isto:

function test()
	for _, marker in pairs(getElementsByType("marker")) do
		local playerName = getElementData(marker, "playerName")
		if (playerName) then
			local mx, my, mz = getElementPosition(marker)
			if (getDistanceBetweenPoints3D(mx, my, mz, getElementPosition (localPlayer))) < 20 then
				local coords = {getScreenFromWorldPosition(mx, my, mz)}
				if coords[1] and coords[2] then
					dxDrawText("Area dominada por: "..playerName, coords[1], coords[2], coords[1], coords[2], tocolor(255, 255, 255, 255), x*1.20, "default-bold", "center", "center", false, false, false, true, false)
				end
			end 
		end
	end
end
addEventHandler("onClientPreRender", root, test)

 

  • Thanks 1
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...