How the hell?

Do anybody know how can this happen?

My Code :



Result :

				wood	=	0
				iron	=	0
				stone	=	0
				food	=	10
		owner	=	2760387851
				wood	=	10
				iron	=	0
				stone	=	0
				food	=	0
[@garrysmod\lua\includes\util.lua:35] bad argument #1 to 'pairs' (table expected, got nil)

What do you mean how the hell can it happen?
“id” is a pretty large number and you are trying to feed it into the key of the table to print.
If your table is THAT large, there is a problem.

In essence what you are trying to do is PrintTable(market[610126042])
For starters, you aren’t any data into market[id]
Second, for the above reason, market[id] also isn’t a table, so PrintTable will error if you try to use them in conjunction.

but it is, above the error u can see


[editline]30th May 2011[/editline]

it is only a random generated number

Make sure that the key in the table and id are of the same type, e.g. both a string or both a number.

No, where it says
That’s the table market itself, not market[id]

The table market appears to be keyed at the same number, but the sub item, id, is not a table, therefor you cannot use table functions (such as PrintTable) on it.

But it is a table

No. It’s not.
MARKET is a table.
Remove the line that says PrintTable(market[id]) and replace it with print(type(market[id])) to see for yourself.
Just because market is indexed at the same number as ID doesn’t make market[id] a table.

Sometimes it works and sometimes it doesn’t :SSSS

[editline]30th May 2011[/editline]

[editline]30th May 2011[/editline]

Check that out

check if the key/id is a string or a number

whoops, didn’t see overv’s post lol.