Controlled Posted June 30, 2014 Share Posted June 30, 2014 So I've been trying to fix this for awhile now. I have 4 Search Boxes in my GUI, and the player can type into them, then once he hits the search button it will check the table for anything that matches all those statements. I got it to KINDA work, it checks them and shows the right results if you put only 1 thing in 1 of the search boxes. But if I put more then 1 search term, it includes those and doesnt check the first. I know it sounds confusing so heres the code: guiGridListClear ( GUIEditor.gridlist[1] ) for key, value in pairs(results) do if ((tostring(value[7]):lower():find(guiGetText(GUIEditor.edit[1]):lower()) and guiGetText(GUIEditor.edit[1])~="") or (tostring(value[3]):lower():find(guiGetText(GUIEditor.edit[2]):lower()) and guiGetText(GUIEditor.edit[2])~="") or (tostring(value[2]):lower():find(guiGetText(GUIEditor.edit[4]):lower()) and guiGetText(GUIEditor.edit[4])~="") or (tostring(value[5]):lower():find(guiGetText(GUIEditor.edit[3]):lower()) and guiGetText(GUIEditor.edit[3])~="") ) then local row = guiGridListAddRow( GUIEditor.gridlist[1] ) guiGridListSetItemText( GUIEditor.gridlist[1], row, GUIEditor.Column[1], tostring( value[1] ), false, true ) guiGridListSetItemText( GUIEditor.gridlist[1], row, GUIEditor.Column[2], tostring( value[2] ), false, false ) guiGridListSetItemText( GUIEditor.gridlist[1], row, GUIEditor.Column[3], tostring( value[3] ), false, false ) guiGridListSetItemText( GUIEditor.gridlist[1], row, GUIEditor.Column[4], tostring( value[4] ), false, false ) guiGridListSetItemText( GUIEditor.gridlist[1], row, GUIEditor.Column[5], tostring( value[5] ), false, false ) end end So that gets triggered when you hit search. But if in GUIEditor.edit[1] I type the username "Controlled" then in GUIEditor.edit[2] I type "Daniel" It won't search for the two BOTH being in the same row of the table. It will show lists of Daniel and Lists of Controlled. Even if one another isn't on the same row. I'm trying to be as clear as possible, please if you don't understand ask questions so I can try to explain more. Link to comment
Controlled Posted June 30, 2014 Author Share Posted June 30, 2014 Its just the "If" statement that needs work, because I don't know how to get it to ignore anything that has no input "" and to search everything that does have a input. Link to comment
Controlled Posted July 2, 2014 Author Share Posted July 2, 2014 i guess last time im going to try to bump this Link to comment
xXMADEXx Posted July 2, 2014 Share Posted July 2, 2014 Try using this, and if it doesn't work then if there's no debug errors then please PM the whole script, otherwise post the errors. (I think I got all of the values correct but I'm not 100% sure) guiGridListClear ( GUIEditor.gridlist[1] ) for key, value in pairs(results) do local v1 = guiGetText(GUIEditor.edit[1]):lower() local v2 = guiGetText(GUIEditor.edit[2]):lower() local v3 = guiGetText(GUIEditor.edit[3]):lower() local v4 = guiGetText(GUIEditor.edit[4]):lower() local x1 = tostring(value[7]):lower() local x2 = tostring(value[3]):lower() local x3 = tostring(value[2]):lower() local x4 = tostring(value[5]):lower() if ( isStr ( x1, v1 ) or isStr ( x2, v2 ) or isStr ( x3, v3 ) or isStr ( x4, v4 ) ) then local row = guiGridListAddRow( GUIEditor.gridlist[1] ) guiGridListSetItemText( GUIEditor.gridlist[1], row, GUIEditor.Column[1], tostring( value[1] ), false, true ) guiGridListSetItemText( GUIEditor.gridlist[1], row, GUIEditor.Column[2], tostring( value[2] ), false, false ) guiGridListSetItemText( GUIEditor.gridlist[1], row, GUIEditor.Column[3], tostring( value[3] ), false, false ) guiGridListSetItemText( GUIEditor.gridlist[1], row, GUIEditor.Column[4], tostring( value[4] ), false, false ) guiGridListSetItemText( GUIEditor.gridlist[1], row, GUIEditor.Column[5], tostring( value[5] ), false, false ) end end function isStr ( s1, s2 ) if ( s1 == "" or s2 == "" ) then return false end if ( string.find ( s1, s2 ) ) then return true end return false 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