Jump to content

Help me DxLibrary


Recommended Posts

I'm having problems starting the panel and the labels don't appear, everything works except the labels

https://imgur.com/a/rbFlm8J

coding Script.lua:

local sx, sy = guiGetScreenSize()
local sw, sh = sx / 1680, sy / 1050
local panelVisible = false
loadstring(exports.dxlibrary:dxGetLibrary())()
 
-- Carregar a fonte Inter-Medium.ttf
dxFont('assets/fonts/Inter-Medium.ttf', 12, true)
 
function showPanel()
    outputDebugString("showPanel() chamado")
    if not panelVisible then
        dxEditor = {}
        dxEditor['dxWindow'] = {}
        dxEditor['dxGridList'] = {}
        dxEditor['dxEdit'] = {}
        dxEditor['dxButton'] = {}
        dxEditor['dxLabel'] = {}
 
        dxEditor['dxWindow'][1] = dxWindow(136 * sw, 271 * sh, 584 * sw, 256 * sh, 'Painel de Vendas', false, 7, nil, -15856105, -1, -15856105)
        dxEditor['dxGridList'][1] = dxGridList(160 * sw, 315 * sh, 154 * sw, 179 * sh, dxEditor['dxWindow'][1], -15461346, -1, -12177770, -14474451, nil, nil, nil)
        dxEditor['dxEdit'][1] = dxEdit(361 * sw, 346 * sh, 323 * sw, 24 * sh, '', dxEditor['dxWindow'][1], false, -1, nil, -13426320, -12177770)
        dxEditor['dxEdit'][2] = dxEdit(396 * sw, 421 * sh, 96 * sw, 24 * sh, '', dxEditor['dxWindow'][1], false, -1, nil, -13426320, -12177770)
        dxEditor['dxButton'][1] = dxButton(438 * sw, 475 * sh, 76 * sw, 25 * sh, 'ENVIAR', dxEditor['dxWindow'][1], 2, -12177770, -1, -12506991)
        dxEditor['dxButton'][2] = dxButton(539 * sw, 475 * sh, 76 * sw, 25 * sh, 'FECHAR', dxEditor['dxWindow'][1], 2, -12177770, -1, -12506991)
       
        -- Alterar a fonte dos labels para Inter-Medium
        dxEditor['dxLabel'][1] = dxLabel(488 * sw, 323 * sh, 78 * sw, 20 * sh, 'DESCRIÇÃO', dxEditor['dxWindow'][1], 'center', 'top', nil, -1, -1, nil)
        dxSetFont(dxEditor['dxLabel'][1], 'Inter-Medium', 12)
       
        dxEditor['dxLabel'][2] = dxLabel(421 * sw, 397 * sh, 47 * sw, 20 * sh, 'VALOR', dxEditor['dxWindow'][1], 'center', 'top', nil, -1, -1, nil)
        dxSetFont(dxEditor['dxLabel'][2], 'Inter-Medium', 12)
       
        dxEditor['dxLabel'][3] = dxLabel(576 * sw, 397 * sh, 67 * sw, 20 * sh, 'CONTATO', dxEditor['dxWindow'][1], 'center', 'top', nil, -1, -1, nil)
        dxSetFont(dxEditor['dxLabel'][3], 'Inter-Medium', 12)
       
        dxEditor['dxEdit'][3] = dxEdit(560 * sw, 421 * sh, 96 * sw, 24 * sh, '', dxEditor['dxWindow'][1], false, -1, nil, -13426320, -12177770)
       
        dxEditor['dxLabel'][4] = dxLabel(201 * sw, 314 * sh, 78 * sw, 20 * sh, 'categorias', dxEditor['dxWindow'][1], 'center', 'top', nil, -1, -1, nil)
        dxSetFont(dxEditor['dxLabel'][4], 'Inter-Medium', 12)
       
        panelVisible = true
        showCursor(true)
    end
end
 
function hidePanel()
    if panelVisible then
        -- Fechar todos os elementos do painel aqui
        -- Exemplo: destroyElement(dxEditor['dxWindow'][1])
       
        panelVisible = false
        showCursor(false)
    end
end
 
function onPlayerCommand(cmd)
    outputDebugString("Comando recebido: " .. cmd)
    if cmd == "anunciar" then
        showPanel()
    end
end
addCommandHandler("anunciar", onPlayerCommand)
 
 
----------------------------------------------------------------
 
meta.xml:
<meta>
    <script src="script.lua" type="client" cache="false" />
 
    <file src="assets/fonts/Inter-Medium.ttf" />
</meta>
Link to comment
local sx, sy = guiGetScreenSize()
local sw, sh = sx / 1680, sy / 1050
local panelVisible = false
loadstring(exports.dxlibrary:dxGetLibrary())()

-- Carregar a fonte Inter-Medium.ttf
local fontLoaded = dxCreateFont('assets/fonts/Inter-Medium.ttf', 12, true)
if not fontLoaded then
    outputDebugString("Falha ao carregar a fonte Inter-Medium.ttf")
else
    outputDebugString("Fonte Inter-Medium.ttf carregada com sucesso")
end

function showPanel()
    outputDebugString("showPanel() chamado")
    if not panelVisible then
        dxEditor = {}
        dxEditor['dxWindow'] = {}
        dxEditor['dxGridList'] = {}
        dxEditor['dxEdit'] = {}
        dxEditor['dxButton'] = {}
        dxEditor['dxLabel'] = {}

        dxEditor['dxWindow'][1] = dxWindow(136 * sw, 271 * sh, 584 * sw, 256 * sh, 'Painel de Vendas', false, 7, nil, -15856105, -1, -15856105)
        dxEditor['dxGridList'][1] = dxGridList(160 * sw, 315 * sh, 154 * sw, 179 * sh, dxEditor['dxWindow'][1], -15461346, -1, -12177770, -14474451, nil, nil, nil)
        dxEditor['dxEdit'][1] = dxEdit(361 * sw, 346 * sh, 323 * sw, 24 * sh, '', dxEditor['dxWindow'][1], false, -1, nil, -13426320, -12177770)
        dxEditor['dxEdit'][2] = dxEdit(396 * sw, 421 * sh, 96 * sw, 24 * sh, '', dxEditor['dxWindow'][1], false, -1, nil, -13426320, -12177770)
        dxEditor['dxButton'][1] = dxButton(438 * sw, 475 * sh, 76 * sw, 25 * sh, 'ENVIAR', dxEditor['dxWindow'][1], 2, -12177770, -1, -12506991)
        dxEditor['dxButton'][2] = dxButton(539 * sw, 475 * sh, 76 * sw, 25 * sh, 'FECHAR', dxEditor['dxWindow'][1], 2, -12177770, -1, -12506991)
       
        -- Alterar a fonte dos labels para Inter-Medium
        dxEditor['dxLabel'][1] = dxLabel(488 * sw, 323 * sh, 78 * sw, 20 * sh, 'DESCRIÇÃO', dxEditor['dxWindow'][1], 'center', 'top', nil, -1, -1, nil)
        if fontLoaded then
            dxSetFont(dxEditor['dxLabel'][1], fontLoaded)
        end
       
        dxEditor['dxLabel'][2] = dxLabel(421 * sw, 397 * sh, 47 * sw, 20 * sh, 'VALOR', dxEditor['dxWindow'][1], 'center', 'top', nil, -1, -1, nil)
        if fontLoaded then
            dxSetFont(dxEditor['dxLabel'][2], fontLoaded)
        end
       
        dxEditor['dxLabel'][3] = dxLabel(576 * sw, 397 * sh, 67 * sw, 20 * sh, 'CONTATO', dxEditor['dxWindow'][1], 'center', 'top', nil, -1, -1, nil)
        if fontLoaded then
            dxSetFont(dxEditor['dxLabel'][3], fontLoaded)
        end
       
        dxEditor['dxEdit'][3] = dxEdit(560 * sw, 421 * sh, 96 * sw, 24 * sh, '', dxEditor['dxWindow'][1], false, -1, nil, -13426320, -12177770)
       
        dxEditor['dxLabel'][4] = dxLabel(201 * sw, 314 * sh, 78 * sw, 20 * sh, 'categorias', dxEditor['dxWindow'][1], 'center', 'top', nil, -1, -1, nil)
        if fontLoaded then
            dxSetFont(dxEditor['dxLabel'][4], fontLoaded)
        end
       
        panelVisible = true
        showCursor(true)
    end
end
 
function hidePanel()
    if panelVisible then
        -- Fechar todos os elementos do painel aqui
        -- Exemplo: destroyElement(dxEditor['dxWindow'][1])
       
        panelVisible = false
        showCursor(false)
    end
end
 
function onPlayerCommand(cmd)
    outputDebugString("Comando recebido: " .. cmd)
    if cmd == "anunciar" then
        showPanel()
    end
end
addCommandHandler("anunciar", onPlayerCommand)

 

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