Jump to content

useful function i think


Recommended Posts


local texts= {}
local counter = 1

function createBlipText(text,x,y,size,color,font ,rot)
    local size = size or 1.3
    local font = font or "default"
    local color = color or tocolor(255,255,255,255)
    local rot = rot or 0
    texts[counter]={text,x,y,size,font ,rot,color}
    counter = counter+1
    return texts[counter-1]
end

local blip = createBlipText("Test" ,591.02747, 871.34741 )

local screenSize = Vector2(guiGetScreenSize())

local function drawWorldPosMapText()
    if isPlayerMapVisible() then

        for k ,v in pairs( texts ) do

            local worldPos = Vector2(v[2] , v[3]) 
            local mapMin, mapMax
            do
                local mx, my, Mx, My = getPlayerMapBoundingBox()
                if mx then
                    mapMin = Vector2(mx, my)
                    mapMax = Vector2(Mx, My)
                else
                    return
                end
            end

            local fMx, fMy = (worldPos.x + 3000) / 6000, -(worldPos.y - 3000) / 6000
            local fmx, fmy = 1 - fMx, 1 - fMy

            local screenMapPos = Vector2((fmx * mapMin.x) + (fMx * mapMax.x), (fmy * mapMin.y) + (fMy * mapMax.y))

            if screenMapPos.x >= 0 and screenMapPos.y >= 0 and screenMapPos.x <= screenSize.x and screenMapPos.y <= screenSize.y then
                local width = dxGetTextWidth(v[1],v[4], v[5])
                dxDrawText(v[1], screenMapPos.x - (width / 2), screenMapPos.y, screenMapPos.x + (width / 2), screenMapPos.y, v[7], v[4], v[5], "center", "center" ,false,false,false,false,false,v[6])
            end

        end
    end
end
addEventHandler("onClientRender", root, drawWorldPosMapText)

 

  • Like 2
Link to comment
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...