Jump to content

Help with Gridlist ( add players )


Adde

Recommended Posts

Hello, I have my panel here where it supposed to be showing player names in the gridlist. I did exactly as I read on wiki and in another topic but it wont work. Nothing in debug :/ can anyone see the problem?

just so you know, this:

GUIEditor = {

    tab = {},

    tabpanel = {},

    button = {},

    label = {},

    window = {},

    gridlist = {}

}

is not the problem, i just removed all labels and buttons to make it easier to read.

 

client

GUIEditor = { 
    tab = {}, 
    tabpanel = {}, 
    button = {}, 
    label = {}, 
    window = {}, 
    gridlist = {} 
} 
  
local x, y = guiGetScreenSize() 
  
GUIEditor.window[11] = guiCreateWindow(1389/1920*x, 359/1080*y, 475, 506, "Staff panel", false) 
guiWindowSetSizable(GUIEditor.window[11], false) 
guiSetVisible(GUIEditor.window[11], false) 
guiSetProperty(GUIEditor.window[11], "CaptionColour", "FFFF0000") 
  
GUIEditor.tabpanel[1] = guiCreateTabPanel(10, 23, 455, 473, false, GUIEditor.window[11]) 
        
GUIEditor.tab[11] = guiCreateTab("Players", GUIEditor.tabpanel[1]) 
       
GUIEditor.gridlist[1] = guiCreateGridList(9, 10, 187, 428, false, GUIEditor.tab[11]) 
guiGridListSetSelectionMode(GUIEditor.gridlist[1], 2) 
column = guiGridListAddColumn(GUIEditor.gridlist[1], "Player Name", 1) 
  
function Refresh () 
  guiGridListClear ( GUIEditor_gridlist[1] ) 
  if column then 
    for id,playeritem in ipairs(getElementsByType("player")) do 
      local row = guiGridListAddRow(GUIEditor_gridlist[1]) 
      guiGridListSetItemText(GUIEditor_gridlist[1], row, column, getPlayerName(playeritem), false, false) 
    end 
  end 
end 
addEventHandler ( "onClientPlayerJoin", getRootElement(), Refresh ) 
addEventHandler ( "onClientPlayerQuit", getRootElement(), Refresh ) 
addEventHandler ( "onClientPlayerChangeNick", getRootElement(), Refresh ) 

Link to comment
Hello, I have my panel here where it supposed to be showing player names in the gridlist. I did exactly as I read on wiki and in another topic but it wont work. Nothing in debug :/ can anyone see the problem?

just so you know, this:

GUIEditor = {

    tab = {},

    tabpanel = {},

    button = {},

    label = {},

    window = {},

    gridlist = {}

}

is not the problem, i just removed all labels and buttons to make it easier to read.

 

client

GUIEditor = { 
    tab = {}, 
    tabpanel = {}, 
    button = {}, 
    label = {}, 
    window = {}, 
    gridlist = {} 
} 
  
local x, y = guiGetScreenSize() 
  
GUIEditor.window[11] = guiCreateWindow(1389/1920*x, 359/1080*y, 475, 506, "Staff panel", false) 
guiWindowSetSizable(GUIEditor.window[11], false) 
guiSetVisible(GUIEditor.window[11], false) 
guiSetProperty(GUIEditor.window[11], "CaptionColour", "FFFF0000") 
  
GUIEditor.tabpanel[1] = guiCreateTabPanel(10, 23, 455, 473, false, GUIEditor.window[11]) 
        
GUIEditor.tab[11] = guiCreateTab("Players", GUIEditor.tabpanel[1]) 
       
GUIEditor.gridlist[1] = guiCreateGridList(9, 10, 187, 428, false, GUIEditor.tab[11]) 
guiGridListSetSelectionMode(GUIEditor.gridlist[1], 2) 
column = guiGridListAddColumn(GUIEditor.gridlist[1], "Player Name", 1) 
  
function Refresh () 
  guiGridListClear ( GUIEditor_gridlist[1] ) 
  if column then 
    for id,playeritem in ipairs(getElementsByType("player")) do 
      local row = guiGridListAddRow(GUIEditor_gridlist[1]) 
      guiGridListSetItemText(GUIEditor_gridlist[1], row, column, getPlayerName(playeritem), false, false) 
    end 
  end 
end 
addEventHandler ( "onClientPlayerJoin", getRootElement(), Refresh ) 
addEventHandler ( "onClientPlayerQuit", getRootElement(), Refresh ) 
addEventHandler ( "onClientPlayerChangeNick", getRootElement(), Refresh ) 

lol that's my code just a second and I will post a fix for you

Edit: here is it

clientsideResourceStart = function() 
  if column then 
    for id,playeritem in ipairs(getElementsByType("player")) do 
      local row = guiGridListAddRow(GUIEditor_Grid[1]) 
      guiGridListSetItemText(GUIEditor_Grid[1], row, column, getPlayerName(playeritem), false, false) 
    end 
  end 
end 
addEventHandler ( "onClientResourceStart", resourceRoot, clientsideResourceStart ) 
  
function Refresh () 
  guiGridListClear ( GUIEditor_Grid[1] ) 
  if column then 
    for id,playeritem in ipairs(getElementsByType("player")) do 
      local row = guiGridListAddRow(GUIEditor_Grid[1]) 
      guiGridListSetItemText(GUIEditor_Grid[1], row, column, getPlayerName(playeritem), false, false) 
    end 
  end 
end 
addEventHandler ( "onClientPlayerJoin", getRootElement(), Refresh ) 
addEventHandler ( "onClientPlayerQuit", getRootElement(), Refresh ) 
addEventHandler ( "onClientPlayerChangeNick", getRootElement(), Refresh ) 

That's should work :)

Edit: else edit the gui Grid list name in the code because it's different than yours.

Link to comment

Btw, I don´t remember how I use guiGridListGetSelectedItem to use for players. I found something and tried to code it. Is this right?

function kick() 
if ( guiGridListGetSelectedItem ( GUIEditor.Grid ) ~= -1 ) then 
        local player = getPlayerFromNick ( guiGridListGetItemPlayerName ( GUIEditor.Grid, guiGridListGetSelectedItem( GUIEditor.Grid ), 1 ) ) 
if ( player ) then 
triggerServerEvent( player, "kickplayer") 

end

end

addEventhandler("onClientGuiClick", GUIEditor.button[5], kick)

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