Jump to content

Making a GUI Searchbar


Khalil

Recommended Posts

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)?

Link to comment

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) 

Link to comment
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) 

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...