Jump to content

help in my script


Paplo

Recommended Posts

my script The writing in the name of the [server] at the top of the server

But when a player goes out and enters the writing disappear

I want a way to make writing remain even if the player output and income

Thank you

  
  
Client .. 
  
local msg = "" 
local player = nil 
local x,y = guiGetScreenSize() 
  
function drawMessage() 
     
    scale = 1.2 
    font = "default-bold" 
    h = dxGetFontHeight(scale, font) 
  
    if player == nil then  
        dxDrawColorText("#ff9900[server]#ffffff " .. msg,500, -1,x,250, tocolor(255,255,255),scale,font) 
    else 
        dxDrawColorText("#FF9900[server]#ffffff " .. msg ,500, -1,x,250, tocolor(255,255,255),scale,"default-bold") 
     
    end 
end 
  
addEventHandler("onClientRender",getRootElement(),drawMessage) 
function newmsg(new) 
  
msg = new 
player = root 
  
  
  
end 
addEvent("newmsg",true) 
addEventHandler("newmsg",getRootElement(),newmsg) 
  
function amoff() 
removeEventHandler("onClientRender", getRootElement(), drawMessage) 
end 
addEvent("amoff", true ) 
addEventHandler("amoff", getRootElement(), amoff) 
  
function rdx(msg) 
    removeEventHandler ( "onClientRender", getRootElement(), drawMessage ) 
    end 
addEvent("mR", true ) 
addEventHandler("mR", getRootElement(), rdx) 
  
  
function dxDrawBorderedText(text, xpos, ypos, w, h, color, scale, font) 
     
    dxDrawText ( text, xpos - 1, ypos - 1, w - 1, h - 1, tocolor ( 0, 0, 0, 255 ), scale, font ) -- black 
    dxDrawText ( text, xpos + 1, ypos - 1, w + 1, h - 1, tocolor ( 0, 0, 0, 255 ), scale, font ) 
    dxDrawText ( text, xpos - 1, ypos + 1, w - 1, h + 1, tocolor ( 0, 0, 0, 255 ), scale, font ) 
    dxDrawText ( text, xpos + 1, ypos + 1, w + 1, h + 1, tocolor ( 0, 0, 0, 255 ), scale, font ) 
    dxDrawText ( text, xpos - 1, ypos, w - 1, h, tocolor ( 0, 0, 0, 255 ), scale, font ) 
    dxDrawText ( text, xpos + 1, ypos, w + 1,h, tocolor ( 0, 0, 0, 255 ), scale, font ) 
    dxDrawText ( text, xpos, ypos - 1, w, h - 1, tocolor ( 0, 0, 0, 255 ), scale, font ) 
    dxDrawText ( text, xpos, ypos + 1, w, h + 1, tocolor ( 0, 0, 0, 255 ), scale, font ) 
    dxDrawText ( text, xpos, ypos, w, h, color, scale, font) 
     
end 
  
function dxDrawColorText(str, ax, ay, bx, by, color, scale, font, alignX, alignY) 
  bx, by, color, scale, font = bx or ax, by or ay, color or tocolor(255,255,255,255), scale or 1, font or "default" 
  if alignX then 
    if alignX == "center" then 
      ax = ax + (bx - ax - dxGetTextWidth(str:gsub("#%x%x%x%x%x%x",""), scale, font))/2 
    elseif alignX == "right" then 
      ax = bx - dxGetTextWidth(str:gsub("#%x%x%x%x%x%x",""), scale, font) 
    end 
  end 
  if alignY then 
    if alignY == "center" then 
      ay = ay + (by - ay - dxGetFontHeight(scale, font))/2 
    elseif alignY == "bottom" then 
      ay = by - dxGetFontHeight(scale, font) 
    end 
  end 
  local alpha = string.format("%08X", color):sub(1,2) 
  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(getColorFromString("#"..col..alpha)) end 
    if s ~= 1 or cap ~= "" then 
      local w = dxGetTextWidth(cap, scale, font) 
      dxDrawBorderedText(cap, ax, ay, ax + w, by, color, scale, font) 
      ax = ax + w 
      color = tocolor(getColorFromString("#"..col..alpha)) 
    end 
    last = e + 1 
    s, e, cap, col = str:find(pat, last) 
  end 
  if last <= #str then 
    cap = str:sub(last) 
    dxDrawBorderedText(cap, ax, ay, ax + dxGetTextWidth(cap, scale, font), by, color, scale, font) 
  end 
end 
  

  
Server .. 
  
addEventHandler("onPlayerLogin", root,  
    function(_,account) 
        if isObjectInACLGroup( "user."..getAccountName(getPlayerAccount(source)), aclGetGroup('Server') ) then 
            bindKey(source, "o","up","chatbox","[server]") 
        end 
    end 
) 
  
addEventHandler("onResourceStart",getResourceRootElement(getThisResource()), 
    function() 
        for i,v in ipairs(getElementsByType('Player')) do 
            local acount = getPlayerAccount(v) 
            if isObjectInACLGroup("user."..getAccountName(acount), aclGetGroup('Server')) then 
                bindKey(v, "o","up","chatbox","[server]") 
           setCameraMatrix(source, 1468.8785400391, -919.25317382813, 100.153465271, 1468.388671875, -918.42474365234, 99.881813049316) 
            end 
        end 
    end 
) 
  
function onAdminChat(player, _, ... ) 
    local tWords = { ... } 
    local tMessage = table.concat(tWords, " ") 
    triggerClientEvent("newmsg",player,tMessage) 
end 
addCommandHandler("[server]", onAdminChat) 

Please help :?

Link to comment

Try this:

Client

local msg = "" 
local player = nil 
local x,y = guiGetScreenSize() 
  
function drawMessage() 
    
    local scale = 1.2 
    local font = "default-bold" 
    h = dxGetFontHeight(scale, font) 
  
    if player == nil then 
        dxDrawColorText("#ff9900[server]#ffffff " .. msg,500, -1,x,250, tocolor(255,255,255),scale,font) 
    else 
        dxDrawColorText("#FF9900[server]#ffffff " .. msg ,500, -1,x,250, tocolor(255,255,255),scale,"default-bold") 
    
    end 
end 
  
addEventHandler("onClientRender",getRootElement(),drawMessage) 
function newmsg(new) 
    msg = tostring(new) 
    player = localPlayer 
     
end 
addEvent("newmsg",true) 
addEventHandler("newmsg",getRootElement(),newmsg) 
  
function amoff() 
removeEventHandler("onClientRender", getRootElement(), drawMessage) 
end 
addEvent("amoff", true ) 
addEventHandler("amoff", getRootElement(), amoff) 
  
function rdx(msg) 
    removeEventHandler ( "onClientRender", getRootElement(), drawMessage ) 
    end 
addEvent("mR", true ) 
addEventHandler("mR", getRootElement(), rdx) 
  
  
function dxDrawBorderedText(text, xpos, ypos, w, h, color, scale, font) 
    
    dxDrawText ( text, xpos - 1, ypos - 1, w - 1, h - 1, tocolor ( 0, 0, 0, 255 ), scale, font ) -- black 
    dxDrawText ( text, xpos + 1, ypos - 1, w + 1, h - 1, tocolor ( 0, 0, 0, 255 ), scale, font ) 
    dxDrawText ( text, xpos - 1, ypos + 1, w - 1, h + 1, tocolor ( 0, 0, 0, 255 ), scale, font ) 
    dxDrawText ( text, xpos + 1, ypos + 1, w + 1, h + 1, tocolor ( 0, 0, 0, 255 ), scale, font ) 
    dxDrawText ( text, xpos - 1, ypos, w - 1, h, tocolor ( 0, 0, 0, 255 ), scale, font ) 
    dxDrawText ( text, xpos + 1, ypos, w + 1,h, tocolor ( 0, 0, 0, 255 ), scale, font ) 
    dxDrawText ( text, xpos, ypos - 1, w, h - 1, tocolor ( 0, 0, 0, 255 ), scale, font ) 
    dxDrawText ( text, xpos, ypos + 1, w, h + 1, tocolor ( 0, 0, 0, 255 ), scale, font ) 
    dxDrawText ( text, xpos, ypos, w, h, color, scale, font) 
    
end 
  
function dxDrawColorText(str, ax, ay, bx, by, color, scale, font, alignX, alignY) 
  bx, by, color, scale, font = bx or ax, by or ay, color or tocolor(255,255,255,255), scale or 1, font or "default" 
  if alignX then 
    if alignX == "center" then 
      ax = ax + (bx - ax - dxGetTextWidth(str:gsub("#%x%x%x%x%x%x",""), scale, font))/2 
    elseif alignX == "right" then 
      ax = bx - dxGetTextWidth(str:gsub("#%x%x%x%x%x%x",""), scale, font) 
    end 
  end 
  if alignY then 
    if alignY == "center" then 
      ay = ay + (by - ay - dxGetFontHeight(scale, font))/2 
    elseif alignY == "bottom" then 
      ay = by - dxGetFontHeight(scale, font) 
    end 
  end 
  local alpha = string.format("%08X", color):sub(1,2) 
  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(getColorFromString("#"..col..alpha)) end 
    if s ~= 1 or cap ~= "" then 
      local w = dxGetTextWidth(cap, scale, font) 
      dxDrawBorderedText(cap, ax, ay, ax + w, by, color, scale, font) 
      ax = ax + w 
      color = tocolor(getColorFromString("#"..col..alpha)) 
    end 
    last = e + 1 
    s, e, cap, col = str:find(pat, last) 
  end 
  if last <= #str then 
    cap = str:sub(last) 
    dxDrawBorderedText(cap, ax, ay, ax + dxGetTextWidth(cap, scale, font), by, color, scale, font) 
  end 
end 
  

Server

  
addEventHandler("onPlayerLogin", root, 
    function(_,account) 
        if isObjectInACLGroup( "user."..getAccountName(getPlayerAccount(source)), aclGetGroup('Server') ) then 
            bindKey(source, "o","up","chatbox","[server]") 
        end 
    end 
) 
  
addEventHandler("onResourceStart",getResourceRootElement(getThisResource()), 
    function() 
        for i,v in ipairs(getElementsByType('Player')) do 
            local acount = getPlayerAccount(v) 
            if isObjectInACLGroup("user."..getAccountName(acount), aclGetGroup('Server')) then 
                bindKey(v, "o","up","chatbox","[server]") 
           setCameraMatrix(source, 1468.8785400391, -919.25317382813, 100.153465271, 1468.388671875, -918.42474365234, 99.881813049316) 
            end 
        end 
    end 
) 
  
addEventHandler("onPlayerJoin", root, 
    function() 
        setTimer( function() 
            if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup('Server')) then 
                bindKey(source, "o","up","chatbox","[server]") 
                setCameraMatrix(source, 1468.8785400391, -919.25317382813, 100.153465271, 1468.388671875, -918.42474365234, 99.881813049316) 
            end 
        end, 500, 1 ) 
    end 
) 
  
function onAdminChat(player, _, ... ) 
    local tWords = { ... } 
    local tMessage = table.concat(tWords, " ") 
    triggerClientEvent("newmsg",player,tMessage) 
end 
addCommandHandler("[server]", onAdminChat) 

Link to comment
Try this:

Client

local msg = "" 
local player = nil 
local x,y = guiGetScreenSize() 
  
function drawMessage() 
    
    local scale = 1.2 
    local font = "default-bold" 
    h = dxGetFontHeight(scale, font) 
  
    if player == nil then 
        dxDrawColorText("#ff9900[server]#ffffff " .. msg,500, -1,x,250, tocolor(255,255,255),scale,font) 
    else 
        dxDrawColorText("#FF9900[server]#ffffff " .. msg ,500, -1,x,250, tocolor(255,255,255),scale,"default-bold") 
    
    end 
end 
  
addEventHandler("onClientRender",getRootElement(),drawMessage) 
function newmsg(new) 
    msg = tostring(new) 
    player = localPlayer 
     
end 
addEvent("newmsg",true) 
addEventHandler("newmsg",getRootElement(),newmsg) 
  
function amoff() 
removeEventHandler("onClientRender", getRootElement(), drawMessage) 
end 
addEvent("amoff", true ) 
addEventHandler("amoff", getRootElement(), amoff) 
  
function rdx(msg) 
    removeEventHandler ( "onClientRender", getRootElement(), drawMessage ) 
    end 
addEvent("mR", true ) 
addEventHandler("mR", getRootElement(), rdx) 
  
  
function dxDrawBorderedText(text, xpos, ypos, w, h, color, scale, font) 
    
    dxDrawText ( text, xpos - 1, ypos - 1, w - 1, h - 1, tocolor ( 0, 0, 0, 255 ), scale, font ) -- black 
    dxDrawText ( text, xpos + 1, ypos - 1, w + 1, h - 1, tocolor ( 0, 0, 0, 255 ), scale, font ) 
    dxDrawText ( text, xpos - 1, ypos + 1, w - 1, h + 1, tocolor ( 0, 0, 0, 255 ), scale, font ) 
    dxDrawText ( text, xpos + 1, ypos + 1, w + 1, h + 1, tocolor ( 0, 0, 0, 255 ), scale, font ) 
    dxDrawText ( text, xpos - 1, ypos, w - 1, h, tocolor ( 0, 0, 0, 255 ), scale, font ) 
    dxDrawText ( text, xpos + 1, ypos, w + 1,h, tocolor ( 0, 0, 0, 255 ), scale, font ) 
    dxDrawText ( text, xpos, ypos - 1, w, h - 1, tocolor ( 0, 0, 0, 255 ), scale, font ) 
    dxDrawText ( text, xpos, ypos + 1, w, h + 1, tocolor ( 0, 0, 0, 255 ), scale, font ) 
    dxDrawText ( text, xpos, ypos, w, h, color, scale, font) 
    
end 
  
function dxDrawColorText(str, ax, ay, bx, by, color, scale, font, alignX, alignY) 
  bx, by, color, scale, font = bx or ax, by or ay, color or tocolor(255,255,255,255), scale or 1, font or "default" 
  if alignX then 
    if alignX == "center" then 
      ax = ax + (bx - ax - dxGetTextWidth(str:gsub("#%x%x%x%x%x%x",""), scale, font))/2 
    elseif alignX == "right" then 
      ax = bx - dxGetTextWidth(str:gsub("#%x%x%x%x%x%x",""), scale, font) 
    end 
  end 
  if alignY then 
    if alignY == "center" then 
      ay = ay + (by - ay - dxGetFontHeight(scale, font))/2 
    elseif alignY == "bottom" then 
      ay = by - dxGetFontHeight(scale, font) 
    end 
  end 
  local alpha = string.format("%08X", color):sub(1,2) 
  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(getColorFromString("#"..col..alpha)) end 
    if s ~= 1 or cap ~= "" then 
      local w = dxGetTextWidth(cap, scale, font) 
      dxDrawBorderedText(cap, ax, ay, ax + w, by, color, scale, font) 
      ax = ax + w 
      color = tocolor(getColorFromString("#"..col..alpha)) 
    end 
    last = e + 1 
    s, e, cap, col = str:find(pat, last) 
  end 
  if last <= #str then 
    cap = str:sub(last) 
    dxDrawBorderedText(cap, ax, ay, ax + dxGetTextWidth(cap, scale, font), by, color, scale, font) 
  end 
end 
  

Server

  
addEventHandler("onPlayerLogin", root, 
    function(_,account) 
        if isObjectInACLGroup( "user."..getAccountName(getPlayerAccount(source)), aclGetGroup('Server') ) then 
            bindKey(source, "o","up","chatbox","[server]") 
        end 
    end 
) 
  
addEventHandler("onResourceStart",getResourceRootElement(getThisResource()), 
    function() 
        for i,v in ipairs(getElementsByType('Player')) do 
            local acount = getPlayerAccount(v) 
            if isObjectInACLGroup("user."..getAccountName(acount), aclGetGroup('Server')) then 
                bindKey(v, "o","up","chatbox","[server]") 
           setCameraMatrix(source, 1468.8785400391, -919.25317382813, 100.153465271, 1468.388671875, -918.42474365234, 99.881813049316) 
            end 
        end 
    end 
) 
  
addEventHandler("onPlayerJoin", root, 
    function() 
        setTimer( function() 
            if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup('Server')) then 
                bindKey(source, "o","up","chatbox","[server]") 
                setCameraMatrix(source, 1468.8785400391, -919.25317382813, 100.153465271, 1468.388671875, -918.42474365234, 99.881813049316) 
            end 
        end, 500, 1 ) 
    end 
) 
  
function onAdminChat(player, _, ... ) 
    local tWords = { ... } 
    local tMessage = table.concat(tWords, " ") 
    triggerClientEvent("newmsg",player,tMessage) 
end 
addCommandHandler("[server]", onAdminChat) 

The same problem :(

Link to comment
my script The writing in the name of the [server] at the top of the server

But when a player goes out and enters the writing disappear

I want a way to make writing remain even if the player output and income

Thank you

You mean the script works, but you want the message to apper for any player that joins the server ?

Link to comment
my script The writing in the name of the [server] at the top of the server

But when a player goes out and enters the writing disappear

I want a way to make writing remain even if the player output and income

Thank you

You mean the script works, but you want the message to apper for any player that joins the server ?

YES !

Link to comment

Try this :

  
  
Client .. 
  
local msg = "" 
local player = nil 
local thereIsMessage = false 
local x,y = guiGetScreenSize() 
  
function drawMessage() 
    
    scale = 1.2 
    font = "default-bold" 
    h = dxGetFontHeight(scale, font) 
  
    if player == nil then 
        dxDrawColorText("#ff9900[server]#ffffff " .. msg,500, -1,x,250, tocolor(255,255,255),scale,font) 
    else 
        dxDrawColorText("#FF9900[server]#ffffff " .. msg ,500, -1,x,250, tocolor(255,255,255),scale,"default-bold") 
    
    end 
end 
  
addEventHandler("onClientResourceStart", resourceRoot, function( ) 
    if thereIsMessage then 
        addEventHandler( "onClientRender", localPlayer, drawMessage( ) ) 
    end 
end ) 
  
addEventHandler("onClientRender",getRootElement(),drawMessage) 
function newmsg(new) 
  
msg = new 
player = root 
thereIsMessage = true 
  
  
end 
addEvent("newmsg",true) 
addEventHandler("newmsg",getRootElement(),newmsg) 
  
function amoff() 
removeEventHandler("onClientRender", getRootElement(), drawMessage) 
end 
addEvent("amoff", true ) 
addEventHandler("amoff", getRootElement(), amoff) 
  
function rdx(msg) 
    removeEventHandler ( "onClientRender", getRootElement(), drawMessage ) 
    end 
addEvent("mR", true ) 
addEventHandler("mR", getRootElement(), rdx) 
  
function dxDrawBorderedText(text, xpos, ypos, w, h, color, scale, font) 
    
    dxDrawText ( text, xpos - 1, ypos - 1, w - 1, h - 1, tocolor ( 0, 0, 0, 255 ), scale, font ) -- black 
    dxDrawText ( text, xpos + 1, ypos - 1, w + 1, h - 1, tocolor ( 0, 0, 0, 255 ), scale, font ) 
    dxDrawText ( text, xpos - 1, ypos + 1, w - 1, h + 1, tocolor ( 0, 0, 0, 255 ), scale, font ) 
    dxDrawText ( text, xpos + 1, ypos + 1, w + 1, h + 1, tocolor ( 0, 0, 0, 255 ), scale, font ) 
    dxDrawText ( text, xpos - 1, ypos, w - 1, h, tocolor ( 0, 0, 0, 255 ), scale, font ) 
    dxDrawText ( text, xpos + 1, ypos, w + 1,h, tocolor ( 0, 0, 0, 255 ), scale, font ) 
    dxDrawText ( text, xpos, ypos - 1, w, h - 1, tocolor ( 0, 0, 0, 255 ), scale, font ) 
    dxDrawText ( text, xpos, ypos + 1, w, h + 1, tocolor ( 0, 0, 0, 255 ), scale, font ) 
    dxDrawText ( text, xpos, ypos, w, h, color, scale, font) 
    
end 
  
function dxDrawColorText(str, ax, ay, bx, by, color, scale, font, alignX, alignY) 
  bx, by, color, scale, font = bx or ax, by or ay, color or tocolor(255,255,255,255), scale or 1, font or "default" 
  if alignX then 
    if alignX == "center" then 
      ax = ax + (bx - ax - dxGetTextWidth(str:gsub("#%x%x%x%x%x%x",""), scale, font))/2 
    elseif alignX == "right" then 
      ax = bx - dxGetTextWidth(str:gsub("#%x%x%x%x%x%x",""), scale, font) 
    end 
  end 
  if alignY then 
    if alignY == "center" then 
      ay = ay + (by - ay - dxGetFontHeight(scale, font))/2 
    elseif alignY == "bottom" then 
      ay = by - dxGetFontHeight(scale, font) 
    end 
  end 
  local alpha = string.format("%08X", color):sub(1,2) 
  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(getColorFromString("#"..col..alpha)) end 
    if s ~= 1 or cap ~= "" then 
      local w = dxGetTextWidth(cap, scale, font) 
      dxDrawBorderedText(cap, ax, ay, ax + w, by, color, scale, font) 
      ax = ax + w 
      color = tocolor(getColorFromString("#"..col..alpha)) 
    end 
    last = e + 1 
    s, e, cap, col = str:find(pat, last) 
  end 
  if last <= #str then 
    cap = str:sub(last) 
    dxDrawBorderedText(cap, ax, ay, ax + dxGetTextWidth(cap, scale, font), by, color, scale, font) 
  end 
end 

Link to comment
Try this :
  
  
Client .. 
  
local msg = "" 
local player = nil 
local thereIsMessage = false 
local x,y = guiGetScreenSize() 
  
function drawMessage() 
    
    scale = 1.2 
    font = "default-bold" 
    h = dxGetFontHeight(scale, font) 
  
    if player == nil then 
        dxDrawColorText("#ff9900[server]#ffffff " .. msg,500, -1,x,250, tocolor(255,255,255),scale,font) 
    else 
        dxDrawColorText("#FF9900[server]#ffffff " .. msg ,500, -1,x,250, tocolor(255,255,255),scale,"default-bold") 
    
    end 
end 
  
addEventHandler("onClientResourceStart", resourceRoot, function( ) 
    if thereIsMessage then 
        addEventHandler( "onClientRender", localPlayer, drawMessage( ) ) 
    end 
end ) 
  
addEventHandler("onClientRender",getRootElement(),drawMessage) 
function newmsg(new) 
  
msg = new 
player = root 
thereIsMessage = true 
  
  
end 
addEvent("newmsg",true) 
addEventHandler("newmsg",getRootElement(),newmsg) 
  
function amoff() 
removeEventHandler("onClientRender", getRootElement(), drawMessage) 
end 
addEvent("amoff", true ) 
addEventHandler("amoff", getRootElement(), amoff) 
  
function rdx(msg) 
    removeEventHandler ( "onClientRender", getRootElement(), drawMessage ) 
    end 
addEvent("mR", true ) 
addEventHandler("mR", getRootElement(), rdx) 
  
function dxDrawBorderedText(text, xpos, ypos, w, h, color, scale, font) 
    
    dxDrawText ( text, xpos - 1, ypos - 1, w - 1, h - 1, tocolor ( 0, 0, 0, 255 ), scale, font ) -- black 
    dxDrawText ( text, xpos + 1, ypos - 1, w + 1, h - 1, tocolor ( 0, 0, 0, 255 ), scale, font ) 
    dxDrawText ( text, xpos - 1, ypos + 1, w - 1, h + 1, tocolor ( 0, 0, 0, 255 ), scale, font ) 
    dxDrawText ( text, xpos + 1, ypos + 1, w + 1, h + 1, tocolor ( 0, 0, 0, 255 ), scale, font ) 
    dxDrawText ( text, xpos - 1, ypos, w - 1, h, tocolor ( 0, 0, 0, 255 ), scale, font ) 
    dxDrawText ( text, xpos + 1, ypos, w + 1,h, tocolor ( 0, 0, 0, 255 ), scale, font ) 
    dxDrawText ( text, xpos, ypos - 1, w, h - 1, tocolor ( 0, 0, 0, 255 ), scale, font ) 
    dxDrawText ( text, xpos, ypos + 1, w, h + 1, tocolor ( 0, 0, 0, 255 ), scale, font ) 
    dxDrawText ( text, xpos, ypos, w, h, color, scale, font) 
    
end 
  
function dxDrawColorText(str, ax, ay, bx, by, color, scale, font, alignX, alignY) 
  bx, by, color, scale, font = bx or ax, by or ay, color or tocolor(255,255,255,255), scale or 1, font or "default" 
  if alignX then 
    if alignX == "center" then 
      ax = ax + (bx - ax - dxGetTextWidth(str:gsub("#%x%x%x%x%x%x",""), scale, font))/2 
    elseif alignX == "right" then 
      ax = bx - dxGetTextWidth(str:gsub("#%x%x%x%x%x%x",""), scale, font) 
    end 
  end 
  if alignY then 
    if alignY == "center" then 
      ay = ay + (by - ay - dxGetFontHeight(scale, font))/2 
    elseif alignY == "bottom" then 
      ay = by - dxGetFontHeight(scale, font) 
    end 
  end 
  local alpha = string.format("%08X", color):sub(1,2) 
  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(getColorFromString("#"..col..alpha)) end 
    if s ~= 1 or cap ~= "" then 
      local w = dxGetTextWidth(cap, scale, font) 
      dxDrawBorderedText(cap, ax, ay, ax + w, by, color, scale, font) 
      ax = ax + w 
      color = tocolor(getColorFromString("#"..col..alpha)) 
    end 
    last = e + 1 
    s, e, cap, col = str:find(pat, last) 
  end 
  if last <= #str then 
    cap = str:sub(last) 
    dxDrawBorderedText(cap, ax, ay, ax + dxGetTextWidth(cap, scale, font), by, color, scale, font) 
  end 
end 

not worked :(

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...