aintaro Posted March 31, 2014 Share Posted March 31, 2014 Hello guys, I'm having a problem with my gridlist, I first load players in the list and whenever I want to click them it does not print their name in the outputchat box, Why does this code not work? --Create the gridlist with players in function createPlayerList () -- Create the grid list playerList = guiCreateGridList ( 0.80, 0.10, 0.15, 0.60, true ) -- Create a players column in the list local column = guiGridListAddColumn( playerList, "Player", 0.85 ) if ( column ) then -- If the column has been created, fill it with players for id, playeritem in ipairs(getElementsByType("player")) do local row = guiGridListAddRow ( playerList ) guiGridListSetItemText ( playerList, row, column, getPlayerName ( playeritem ), false, false ) end addEventHandler ( "onClientGUIClick", playerList, click ) end end --addEventHandler ( "onClientResourceStart", getRootElement(), createPlayerList ) --handle the player click when he clicks on a gridlist item function click ( button, state, sx, sy, x, y, z, elem, gui ) -- if state is down ( not to trigger the function twice on mouse button up/down), clicked gui and the element is our player list if ( ( state == "down" ) and ( gui == true ) and ( source == playerList ) ) then -- get the player name from the selected row, first column local playerName = guiGridListGetItemText ( playerList, guiGridListGetSelectedItem ( playerList ), 1 ) outputChatBox ( playerName ) -- output it to chat box end end --This function is called when we start the client addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), function () -- create the log in window and its components createPlayerList () -- enable the players cursor (so they can select and click on the components) showCursor(true) -- set the input focus onto the GUI, allowing players (for example) to press 'T' without the chatbox opening guiSetInputEnabled(true) end ) Thanks in advance, Greetz Aintaro Link to comment
aintaro Posted March 31, 2014 Author Share Posted March 31, 2014 Anybody please could help me with guigridlist? Link to comment
WhoAmI Posted March 31, 2014 Share Posted March 31, 2014 Check this function createPlayerList () -- Create the grid list playerList = guiCreateGridList ( 0.80, 0.10, 0.15, 0.60, true ) -- Create a players column in the list local column = guiGridListAddColumn( playerList, "Player", 0.85 ) if ( column ) then -- If the column has been created, fill it with players for id, playeritem in ipairs(getElementsByType("player")) do local row = guiGridListAddRow ( playerList ) guiGridListSetItemText ( playerList, row, column, getPlayerName ( playeritem ), false, false ) end end end --addEventHandler ( "onClientResourceStart", getRootElement(), createPlayerList ) --handle the player click when he clicks on a gridlist item function click ( button, state, sx, sy, x, y, z, elem, gui ) -- if state is down ( not to trigger the function twice on mouse button up/down), clicked gui and the element is our player list if ( ( state == "down" ) and ( gui == true ) and ( source == playerList ) ) then -- get the player name from the selected row, first column local playerName = guiGridListGetItemText ( playerList, guiGridListGetSelectedItem ( playerList ), 1 ) outputChatBox ( playerName ) -- output it to chat box end end addEventHandler ( "onClientGUIClick", playerList, click ) --This function is called when we start the client addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), function () -- create the log in window and its components createPlayerList () -- enable the players cursor (so they can select and click on the components) showCursor(true) -- set the input focus onto the GUI, allowing players (for example) to press 'T' without the chatbox opening guiSetInputEnabled(true) end ) Link to comment
aintaro Posted March 31, 2014 Author Share Posted March 31, 2014 Nop did not work, I clicked my name on the gridlist but nothing printed out Link to comment
WhoAmI Posted March 31, 2014 Share Posted March 31, 2014 Well, your code in 1st post should work. Make sure that script in meta is client and check debugscript 3. Link to comment
aintaro Posted March 31, 2014 Author Share Posted March 31, 2014 Ok thanks for information, i'll try on a blank gamemode Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now