ArcAngeL Posted April 25, 2019 Share Posted April 25, 2019 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
Moderators Patrick Posted April 25, 2019 Moderators Share Posted April 25, 2019 (edited) Replace pairs to ipairs and resourceRoot to root at line 8. Edited April 25, 2019 by stPatrick Link to comment
ArcAngeL Posted April 25, 2019 Author Share Posted April 25, 2019 yes ı maked but not working again Link to comment
Moderators Patrick Posted April 25, 2019 Moderators Share Posted April 25, 2019 3 hours ago, ArcAngeL said: yes ı maked but not working again It has to work Link to comment
ArcAngeL Posted April 25, 2019 Author Share Posted April 25, 2019 11 minutes ago, stPatrick said: It has to work lol ı am not lying it is not working maybe problem is my 'vehicle shop resource' Link to comment
Moderators Patrick Posted April 25, 2019 Moderators Share Posted April 25, 2019 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? Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now