Jump to content

SearchBar Problem


isa_Khamdan

Recommended Posts

Posted

Hello ,

I made a search bar for my gridlist and I used this code from the forums to make it work but it doesn't and there is no errors at all so can anyone tell me how can I fix it?

clientsideResourceStart = function() 
  if column then 
    for id,playeritem in ipairs(getElementsByType("player")) do 
      local row = guiGridListAddRow(GUIEditor_Grid[1]) 
      guiGridListSetItemText(GUIEditor_Grid[1], row, column, getPlayerName(playeritem), false, false) 
    end 
  end 
end 
addEventHandler ( "onClientResourceStart", resourceRoot, clientsideResourceStart ) 
  
  
function search() 
  
    guiGridListClear(GUIEditor_Grid[1]) 
  
    local text = guiGetText(SearchBar) 
  
    if (text == "") then 
  
        for index, player in ipairs(getElementsByType("player")) do 
  
            if (player ~= localPlayer) then 
  
                local row = guiGridListAddRow(GUIEditor_Grid[1]) 
  
                guiGridListSetItemText(GUIEditor_Grid[1], 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(GUIEditor_Grid[1]) 
  
                    guiGridListSetItemText(GUIEditor_Grid[1], row, 1, getPlayerName(player), false, false) 
  
                end 
  
            end 
  
        end 
  
    end 
  
end 
  
addEventHandler("onClientGUIChanged", SearchBar, search) 

350x20_FFFFFF_FFFFFF_000000_000000.png
Posted

Are you sure that there are no errors? can you post the whole code?

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

I tested it and it works, you're testing it with someone else, right? because the script is skipping the local player, so it won't show up on list.

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
I tested it and it works, you're testing it with someone else, right? because the script is skipping the local player, so it won't show up on list.

Edit : I will test it now on my server.

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