abu5lf Posted April 6, 2012 Share Posted April 6, 2012 (edited) function onClientGUIChanged() local name = guiGetText(source) for index, player in pairs(getElementsByType("player")) do if string.find(getPlayerName(player):lower(), name:lower()) then local column = guiGridListAddColumn ( playerlist, "Player Name", 1.50 ) if ( column ) then for id, playeritem in ipairs ( getElementsByType ( "player" ) ) do local row = guiGridListAddRow ( playerlist ) guiGridListSetItemText ( playerlist, row, column, getPlayerName( playeritem ), false, false ) end end end end end addEventHandler("onClientGUIChanged", bhsh, onClientGUIChanged) This edit does not work correctly, so finds a player Edited December 25, 2012 by Guest Link to comment
X-SHADOW Posted April 6, 2012 Share Posted April 6, 2012 why you use getElementsByType 2 times ? function onClientGUIChanged() local name = guiGetText(source) if string.find(getPlayerName(player):lower(), name:lower()) then local column = guiGridListAddColumn ( playerlist, "Player Name", 1.50 ) if ( column ) then for id, playeritem in ipairs ( getElementsByType ( "player" ) ) do local row = guiGridListAddRow ( playerlist ) guiGridListSetItemText ( playerlist, row, column, getPlayerName( playeritem ), false, false ) end end end end addEventHandler("onClientGUIChanged", bhsh, onClientGUIChanged) Link to comment
abu5lf Posted April 6, 2012 Author Share Posted April 6, 2012 why you use getElementsByType 2 times ? function onClientGUIChanged() local name = guiGetText(source) if string.find(getPlayerName(player):lower(), name:lower()) then local column = guiGridListAddColumn ( playerlist, "Player Name", 1.50 ) if ( column ) then for id, playeritem in ipairs ( getElementsByType ( "player" ) ) do local row = guiGridListAddRow ( playerlist ) guiGridListSetItemText ( playerlist, row, column, getPlayerName( playeritem ), false, false ) end end end end addEventHandler("onClientGUIChanged", bhsh, onClientGUIChanged) Code does not work ^ The script works, but only if my right to search for the player repeats in Grid List Link to comment
abu5lf Posted April 6, 2012 Author Share Posted April 6, 2012 show your full code . Well,There are those who can help without full Code Show Link to comment
drk Posted April 6, 2012 Share Posted April 6, 2012 local column = guiGridListAddColumn ( playerlist, 'Player Name', 1.50 ) addEventHandler ( 'onClientGUIChanged', root, function ( ) if ( source == bhsh ) then guiGridListClear ( playerlist ); local sName = guiGetText ( source ); if ( sName ~= "" ) then for _, pPlayer in ipairs ( getElementsByType 'player' ) do if ( string.find ( getPlayerName ( pPlayer ):lower ( ), sName:lower ( ), 1, true ) then local row = guiGridListAddRow ( playerlist ); guiGridListSetItemText ( playerlist, row, column, getPlayerName ( pPlayer ), false, false ); end end end end end ) 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