Jacobob14 Posted August 27, 2015 Share Posted August 27, 2015 I do not understand what the problem when i insert data in Table all is well but when I try recover of the table data not work for i,top in ipairs(topslist) do outputChatBox(topslist[top].Score) end addEventHandler("onElementDataChange",root, function (data) if ( data == "money" ) and getElementType(source) == "player" then local money = getElementData(source,"money") topslist[source] = {Score = money, Name = getPlayerName(source)} end end ) Link to comment
TAPL Posted August 27, 2015 Share Posted August 27, 2015 for i,top in ipairs(topslist) do outputChatBox(top.Score) end Link to comment
Noki Posted August 28, 2015 Share Posted August 28, 2015 table = {} table[1] = {"foo", "bar"} for i, v in ipairs(table) do for _, y in pairs(v) do print(i.." "..y) end end --[[ i would be the index v would be a table v[1] would be "foo" v[2] would be "bar" y would be "foo"\n "bar" --]] table = {} table[1] = {foo = "xyz", bar = "abc"} for i, v in ipairs(table) do print(i.." "..v.foo.." "..v.bar) end --[[ i would be the index v would be a table v.foo would be "xyz" v.bar would be "abc" --]] Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now