Jump to content

Group name over head.


Pedro001

Recommended Posts

On 10/11/2018 at 16:19, Pedro001 said:

How can I make a script to put the name of the group the player is in, over his head? 

group = getElementData(v,"Group")
addEventHandler("onClientRender", getRootElement(), 
function ()
for k,v in ipairs(getElementsByType("player")) do
		if getElementData(v,"Group") then
			if v == localPlayer then return end
			dxDrawTextOnElement(v,group,1,20,0,0,255,255,1,"arial")
		end
	end
end)

 

Link to comment
3 hours ago, Knuck said:

group = getElementData(v,"Group")
addEventHandler("onClientRender", getRootElement(), 
function ()
for k,v in ipairs(getElementsByType("player")) do
		if getElementData(v,"Group") then
			if v == localPlayer then return end
			dxDrawTextOnElement(v,group,1,20,0,0,255,255,1,"arial")
		end
	end
end)

 

Hey man, thank you very much for responding me, I apreciate! 

However...

I'm getting Bad argument @ 'getElementData' [Expected element at argument 1, got nil] 

I did some research but I couldn't find the reason :(

Link to comment
addEventHandler("onClientRender", getRootElement(), 
  function ()
    for k,v in ipairs(getElementsByType("player")) do
      local group = getElementData(v,"Group")
      if group and v ~= localPlayer then
        dxDrawTextOnElement(v,group,1,20,0,0,255,255,1,"arial")
      end
    end
  end
)

group = getElementData(v,"Group") on line 2 was the problem, v wasn't defined at that point.

Link to comment

 

On 10/11/2018 at 22:19, Pedro001 said:

How can I make a script to put the name of the group the player is in, over his head? 

 

function showClan()
	local player = getLocalPlayer()
	local everybody = getElementsByType("player")
	for _, thePlayer in ipairs(everybody) do
		if getElementData(everybody, "gang") ~= "None" then 
			if everybody ~= getLocalPlayer() then
				if getElementData(everybody, "gang") == getElementData(player, "gang") then
					local x, y, z = getElementPosition(thePlayer)
					local cx, cy, cz = getElementPosition(getLocalPlayer())
					local namePlayer = string.gsub(getPlayerName(thePlayer),"#%x%x%x%x%x%x","")
					if getDistanceBetweenPoints3D(x, y, z, cx, cy, cz) <= 300 and localPlayer ~= thePlayer then
						local sX, sY, sZ = getScreenFromWorldPosition(x, y, z)
						if(sX and sY and sZ)then
							local color = tocolor(255, 255, 255)
							local size = 1
							dxDrawText(namePlayer, sX+25, sY-40, 25, 20, color, size,"default-bold")
							dxDrawText(math.floor(getDistanceBetweenPoints3D(x,y,z, cx,cy,cz)).." m", sX+25, sY-20, 25, 20, color, size,"default-bold")
						end
					end	
				end
			end
		end
	end
end	
addEventHandler("onClientRender", getRootElement(), showClan)

test.

Edited by OverKILL
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...