Jump to content

[HELP] Writting in Map


Hero192

Recommended Posts

I stuck in showing the text on the map

Please do an example custom text with custom color and let the text be attacked to blip "23"and "42".

Already tried in line 25 / 26 but i have no idea about how to make like 2 Text/Color for this code in table

Please guys help me if you know how

local textFont       = "sans" 
local textScale      = 0.8 
local heightPadding  = 1 
local widthPadding   = 1 
local xOffset        = 5 
local minAlpha       = 10 
local textAlpha      = 255 
local rectangleColor = tocolor(0,0,0,155) 
  
  
local floor          = math.floor 
local w,h            = guiGetScreenSize() 
  
local function drawMapStuff() 
    if isPlayerMapVisible() then 
  
        local sx,sy,ex,ey     = getPlayerMapBoundingBox() 
        local mw,mh           = ex-sx,sy-ey 
        local cx,cy           = (sx+ex)/2,(sy+ey)/2 
        local ppuX,ppuY       = mw/6000,mh/6000 
        local fontHeight      = dxGetFontHeight(textScale,textFont) 
        local yOffset         = fontHeight/2 
        local blips           = getElementsByType("blip") 
           for k,v in ipairs(blips) do 
            if tonumber(getBlipIcon(v)) == 23 then 
                        if tonumber(getBlipIcon(v)) == 42 then 
                local px,py      = getElementPosition(v) 
                local x          = floor(cx+px*ppuX+xOffset) 
                local y          = floor(cy+py*ppuY-yOffset) 
                local jname      = getElementData(v,"name")                      
                local nameLength = dxGetTextWidth(jname,textScale,textFont)  
                local r,g,b      = unpack(getElementData(v,"color")) 
                local _,_,_,a    = getBlipColor(v) 
  
                if a>minAlpha then 
  
                    dxDrawRectangle(x-widthPadding,y+heightPadding,nameLength+widthPadding*2,fontHeight-heightPadding*1,rectangleColor,false) 
                    dxDrawText(jname,x,y,x+nameLength,y+fontHeight,tocolor(r,g,b,textAlpha),textScale,textFont,"left","top",false,false,false,true) 
                     end 
                end 
            end 
        end 
    end 
end 
addEventHandler("onClientRender",getRootElement(),drawMapStuff) 

Edited by Guest
Link to comment

I stuck in showing the text on the map

Please do an example custom text with custom color and let the text be attacked to blip "23"and "42".

Already tried in line 25 / 26 but i have no idea about how to make like 2 Text/Color for this code in table

Please guys help me if you know how

local textFont       = "sans" 
local textScale      = 0.8 
local heightPadding  = 1 
local widthPadding   = 1 
local xOffset        = 5 
local minAlpha       = 10 
local textAlpha      = 255 
local rectangleColor = tocolor(0,0,0,155) 
  
  
local floor          = math.floor 
local w,h            = guiGetScreenSize() 
  
local function drawMapStuff() 
    if isPlayerMapVisible() then 
  
        local sx,sy,ex,ey     = getPlayerMapBoundingBox() 
        local mw,mh           = ex-sx,sy-ey 
        local cx,cy           = (sx+ex)/2,(sy+ey)/2 
        local ppuX,ppuY       = mw/6000,mh/6000 
        local fontHeight      = dxGetFontHeight(textScale,textFont) 
        local yOffset         = fontHeight/2 
        local blips           = getElementsByType("blip") 
           for k,v in ipairs(blips) do 
            if tonumber(getBlipIcon(v)) == 23 then 
                        if tonumber(getBlipIcon(v)) == 42 then 
                local px,py      = getElementPosition(v) 
                local x          = floor(cx+px*ppuX+xOffset) 
                local y          = floor(cy+py*ppuY-yOffset) 
                local jname      = getElementData(v,"name")                      
                local nameLength = dxGetTextWidth(jname,textScale,textFont)  
                local r,g,b      = unpack(getElementData(v,"color")) 
                local _,_,_,a    = getBlipColor(v) 
  
                if a>minAlpha then 
  
                    dxDrawRectangle(x-widthPadding,y+heightPadding,nameLength+widthPadding*2,fontHeight-heightPadding*1,rectangleColor,false) 
                    dxDrawText(jname,x,y,x+nameLength,y+fontHeight,tocolor(r,g,b,textAlpha),textScale,textFont,"left","top",false,false,false,true) 
                     end 
                end 
            end 
        end 
    end 
end 
addEventHandler("onClientRender",getRootElement(),drawMapStuff) 

Link to comment

The text should be colored, the rectangle is black at all times. Which do you want it colored? Rectangle or the text?

EDIT: If it works for me, it should work for you. (http://prntscr.com/7t60f1) This is the code I used:

local textFont       = "sans" 
local textScale      = 0.8 
local heightPadding  = 1 
local widthPadding   = 1 
local xOffset        = 5 
local minAlpha       = 10 
local textAlpha      = 255 
local rectangleColor = tocolor(0,0,0,155) 
  
  
local floor          = math.floor 
local w,h            = guiGetScreenSize() 
  
local function drawMapStuff() 
    if isPlayerMapVisible() then 
  
        local sx,sy,ex,ey     = getPlayerMapBoundingBox() 
        local mw,mh           = ex-sx,sy-ey 
        local cx,cy           = (sx+ex)/2,(sy+ey)/2 
        local ppuX,ppuY       = mw/6000,mh/6000 
        local fontHeight      = dxGetFontHeight(textScale,textFont) 
        local yOffset         = fontHeight/2 
        local blips           = getElementsByType("blip") 
        for k,v in ipairs(blips) do 
            local px,py      = getElementPosition(v) 
            local x          = floor(cx+px*ppuX+xOffset) 
            local y          = floor(cy+py*ppuY-yOffset) 
            local jname      = getElementData(v,"name") or "none"                     
            local nameLength = dxGetTextWidth(jname,textScale,textFont)  
            local r,g,b      = unpack(getElementData(v,"color") or {255, 255, 255}) 
            local _,_,_,a    = getBlipColor(v) 
  
            if a>minAlpha then 
  
                dxDrawRectangle(x-widthPadding,y+heightPadding,nameLength+widthPadding*2,fontHeight-heightPadding*1,rectangleColor,false) 
                dxDrawText(jname,x,y,x+nameLength,y+fontHeight,tocolor(r,g,b,textAlpha),textScale,textFont,"left","top",false,false,false,true) 
            end 
        end 
    end 
end 
addEventHandler("onClientRender",getRootElement(),drawMapStuff) 

Link to comment

Just... Use this:

local textFont       = "sans" 
local textScale      = 0.8 
local heightPadding  = 1 
local widthPadding   = 1 
local xOffset        = 5 
local minAlpha       = 10 
local textAlpha      = 255 
local rectangleColor = tocolor(0,0,0,155) 
  
  
local floor          = math.floor 
local w,h            = guiGetScreenSize() 
  
local function drawMapStuff() 
    if isPlayerMapVisible() then 
  
        local sx,sy,ex,ey     = getPlayerMapBoundingBox() 
        local mw,mh           = ex-sx,sy-ey 
        local cx,cy           = (sx+ex)/2,(sy+ey)/2 
        local ppuX,ppuY       = mw/6000,mh/6000 
        local fontHeight      = dxGetFontHeight(textScale,textFont) 
        local yOffset         = fontHeight/2 
        local blips           = getElementsByType("blip") 
        for k,v in ipairs(blips) do 
            local px,py      = getElementPosition(v) 
            local x          = floor(cx+px*ppuX+xOffset) 
            local y          = floor(cy+py*ppuY-yOffset) 
            local jname      = getElementData(v,"name") or ""                     
            local nameLength = dxGetTextWidth(jname,textScale,textFont) 
            local r,g,b      = unpack(getElementData(v,"color") or {255, 255, 255}) 
            if getBlipIcon(v) == 23 then 
                r, g, b = 0, 255, 0 
                jname = "whatever you want" 
            elseif getBlipIcon(v) == 42 then 
                r, g, b = 255, 0, 0 
                jname = "whatever you want 2" 
            end 
            local _,_,_,a    = getBlipColor(v) 
  
            if a>minAlpha then 
  
                dxDrawRectangle(x-widthPadding,y+heightPadding,nameLength+widthPadding*2,fontHeight-heightPadding*1,rectangleColor,false) 
                dxDrawText(jname,x,y,x+nameLength,y+fontHeight,tocolor(r,g,b,textAlpha),textScale,textFont,"left","top",false,false,false,true) 
            end 
        end 
    end 
end 
addEventHandler("onClientRender",getRootElement(),drawMapStuff) 

Link to comment

Still don't understand you. Show a "rectangle" on the map:

createRadarArea 

Remove rectangle:

local textFont       = "sans" 
local textScale      = 0.8 
local heightPadding  = 1 
local widthPadding   = 1 
local xOffset        = 5 
local minAlpha       = 10 
local textAlpha      = 255 
local rectangleColor = tocolor(0,0,0,155) 
  
  
local floor          = math.floor 
local w,h            = guiGetScreenSize() 
  
local function drawMapStuff() 
    if isPlayerMapVisible() then 
  
        local sx,sy,ex,ey     = getPlayerMapBoundingBox() 
        local mw,mh           = ex-sx,sy-ey 
        local cx,cy           = (sx+ex)/2,(sy+ey)/2 
        local ppuX,ppuY       = mw/6000,mh/6000 
        local fontHeight      = dxGetFontHeight(textScale,textFont) 
        local yOffset         = fontHeight/2 
        local blips           = getElementsByType("blip") 
        for k,v in ipairs(blips) do 
            local px,py      = getElementPosition(v) 
            local x          = floor(cx+px*ppuX+xOffset) 
            local y          = floor(cy+py*ppuY-yOffset) 
            local jname      = getElementData(v,"name") or ""                     
            local nameLength = dxGetTextWidth(jname,textScale,textFont) 
            local r,g,b      = unpack(getElementData(v,"color") or {255, 255, 255}) 
            if getBlipIcon(v) == 23 then 
                r, g, b = 0, 255, 0 
                jname = "whatever you want" 
            elseif getBlipIcon(v) == 42 then 
                r, g, b = 255, 0, 0 
                jname = "whatever you want 2" 
            end 
            local _,_,_,a    = getBlipColor(v) 
  
            if a>minAlpha then 
                dxDrawText(jname,x,y,x+nameLength,y+fontHeight,tocolor(r,g,b,textAlpha),textScale,textFont,"left","top",false,false,false,true) 
            end 
        end 
    end 
end 
addEventHandler("onClientRender",getRootElement(),drawMapStuff) 

Link to comment

By the way,How may i use the Peds table in this F11 texts , i mean i want the texts set in the Peds table pos and shows in the F11 texts

local pedPos = { 
    {2321.06, 36.8, 26.48,88}, 
     {-553.84, 2594, 53.93,258}, 
    {-1969.19, -2427.74, 30.63,233} 
} 
local skins = {73,179} 
local peds = {} 
  
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
        for i=1, # peds do 
             peds[i] = createPed(skins[math.random(1, #skins)], traderpPos[i][1], traderpPos[i][2], traderpPos[i][3]) 
            if  peds[i] then 
                setElementFrozen(traders[i], true) 
                if pedPos[i][4] then 
                    setPedRotation( pedsi], pedPos[i][4]) 
                end 
            end 
        end 
    end 
) 

Link to comment

It's an easy workaround.

local pedPos = { 
    {2321.06, 36.8, 26.48,88, "John"}, 
     {-553.84, 2594, 53.93,258, "Banana"}, 
    {-1969.19, -2427.74, 30.63,233, "Dr. Who"} 
} 
local skins = {73,179} 
local peds = {} 
local blips = {} 
  
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
        for i=1, # peds do 
             peds[i] = createPed(skins[math.random(1, #skins)], traderpPos[i][1], traderpPos[i][2], traderpPos[i][3]) 
            if  peds[i] then 
                blips[i] = createBlip(traderpPos[i][1], traderpPos[i][2], traderpPos[i][3]) 
                setElementData(blips[i], "name", traderpPos[i][5]) 
                setElementData(blips[i], "color", {255, 255, 255}) 
                setElementFrozen(traders[i], true) 
                if pedPos[i][4] then 
                    setPedRotation( pedsi], pedPos[i][4]) 
                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...