Jump to content

How i make search in gridlist ?


#Madara

Recommended Posts

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 
) 

  • Thanks 1
Link to comment
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

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

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