Sign in to follow this  
ArcAngeL

Vehicle 's owner name (vehicle tag)

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)

 

Share this post


Link to post

Replace pairs to ipairs and resourceRoot to root at line 8.

Edited by stPatrick

Share this post


Link to post
3 hours ago, ArcAngeL said:

yes ı maked but not working again ☹️

It has to work

 

Share this post


Link to post
11 minutes ago, stPatrick said:

It has to work

 

lol ı am not lying it is not working maybe problem is my 'vehicle shop resource'

Share this post


Link to post
2 hours ago, ArcAngeL said:

lol ı am not lying it is not working maybe problem is my 'vehicle shop resource'

Probably.
Is 'owner' element data set?

Share this post


Link to post

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.