Jump to content

Double arrays in a table


Seif

Recommended Posts

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

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

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