#Madara Posted August 3, 2015 Share Posted August 3, 2015 Hi Guys , How i Make Search in Gridlist When player write in Edit Example : when i write in edit madara he show to me the player his name madara i added all players in gridlist and everythink but now i want to know how to make search ? Link to comment
GTX Posted August 3, 2015 Share Posted August 3, 2015 addEventHandler("onClientGUIChanged", root, function() if source == edit then guiGridListClear(grid) for i, v in ipairs(getElementsByType"player") do if string.find(string.lower(string.gsub(getPlayerName(v), "#%x%x%x%x%x%x", "")), guiGetText(source)) then guiGridListSetItemText(grid, guiGridListAddRow(grid), column, getPlayerName(v), false, false) end end end end ) 1 Link to comment
#Madara Posted August 3, 2015 Author Share Posted August 3, 2015 addEventHandler("onClientGUIChanged", root, function() if source == edit then guiGridListClear(grid) for i, v in ipairs(getElementsByType"player") do if string.find(string.lower(string.gsub(getPlayerName(v), "#%x%x%x%x%x%x", "")), guiGetText(source)) then guiGridListSetItemText(grid, guiGridListAddRow(grid), column, getPlayerName(v), false, false) end end end end ) i edit it and the search not work , this is my code : addEventHandler("onClientResourceStart", resourceRoot, function() Window = guiCreateWindow(504, 157, 358, 408, "Players In Server", false) guiWindowSetSizable(Window, false) guiSetAlpha(Window, 1.00) guiSetVisible( Window , false) GridList = guiCreateGridList(18, 82, 322, 306, false, Window) ID = guiGridListAddColumn(GridList, "# ID :", 0.1) Players = guiGridListAddColumn(GridList, "# Players :", 0.-- s8) --> Edit = guiCreateEdit(30, 34, 286, 38, "", false, Window) Search = guiCreateButton(320, 39, 29, 28, "Search", false, Window) guiSetFont(Search, "default-small") for id, v in ipairs(getElementsByType("player")) do local row = guiGridListAddRow(GridList) guiGridListSetItemText ( GridList, row, ID,tonumber(id), false, false ) guiGridListSetItemText ( GridList, row, Players,tostring(getPlayerName(v)), false, false ) end end ) function Default() for id, v in ipairs(getElementsByType("player")) do local row = guiGridListAddRow(GridList) guiGridListSetItemText ( GridList, row, ID,tonumber(id), false, false ) guiGridListSetItemText ( GridList, row, Players,tostring(getPlayerName(v)), false, false ) end end addEventHandler("onClientGUIChanged", root, function() if source == Edit then if ( guiGetText(source) == "") then return Default() end local row = guiGridListAddRow(GridList) guiGridListClear(GridList) for i, v in ipairs(getElementsByType"player") do if string.find(string.lower(string.gsub(getPlayerName(v), "#%x%x%x%x%x%x", "")), guiGetText(source)) then guiGridListSetItemText(GridList, row, Players, getPlayerName(v), false, false) guiGridListSetItemText ( GridList, row, ID,tonumber(i), false, false ) end end end end ) Link to comment
GTX Posted August 3, 2015 Share Posted August 3, 2015 That's much different code than I gave you. guiGridListClear(GridList) for i, v in ipairs(getElementsByType"player") do if string.find(string.lower(string.gsub(getPlayerName(v), "#%x%x%x%x%x%x", "")), guiGetText(source)) then guiGridListSetItemText(GridList, guiGridListAddRow(GridList), 1, tostring(i), false, false) guiGridListSetItemText(GridList, guiGridListAddRow(GridList), 2, getPlayerName(v), false, false) end end Link to comment
#Madara Posted August 3, 2015 Author Share Posted August 3, 2015 That's much different code than I gave you. guiGridListClear(GridList) for i, v in ipairs(getElementsByType"player") do if string.find(string.lower(string.gsub(getPlayerName(v), "#%x%x%x%x%x%x", "")), guiGetText(source)) then guiGridListSetItemText(GridList, guiGridListAddRow(GridList), 1, tostring(i), false, false) guiGridListSetItemText(GridList, guiGridListAddRow(GridList), 2, getPlayerName(v), false, false) end end it's work now , but when the M is capital it's dosen't search and when is m small he search, i want when M is capital or m is small he can search . Link to comment
GTX Posted August 3, 2015 Share Posted August 3, 2015 if string.find(string.lower(string.gsub(getPlayerName(v), "#%x%x%x%x%x%x", "")), string.lower(guiGetText(source))) then 1 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