Sasu Posted March 11, 2013 Share Posted March 11, 2013 How can I do to create a one a row for player and no create much row of the same player ? And also How can I do to uptade the list? function actualizarLista() if ( columnPlayers ) then for id, player in ipairs(getElementsByType("player")) do row = guiGridListAddRow ( playerLista ) guiGridListSetItemText ( playerLista, row, columnPlayers, getPlayerName ( player ), false, false ) end end end addEventHandler("onClientPlayerJoin", getRootElement(), actualizarLista) addEventHandler("onClientPlayerChangeNick", getRootElement(), actualizarLista) addEventHandler("onClientResourceStart", getRootElement(), actualizarLista) Link to comment
OGF Posted March 11, 2013 Share Posted March 11, 2013 function update ( old, new ) if ( eventName == "onClientPlayerJoin" ) then guiGridListSetItemText ( playerlist, guiGridListAddRow ( playerlist ), pcolumn, getPlayerName ( source ), false, false ) elseif ( eventName == "onClientPlayerQuit" ) then for row = 0, guiGridListGetRowCount ( playerlist ) do if ( guiGridListGetItemText ( playerlist, row, pcolumn ) == getPlayerName ( source ) ) then guiGridListRemoveRow ( playerlist, row ) break end end elseif ( eventName == "onClientPlayerChangeNick" ) then for row = 0, guiGridListGetRowCount ( playerlist ) do if ( guiGridListGetItemText ( playerlist, row, pcolumn ) == old ) then guiGridListSetItemText ( playerlist, row, pcolumn, new, false, false ) break end end end end addEventHandler ( "onClientPlayerJoin", root, update ) addEventHandler ( "onClientPlayerQuit", root, update ) addEventHandler ( "onClientPlayerChangeNick", root, update ) Link to comment
OGF Posted March 11, 2013 Share Posted March 11, 2013 its' the one i used, i copied it from my script, just replace playerlist with yours. Link to comment
Sasu Posted March 11, 2013 Author Share Posted March 11, 2013 Doesnt work and no error on debug 3 . P.D.: Can I use to do public resource? Link to comment
Dice Posted March 11, 2013 Share Posted March 11, 2013 function update ( old, new ) if ( eventName == "onClientPlayerJoin" ) then guiGridListSetItemText ( playerLista, guiGridListAddRow ( playerLista), columnPlayers, getPlayerName ( source ), false, false ) elseif ( eventName == "onClientPlayerQuit" ) then for row = 0, guiGridListGetRowCount ( playerLista) do if ( guiGridListGetItemText ( playerLista, row, columnPlayers) == getPlayerName ( source ) ) then guiGridListRemoveRow ( playerLista, row ) break end end elseif ( eventName == "onClientPlayerChangeNick" ) then for row = 0, guiGridListGetRowCount ( playerLista) do if ( guiGridListGetItemText ( playerLista, row, columnPlayers) == old ) then guiGridListSetItemText ( playerLista, row, columnPlayers, new, false, false ) break end end end end addEventHandler ( "onClientPlayerJoin", root, update ) addEventHandler ( "onClientPlayerQuit", root, update ) addEventHandler ( "onClientPlayerChangeNick", root, update ) Try now I replaced all the variables with yours. Link to comment
Sasu Posted March 11, 2013 Author Share Posted March 11, 2013 I did that but doesnt work. Link to comment
PaiN^ Posted March 11, 2013 Share Posted March 11, 2013 (edited) for i,v in ipairs( getElementsByType( "player" ) ) do local row = guiGridListAddRow( playerList ) guiGridListSetItemText( playerList, row, columnPlayers, getPlayerName( v )[1], false, false ) end If it didn't work, try this : function getAllPlayers ( ) guiGridListClear( playerList ) for i,v in ipairs( getElementsByType( "player" ) ) do local row = guiGridListAddRow( playerList ) guiGridListSetItemText( playerList, row, 1, getPlayerName( v ), false, false ) end end Edited March 12, 2013 by Guest Link to comment
Sasu Posted March 12, 2013 Author Share Posted March 12, 2013 for i,v in ipairs( getElementsByType( "player" ) ) do local row = guiGridListAddRow( playerList ) guiGridListSetItemText( playerList, row, columnPlayers, getPlayerName( v )[1], false, false ) end function update ( old, new ) if ( eventName == "onClientPlayerJoin" ) then for i,v in ipairs(getElementsByType("player")) do guiGridListSetItemText ( playerLista, guiGridListAddRow (playerLista), columnPlayers, v, false, false ) end elseif ( eventName == "onClientPlayerQuit" ) then for row = 0, guiGridListGetRowCount ( playerLista) do for i,v in ipairs(getElementsByType("player")) do if ( guiGridListGetItemText ( playerLista, row, columnPlayers) == v ) then end guiGridListRemoveRow ( playerLista, row ) break end end elseif ( eventName == "onClientPlayerChangeNick" ) then for row = 0, guiGridListGetRowCount ( playerLista) do if ( guiGridListGetItemText ( playerLista, row, columnPlayers) == old ) then guiGridListSetItemText ( playerLista, row, columnPlayers, new, false, false ) break end end end end addEventHandler ( "onClientPlayerJoin", root, update ) addEventHandler ( "onClientPlayerQuit", root, update ) addEventHandler ( "onClientPlayerChangeNick", root, update ) Correctly? But doesnt work and any error on debug 3 U.U Link to comment
PaiN^ Posted March 12, 2013 Share Posted March 12, 2013 Use my code : function getAllPlayers ( ) guiGridListClear( playerList ) for i,v in ipairs( getElementsByType( "player" ) ) do local row = guiGridListAddRow( playerList ) guiGridListSetItemText( playerList, row, 1, getPlayerName( v ), false, false ) end end and add the function to the open function, Like this : function ( ) if guiGetVisible( window ) then guiSetVisible( window, false ) showCursor( false ) guiSetInputEnabled( false ) else guiSetVisible( window, true ) showCursor( true ) guiSetInputEnabled( true ) getAllPlayers( ) end end ) Link to comment
OGF Posted March 12, 2013 Share Posted March 12, 2013 Sasuke*, my code literally works for me, are you sure you are not getting any type of errors? is your playerlist openable by some KEY? command? How is it triggered? Link to comment
TheIceman1 Posted March 12, 2013 Share Posted March 12, 2013 Try this: function actualizarLista() if ( columnPlayers ) then for id, playeritem in ipairs(getElementsByType("player")) do local row = guiGridListAddRow ( playerLista ) guiGridListSetItemText ( playerLista, row, columnPlayers, getPlayerName( playeritem ), false, false ) end end addEventHandler("onClientPlayerJoin", getRootElement(), actualizarLista) addEventHandler("onClientPlayerChangeNick", getRootElement(), actualizarLista) addEventHandler("onClientResourceStart", getRootElement(), actualizarLista) Link to comment
Sasu Posted March 12, 2013 Author Share Posted March 12, 2013 Use my code :function getAllPlayers ( ) guiGridListClear( playerList ) for i,v in ipairs( getElementsByType( "player" ) ) do local row = guiGridListAddRow( playerList ) guiGridListSetItemText( playerList, row, 1, getPlayerName( v ), false, false ) end end and add the function to the open function, Like this : function ( ) if guiGetVisible( window ) then guiSetVisible( window, false ) showCursor( false ) guiSetInputEnabled( false ) else guiSetVisible( window, true ) showCursor( true ) guiSetInputEnabled( true ) getAllPlayers( ) end end ) Its works. Thanks All. 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