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 )