I've fixed something,
local x, y = guiGetScreenSize ()
local timicSettings = {
xOffset = 556,
yOffset = (y / 2) - 445,
xOffset1 = 552,
yOffset1 = (y / 2) - 443,
}
local textX = x - timicSettings.xOffset
local textY = timicSettings.yOffset
local textX1 = x - timicSettings.xOffset1
local textY1 = timicSettings.yOffset1
addEventHandler("onClientRender",root,
function(player,name)
local getp = type(name)=='string' and string.gsub ( name, '#%x%x%x%x%x%x', '' ) or name
dxDrawText("~XG~Timic",textX1, textY1, x, y,tocolor(0,0,0,255),1.0,"bankgothic","left","top",false,false,false)
dxDrawColorText(getp,textX, textY, x, y,tocolor(255,255,255,255),1.0,"bankgothic","left","top",false,false,false)
end
)
--- --- --- --- ---
function dxDrawColorText(str, ax, ay, bx, by, color, scale, font, alignX, alignY)
if alignX then
if alignX == "center" then
local w = dxGetTextWidth(str:gsub("#%x%x%x%x%x%x",""), scale, font)
ax = ax + (bx-ax)/2 - w/2
elseif alignX == "right" then
local w = dxGetTextWidth(str:gsub("#%x%x%x%x%x%x",""), scale, font)
ax = bx - w
end
end
if alignY then
if alignY == "center" then
local h = dxGetFontHeight(scale, font)
ay = ay + (by-ay)/2 - h/2
elseif alignY == "bottom" then
local h = dxGetFontHeight(scale, font)
ay = by - h
end
end
local pat = "(.-)#(%x%x%x%x%x%x)"
local s, e, cap, col = str:find(pat, 1)
local last = 1
while s do
if cap == "" and col then color = tocolor(tonumber("0x"..col:sub(1, 2)), tonumber("0x"..col:sub(3, 4)), tonumber("0x"..col:sub(5, 6)), 255) end
if s ~= 1 or cap ~= "" then
local w = dxGetTextWidth(cap, scale, font)
dxDrawText(cap, ax, ay, ax + w, by, color, scale, font)
ax = ax + w
color = tocolor(tonumber("0x"..col:sub(1, 2)), tonumber("0x"..col:sub(3, 4)), tonumber("0x"..col:sub(5, 6)), 255)
end
last = e + 1
s, e, cap, col = str:find(pat, last)
end
if last <= #str then
cap = str:sub(last)
local w = dxGetTextWidth(cap, scale, font)
dxDrawText(cap, ax, ay, ax + w, by, color, scale, font)
end
end
It gives me:
ERROR: test\test_c.lua:52: attempt to index local 'str' (a nil value)