Jump to content

dxDraw scaling and postioning.


Recommended Posts

Hey, basically, I want to display the license plate above cars, as I have right now, it isnt above the car at all times. If I drive a little away from a car, the text goes way up high.

I am wondering how I can scale it, so that the position is always locked right above the cars roof at whatever distance you are away from the car, and the further away from the car, the smaller it is?

Thanks, much appreciated :)

This is what I have so far.

local px, py, pz = getElementPosition(localPlayer) 
    -- vehicles 
    for key, value in ipairs(getElementsByType("vehicle")) do 
        if isElementStreamedIn(value) and (isElementOnScreen(value))  then 
            local x, y, z = getElementPosition(value) 
            local plateText = getVehiclePlateText ( value ) 
            if (isLineOfSightClear(px, py, pz, x, y, z, true, false, false, true, false, false, true)) then 
                local tx, ty = getScreenFromWorldPosition(x, y, z, 5000, false) 
                 
                if (tx) then 
                      
                     
                    local size = dxGetTextWidth(getVehicleName(value), 1, "bankgothic") + 170 
             
                    dxDrawText(plateText, tx, ty, tx, ty-200, tocolor(10, 255, 10, 160), 0.6, "bankgothic", "center", "center") 
                end 
            end 
        end 
    end 

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