Jump to content

Adicionar resources á uma gridlist


Recommended Posts

Salve.
Queria adicionar row's á uma GridList com todos os resources.

Tentei isso:

-- server_side

function abrirPainel(thePlayer)
  local resources = getResources()
  triggerClientEvent ( thePlayer, "abrirP", thePlayer, resources )
end
addCommandHandler("resources", abrirPainel)

 

-- client_side

aberto = false;

GUI = {
    gridlist = {},
    window = {},
    button = {},
    label = {}
}

  local screenW, screenH = guiGetScreenSize()
  GUI.window[1] = guiCreateWindow((screenW - 567) / 2, (screenH - 311) / 2, 567, 311, "RESOURCE MANAGEMENT", false)
  guiWindowSetSizable(GUI.window[1], false)
  guiSetProperty(GUI.window[1], "CaptionColour", "FF1DA7E1")

  GUI.gridlist[1] = guiCreateGridList(38, 39, 379, 250, false, GUI.window[1])
  guiGridListAddColumn(GUI.gridlist[1], "RESOURCE", 1)
  GUI.button[1] = guiCreateButton(427, 111, 126, 21, "INICIAR", false, GUI.window[1])
  guiSetProperty(GUI.button[1], "NormalTextColour", "FFFFFFFF")
  GUI.button[2] = guiCreateButton(427, 142, 126, 21, "REINICIAR", false, GUI.window[1])
  guiSetProperty(GUI.button[2], "NormalTextColour", "FFFFFFFF")
  GUI.button[3] = guiCreateButton(427, 173, 126, 21, "PARAR", false, GUI.window[1])
  guiSetProperty(GUI.button[3], "NormalTextColour", "FFFFFFFF")
  GUI.label[1] = guiCreateLabel(38, 26, 379, 13, "CARREGANDO RESOURCES", false, GUI.window[1])
  guiLabelSetHorizontalAlign(GUI.label[1], "center", false)
  guiLabelSetVerticalAlign(GUI.label[1], "center")
  GUI.button[4] = guiCreateButton(427, 264, 126, 21, "ATUALIZAR LISTA", false, GUI.window[1])
  guiSetProperty(GUI.button[4], "NormalTextColour", "FFA9A9A9")    

  guiSetVisible(GUI.window[1], false)

function abrir(tabela)
  if aberto == false then
    guiSetVisible(GUI.window[1], true)
    guiSetText(GUI.label[1], "CARREGANDO RESOURCES")
    carregarResources(tabela)

    showCursor(true)
    aberto = true

  else
    guiSetVisible(GUI.window[1], false)
    showCursor(false)
    aberto = false
  end
end
addEvent( "abrirP", true )
addEventHandler( "abrirP", localPlayer, abrir )

function carregarResources(tabelaDeResources)
  for resourceKey, resourceValue in ipairs(tabelaDeResources) do
    local name = getResourceName(resourceValue)
    guiGridListAddRow(GUI.gridlist[1], name)
  end
end


Não apresenta nenhum erro, só não adiciona os resources.

Grato se puderem ajudar...

Edited by SrPattif
Link to comment
11 hours ago, KronoS Lettify said:

Os objetos-resource não são transferidos via evento, você teria que criar uma nova tabela com os nomes dos resources e então enviá-los ao client.

O que eu fiz:
Ao lado CLIENTE, ele faz a solicitação da tabela getResources() via triggerServerEvent.
Ao lado SERVIDOR, depois que o triggerServerEvent foi chamado, ele faz um triggerClientEvent, retornando nele, a tabela do getResources()

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