Jump to content

Vehicle 's owner name (vehicle tag)


ArcAngeL

Recommended Posts

 

I want to add  name of the 'car owner' on the car.ı maked some codes but not working.my car shop resource owner element data is "owner" but still ı cant add dx tag name on the car.can someone help me ? maybe ı cant see my mistakes.

 

local fontP = dxCreateFont( "normal.ttf", 20 )

local SX,SY = guiGetScreenSize()
local px,py = 1366,768
local sx,sy =  (SX/px), (SY/py)

function drawCarTags()
	for k, veh in pairs(getElementsByType("vehicle", resourceRoot, true)) do
		local cx, cy, cz, lx, ly, lz = getCameraMatrix()
		local px, py, pz = getElementPosition(veh)
		local dist = getDistanceBetweenPoints3D(cx, cy, cz, px, py, pz)
		if dist < 60 then
			if( isLineOfSightClear(cx, cy, cz, px, py, pz, true, false, false) ) then
				local x, y = getScreenFromWorldPosition (px, py, pz + 1)
				if(x and y) then
					local owner = getElementData(veh, "owner")
					if (owner and getPlayerFromName(owner)) then
						local h = dxGetFontHeight(sy*0.8, fontP)
						local w = dxGetTextWidth(owner, sy*0.8, fontP)
						dxDrawText(owner, x - w / 2, y + h*-2, w, h, tocolor(getPlayerNametagColor(getPlayerFromName(owner))), sy*0.8, fontP)			
					end
				end
			end
		end
	end
end
addEventHandler("onClientRender", root, drawCarTags)

 

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