Jump to content

Problem with table


Recommended Posts

Why the table disappears after the cycle? Never this was not.

shel = {}
local shelPlaces = {
	[1] = {
		[1] = {x=0,y=0,z=0},
		[2] = {x=0,y=0,z=0},
		[3] = {x=0,y=0,z=0},
	},
}

function createShelters(gameId, players)
	local gameId = tonumber(gameId)
	shel[gameId] = {}
	for i=1,#shelPlaces do
		--outputDebugString("table "..shel[gameId])
		shel[gameId][i] = {
			["places"] = {
				[1] = {x=shelPlaces[i][1].x,y=shelPlaces[i][1].y,z=shelPlaces[i][1].z,["object"]="craftTable"},
			},
		}
		outputChatBox(shel[1][1]["places"][1]["object"]) -- WORKING
		for pI=2,#shelPlaces[i] do
			shel[gameId][i]["places"] = {
				[pI] = {x=shelPlaces[i][pI].x,y=shelPlaces[i][pI].y,z=shelPlaces[i][pI].z,["object"]=false},
			}
		end
	end
	createCraftsTable(gameId)
end
addEventHandler("onGameStarted", root, createShelters)

function createCraftsTable()
	--for i=1,10 do
		--for name,object in pairs(shel[gameId][i])
end

function tempSpawn()
	spawnPlayer(source, 0,0,5)
	setCameraTarget(source, source)
end
addEventHandler("onPlayerLogin", root, tempSpawn)

function startTest(pSource, command, gameId)
	triggerEvent("onGameStarted", root, gameId)
end
addCommandHandler("gameTest", startTest)

function getGameInfo()
	outputChatBox(shel[1][1]["places"][1]["object"]) -- NOT WORKING
end
addCommandHandler("gInfo", getGameInfo)

 

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