Khalil Posted September 20, 2013 Share Posted September 20, 2013 Hello. I made a gridlist to get all players in the server. I do the command to open the gui and it looks fine. I close the gui, and open it again, then I find three of the same player on the gridlist, I don't know what to do, here's the code: function showGUI ( ) local tostate = not guiGetVisible ( win ) guiSetVisible ( win, tostate ) showCursor ( tostate ) for index, player in ipairs ( getElementsByType ( 'player' ) ) do if ( player ~= localPlayer ) then guiGridListSetItemText ( gridList, guiGridListAddRow ( gridList ), 1, getPlayerName ( player ), false, false ) end end end addCommandHandler("aj",showGUI) Link to comment
bandi94 Posted September 20, 2013 Share Posted September 20, 2013 function showGUI ( ) local tostate = not guiGetVisible ( win ) guiSetVisible ( win, tostate ) showCursor ( tostate ) guiGridListClear(gridList) for index, player in ipairs ( getElementsByType ( 'player' ) ) do if ( player ~= localPlayer ) then guiGridListSetItemText ( gridList, guiGridListAddRow ( gridList ), 1, getPlayerName ( player ), false, false ) end end end addCommandHandler("aj",showGUI) Link to comment
Khalil Posted September 20, 2013 Author Share Posted September 20, 2013 Works fine thanks Also, when a player leaves the server, the gridlist should automatically refresh, how do I do that? Link to comment
bandi94 Posted September 20, 2013 Share Posted September 20, 2013 function refreshGUI() guiGridListClear(gridList) for index, player in ipairs ( getElementsByType ( 'player' ) ) do if ( player ~= localPlayer ) then guiGridListSetItemText ( gridList, guiGridListAddRow ( gridList ), 1, getPlayerName ( player ), false, false ) end end end addEventHandler( "onClientPlayerQuit", getRootElement(), refreshGUI ) 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