Jump to content

Making a GUI Searchbar


Khalil

Recommended Posts

Posted

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.

Level 3 admin on RRC:RPG.

560x95.png

Posted

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

Level 3 admin on RRC:RPG.

560x95.png

Posted

Eh... why are you getting the selected item?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

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) 

Level 3 admin on RRC:RPG.

560x95.png

Posted

You have to first clear the gridlist, then when it finds a match, add a new row.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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

CiTLh.png

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...