Seif Posted July 21, 2010 Share Posted July 21, 2010 Since setElementData seems to be slow, I said I'd use tables instead. However I don't know how I would make a multi-dimensional table. If I do: sourceTable = {}{} it will give me an error, saying I must only have 1 {}. This is made serverside so I want to have a slot for the source and one for the variables I want to store in. Any possibility? Link to comment
Seif Posted July 21, 2010 Author Share Posted July 21, 2010 ever though about sql? What does SQL have to do with this? Link to comment
DiSaMe Posted July 21, 2010 Share Posted July 21, 2010 It must be sourceTable = {{}} instead of sourceTable = {}{}. However, only sourceTable[1] will be the table, other values will be nil as they aren't set to any value. So you need to set them yourself when the source is created. If the source is player, it can be like this: sourceTable = {} function playerJoined() sourceTable[source] = {} end addEventHandler("onPlayerJoin",getRootElement(),playerJoined) function playerLeft() sourceTable[source] = nil end addEventHandler("onPlayerQuit",getRootElement(),playerLeft) Link to comment
Seif Posted July 21, 2010 Author Share Posted July 21, 2010 I tried that but it gives me this error: "attempt to index field "?" (a nil value)" when I try this: sourceTable[source][sqlid] = row[1] Link to comment
DiSaMe Posted July 21, 2010 Share Posted July 21, 2010 It means that source or SQLid has no value. Link to comment
Seif Posted July 21, 2010 Author Share Posted July 21, 2010 Then how am I suppose to set it a value if it keeps giving me that error? Link to comment
MaddDogg Posted July 21, 2010 Share Posted July 21, 2010 You have to do this first: sourceTable[source] = {} With this you create a new sub-table at index location [source]. Link to comment
Seif Posted July 21, 2010 Author Share Posted July 21, 2010 I did do it when the player connects. Link to comment
Jason_Gregory Posted July 22, 2010 Share Posted July 22, 2010 Then show us your function... Link to comment
50p Posted July 22, 2010 Share Posted July 22, 2010 If in doubt: http://www.lua.org/pil/11.2.html 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