Khalil Posted September 20, 2013 Posted September 20, 2013 How do I make it like lil_Toady's admin panel? I made a gridlist, got all the server players in there, and added an editbox.
Castillo Posted September 20, 2013 Posted September 20, 2013 Use the event: onClientGUIChanged then, loop all the items of the grid list and see if any has part of the string entered on the edit box ( guiGetText ).
Khalil Posted September 20, 2013 Author Posted September 20, 2013 see if any has part of the string entered on the edit box ( guiGetText ). How exactly do I do that?
Khalil Posted September 20, 2013 Author Posted September 20, 2013 Ok so, I have this: function search() for index, player in ipairs ( getElementsByType ( 'player' ) ) do if ( player ~= localPlayer ) then local item = guiGridListGetSelectedItem(gridList) local player = guiGridListGetItemText(gridList,item,0) local search = guiGetText(searchBar) string.match(player,search) end end end addEventHandler("onClientGUIChanged",searchBar,search) How do I remove all the other rows and just have the matched player(s)?
Castillo Posted September 20, 2013 Posted September 20, 2013 Eh... why are you getting the selected item?
Khalil Posted September 20, 2013 Author Posted September 20, 2013 oh lol that was a mistake.. so I have this now: function search() for index, player in ipairs ( getElementsByType ( 'player' ) ) do if ( player ~= localPlayer ) then local search = guiGetText(searchBar) string.match(index,search) end end end addEventHandler("onClientGUIChanged",searchBar,search)
Castillo Posted September 20, 2013 Posted September 20, 2013 You have to first clear the gridlist, then when it finds a match, add a new row.
TAPL Posted September 20, 2013 Posted September 20, 2013 function search() guiGridListClear(gridList) local text = guiGetText(searchBar) if (text == "") then for index, player in ipairs(getElementsByType("player")) do if (player ~= localPlayer) then local row = guiGridListAddRow(gridList) guiGridListSetItemText(gridList, row, 1, getPlayerName(player), false, false) end end else for index, player in ipairs(getElementsByType("player")) do if (player ~= localPlayer) then if string.find (string.upper(getPlayerName(player)), string.upper(text), 1, true) then local row = guiGridListAddRow(gridList) guiGridListSetItemText(gridList, row, 1, getPlayerName(player), false, false) end end end end end addEventHandler("onClientGUIChanged", searchBar, search)
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