[Lua] How to find something in an array?

So, I am building a little RP framework for a little project and for fun. I needed to look for a list of players to see if the player’s name is there before replacing things in the MySQL database.

So I used this line :

local players = MySQL.Sync.fetchAll('SELECT ign FROM storage')

To store them all in an array. Now I need to see if the player’s name is included in there. How would I be able to achieve this?

1 Like
for i=1, #players, 1 do
	    if players[i].Name == "Cheleber" then 
            end
end

cheers pal, appreciate it

Idk if it will work for your specific case, cause it depends on your db structure. But try it.

Nah, it worked. Thanks bro.

Orrr he could use the ipairs function because that’s what it was made for.