I have a table in shared.lua
As I know, you can use it at client and server side right?
I can print it from shared.lua but I can't from cl_init.lua
Table:
[LUA]
Resources.Info = {}
Resources.Info = util.KeyValuesToTable(file.Read("DarkAges/Save/info.txt") )
PrintTable(Resources.Info)
[/LUA]
[editline]31st October 2010[/editline]
Error message:
[darkages\gamemode\mainmenu.lua:105] attempt to index field '?' (a nil value)
[editline]31st October 2010[/editline]
Line 105
print(Resources.Info[Item].name)
[editline]31st October 2010[/editline]
Item is good
FYI, you don't need the util. bit.
It seems that the Info table is empty. The file you are trying to read probably doesn't exist client side.
Yeah, it is true, but it is loaded in shared.lua
[QUOTE=runamagic;25760642]Yeah, it is true, but it is loaded in shared.lua[/QUOTE]
There's no such thing as shared tables. When you create something in shared.lua, you actually create two instances of it - one on the server and one on the client. No connection is made between them.
But, for example, I have an other table in shared.lua
[LUA]
Resources.fishing[1] = "sardine"
Resources.fishing[2] = "trout"
Resources.fishing[3] = "pike"
Resources.fishing[4] = "salmon"
Resources.fishing[5] = "lobster"
[/LUA]
and I can use it on client side
Okey, thanks
[editline]31st October 2010[/editline]
New problem :S
I have send it by datastream.
Got this:
[@lua\includes\extensions\table.lua:103] bad argument #1 to 'pairs' (table expected, got nil)
When I print the table, I see everything
Code?
[LUA]
Data = {}
Data.Inventory = ply.Inventory
Data.Resources = Resources.Info
datastream.StreamToClients(ply, "cucc" ,Data )
[/LUA]
[LUA]
function Inventory_Setup ( cucc, id, inv, data )
Resources = {}
Inventory = {}
Resources = data.Resources
Inventory = data.Inventory
end
[/LUA]
Problem is here:
for k,v in pairs(Inventory) do
[editline]31st October 2010[/editline]
Any idea?
Please HEEEEEEELP
A qualified guess says Inventory is nil (ie ply.Inventory is nil)
Did you even hook that datastream? Because you did not include that in your pasted code.
It isn't because I can print the data table
And yeah, I have hooked it
datastream.Hook("cucc", Inventory_Setup)
Sorry, you need to Log In to post a reply to this thread.