Jump to content

Help Table


Jacobob14

Recommended Posts

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

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