Seif Posted July 21, 2010 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?
Seif Posted July 21, 2010 Author Posted July 21, 2010 ever though about sql? What does SQL have to do with this?
DiSaMe Posted July 21, 2010 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)
Seif Posted July 21, 2010 Author 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]
Seif Posted July 21, 2010 Author Posted July 21, 2010 Then how am I suppose to set it a value if it keeps giving me that error?
MaddDogg Posted July 21, 2010 Posted July 21, 2010 You have to do this first: sourceTable[source] = {} With this you create a new sub-table at index location [source].
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