Castillo Posted September 23, 2012 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. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Kenix Posted September 23, 2012 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. http://vk.com/the_kenix Вопросы задавайте на форуме, не пишите мне в личку. Please don't pm me.
Castillo Posted September 23, 2012 Author 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 ) San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Castillo Posted September 23, 2012 Author Posted September 23, 2012 You're welcome. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
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