Castillo Posted September 23, 2012 Share Posted September 23, 2012 pList = guiCreateGridList(194,9,300,300,false,wn) column = guiGridListAddColumn( pList, "Player", 0.85 ) function refresh ( ) guiGridListClear ( pList ) for id, player in ipairs ( getElementsByType ( "player" ) ) do local row = guiGridListAddRow ( pList ) guiGridListSetItemText ( pList, row, column, getPlayerName ( player ), false, false ) end end addEventHandler ( "onClientResourceStart", resourceRoot, refresh ) addEventHandler ( "onClientPlayerJoin", root, refresh ) addEventHandler ( "onClientPlayerQuit", root, refresh ) addEventHandler ( "onClientPlayerChangeNick", root, refresh ) That'll update it every time a player joins/quits/changes nick. Link to comment
Kenix Posted September 23, 2012 Share Posted September 23, 2012 When some player quit or join or changed nick it will clear all grid list with select item. Better make find and set text when player changed nick name and when player quit remove row and when player joined add row but not clear all gridlist. Link to comment
Castillo Posted September 23, 2012 Author Share Posted September 23, 2012 pList = guiCreateGridList(194,9,300,300,false,wn) column = guiGridListAddColumn( pList, "Player", 0.85 ) function refresh ( ) for id, player in ipairs ( getElementsByType ( "player" ) ) do guiGridListSetItemText ( pList, guiGridListAddRow ( pList ), column, getPlayerName ( player ), false, false ) end end addEventHandler ( "onClientResourceStart", resourceRoot, refresh ) function update ( old, new ) if ( eventName == "onClientPlayerJoin" ) then guiGridListSetItemText ( pList, guiGridListAddRow ( pList ), column, getPlayerName ( source ), false, false ) elseif ( eventName == "onClientPlayerQuit" ) then for row = 0, guiGridListGetRowCount ( pList ) do if ( guiGridListGetItemText ( pList, row, column ) == getPlayerName ( source ) ) then guiGridListRemoveRow ( pList, row ) break end end elseif ( eventName == "onClientPlayerChangeNick" ) then for row = 0, guiGridListGetRowCount ( pList ) do if ( guiGridListGetItemText ( pList, row, column ) == old ) then guiGridListSetItemText ( pList, row, column, new, false, false ) break end end end end addEventHandler ( "onClientPlayerJoin", root, update ) addEventHandler ( "onClientPlayerQuit", root, update ) addEventHandler ( "onClientPlayerChangeNick", root, update ) Link to comment
Castillo Posted September 23, 2012 Author Share Posted September 23, 2012 You're welcome. 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