Jump to content

Problem with dxdrawtext


MGO

Recommended Posts

Hello, I'm new to mta scripting and I researched  this issue but couldn't find any tutos, I would like to add a border to the following text :
 

dxDrawText(v.text, sx - (0.5 * width), yPos, sx - (0.5 * width), yPos - (i * fontHeight), tocolor(unpack(v.color)), 1, font, "left", "top", false, false, false)

the text moves with the player idk if that's worth mentioning, but I tried to add a border like this :
 

dxDrawText(v.text, sx - (0.5 * width), yPos, sx - (0.505 * width), yPos - (i * fontHeight), tocolor(0,0,0), 1, font, "left", "top", false, false, false)
dxDrawText(v.text, sx - (0.5 * width), yPos, sx - (0.495 * width), yPos - (i * fontHeight), tocolor(0,0,0), 1, font, "left", "top", false, false, false)
dxDrawText(v.text, sx - (0.505 * width), yPos, sx - (0.5 * width), yPos - (i * fontHeight), tocolor(0,0,0), 1, font, "left", "top", false, false, false)
dxDrawText(v.text, sx - (0.495 * width), yPos, sx - (0.5 * width), yPos - (i * fontHeight), tocolor(0,0,0), 1, font, "left", "top", false, false, false)
dxDrawText(v.text, sx - (0.5 * width), yPos, sx - (0.5 * width), yPos - (i * fontHeight), tocolor(unpack(v.color)), 1, font, "left", "top", false, false, false)

but the borders looks weird and glitchy, if anyone knows any solution plz help. and Thanks in advance.

Link to comment
  • Moderators
5 hours ago, MGO said:

if anyone knows any solution plz help.

Just move the text by 1 pixel:

local borderSize = 1
dxDrawText(v.text, sx - (0.5 * width) - borderSize, yPos, sx - (0.5 * width) - borderSize, yPos - (i * fontHeight), tocolor(0,0,0), 1, font, "left", "top", false, false, false)
dxDrawText(v.text, sx - (0.5 * width) + borderSize, yPos, sx - (0.5 * width) + borderSize, yPos - (i * fontHeight), tocolor(0,0,0), 1, font, "left", "top", false, false, false)
dxDrawText(v.text, sx - (0.5 * width) - borderSize, yPos, sx - (0.5 * width) + borderSize, yPos - (i * fontHeight), tocolor(0,0,0), 1, font, "left", "top", false, false, false)
dxDrawText(v.text, sx - (0.5 * width) + borderSize, yPos, sx - (0.5 * width) - borderSize, yPos - (i * fontHeight), tocolor(0,0,0), 1, font, "left", "top", false, false, false)

dxDrawText(v.text, sx - (0.5 * width), yPos, sx - (0.5 * width), yPos - (i * fontHeight), tocolor(unpack(v.color)), 1, font, "left", "top", false, false, false)

 

Link to comment

You can use something more simplier

 

--// Example
local borderSize = 1

dxDrawBorderedText(borderSize, etc..)
function dxDrawBorderedText (outline, text, left, top, right, bottom, color, scale, font, alignX, alignY, clip, wordBreak, postGUI, colorCoded, subPixelPositioning, fRotation, fRotationCenterX, fRotationCenterY)
    for oX = (outline * -1), outline do
        for oY = (outline * -1), outline do
            dxDrawText (text, left + oX, top + oY, right + oX, bottom + oY, tocolor(0, 0, 0, 255), scale, font, alignX, alignY, clip, wordBreak, postGUI, colorCoded, subPixelPositioning, fRotation, fRotationCenterX, fRotationCenterY)
        end
    end
    dxDrawText (text, left, top, right, bottom, color, scale, font, alignX, alignY, clip, wordBreak, postGUI, colorCoded, subPixelPositioning, fRotation, fRotationCenterX, fRotationCenterY)
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...