Hero192 Posted July 15, 2015 Share Posted July 15, 2015 (edited) 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 July 15, 2015 by Guest Link to comment
GTX Posted July 15, 2015 Share Posted July 15, 2015 viewtopic.php?f=91&t=70747&p=657875&hilit=getPlayerMapBoundingBox#p658114 Here's an example. Link to comment
Hero192 Posted July 15, 2015 Author Share Posted July 15, 2015 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
GTX Posted July 15, 2015 Share Posted July 15, 2015 For the text: setElementData(yourblip, "name", "whatever you want") For the color (now it will be green): setElementData(yourblip, "color", {0, 255, 0}) Link to comment
Hero192 Posted July 15, 2015 Author Share Posted July 15, 2015 The color Doesn't working it show as black even if i set it to another one Link to comment
GTX Posted July 15, 2015 Share Posted July 15, 2015 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
Hero192 Posted July 15, 2015 Author Share Posted July 15, 2015 But it shows to all blips and the text ="none" , color = "255,255,255" Even when i set my own text / Color it doesn't works setElementData(23, "name", "whatever you want") setElementData(23, "color", "0,255,0") Link to comment
GTX Posted July 15, 2015 Share Posted July 15, 2015 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
Hero192 Posted July 15, 2015 Author Share Posted July 15, 2015 Thank you alot one more thing there's a way for adding the rectangle in the text who attacked between blips 23,42? because i tried and i failed Link to comment
GTX Posted July 15, 2015 Share Posted July 15, 2015 I don't understand you. Keep trying. It's all about maths. Link to comment
Hero192 Posted July 15, 2015 Author Share Posted July 15, 2015 I mean,i want show the rectangle in the map too what you gave me it show the texts without rectangles. Link to comment
GTX Posted July 15, 2015 Share Posted July 15, 2015 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
Hero192 Posted July 16, 2015 Author Share Posted July 16, 2015 I mean in the F11 M not in the radar (mini map) Link to comment
Hero192 Posted July 16, 2015 Author Share Posted July 16, 2015 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
GTX Posted July 16, 2015 Share Posted July 16, 2015 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
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