I am making a menu in which you can read a text file and it will make a vehicle menu. All is well, until I realized that the menu wouldn’t load. I ended up finding out that the menu wouldn’t load because of my line below
local open = io.open
Does FiveM not allow io.open? I know another way of loading this, but I just want to know if using io.open to read a text file was not able to load in FiveM, or if there was another line of code I could use to prevent this
Alright, so I went ahead and did what you recommended and I put down this
local file = LoadResourceFile("cars", "cars.txt")
I have got the menu to fully load now, which is great, but I have one question.
I am using the text file to read what is on the inside, so I went ahead and made a for loop
for line in io.lines(file) do
//...
end
Problem is, using io.lines(file) doesn’t work, so is there any way to use ‘LoadResourceFile’ to read the text on the inside?
It gives you the file contents as a string. Including newlines (\r and/or \n) so split that string by \r\n or \n and loop through the table that’s created.