Error Help


[ERROR] gamemodes/darkrp/gamemode/modules/base/sv_data.lua:315: attempt to call field 'doorIndexToEnt' (a nil value)
1. callback - gamemodes/darkrp/gamemode/modules/base/sv_data.lua:315
2. query - gamemodes/darkrp/gamemode/libraries/database.lua:145
3. setUpNonOwnableDoors - gamemodes/darkrp/gamemode/modules/base/sv_data.lua:311
4. onFinished - gamemodes/darkrp/gamemode/modules/base/sv_data.lua:151
5. commit - gamemodes/darkrp/gamemode/libraries/database.lua:59
6. initDatabase - gamemodes/darkrp/gamemode/modules/base/sv_data.lua:149
7. Call - gamemodes/darkrp/gamemode/modules/base/sv_gamemode_functions.lua:81
8. unknown - gamemodes/darkrp/gamemode/libraries/database.lua:33

Timer Failed! [Simple][@gamemodes/darkrp/gamemode/libraries/database.lua (line 31)]

Any ideas? I think this is causing my doors to not save.

I am certain this is causing door groups to not save.

All you provided was error. No code, no other info.
Are we supposed to magically generate the code for us to check what is wrong with it or something like that?

Saying what happens because of the error is not a help at all (Atleast in this case).
It’s like saying that car doesnt work which isn’t helpful because there can be atleast 5000 reasons why it happens.


/*---------------------------------------------------------
 Doors
 ---------------------------------------------------------*/
function DarkRP.storeDoorData(ent)
	if not ent:CreatedByMap() then return end
	local map = string.lower(game.GetMap())
	local nonOwnable = ent:getKeysNonOwnable()
	local title = ent:getKeysTitle()

	MySQLite.query([[REPLACE INTO darkrp_door VALUES(]]..
		ent:doorIndex() ..[[, ]] ..
		MySQLite.SQLStr(map) .. [[, ]] ..
		(title and MySQLite.SQLStr(title) or "NULL") .. [[, ]] ..
		"NULL" .. [[, ]] ..
		(nonOwnable and 1 or 0) .. [[);]])
end

function setUpNonOwnableDoors()
	MySQLite.query("SELECT idx, title, isLocked, isDisabled FROM darkrp_door WHERE map = " .. MySQLite.SQLStr(string.lower(game.GetMap())) .. ";", function(r)
		if not r then return end

		for _, row in pairs(r) do
			local e = DarkRP.doorIndexToEnt(tonumber(row.idx))
			if IsValid(e) and e:isKeysOwnable() then
				e:setKeysNonOwnable(tobool(row.isDisabled))
				if r.isLocked ~= nil then
					e:Fire((tobool(row.locked) and "" or "un").."lock", "", 0)
				end
				e:setKeysTitle(row.title ~= "NULL" and row.title or nil)
			end
		end
	end)
end

function DarkRP.storeTeamDoorOwnability(ent)
	if not ent:CreatedByMap() then return end
	local map = string.lower(game.GetMap())

	MySQLite.query("DELETE FROM darkrp_jobown WHERE idx = " .. ent:doorIndex() .. " AND map = " .. MySQLite.SQLStr(map) .. ";")
	for k,v in pairs(ent:getKeysDoorTeams() or {}) do
		MySQLite.query("INSERT INTO darkrp_jobown VALUES(" .. ent:doorIndex() .. ", " .. MySQLite.SQLStr(map) .. ", " .. k .. ");")
	end
end

function setUpTeamOwnableDoors()
	MySQLite.query("SELECT idx, job FROM darkrp_jobown WHERE map = " .. MySQLite.SQLStr(string.lower(game.GetMap())) .. ";", function(r)
		if not r then return end

		for _, row in pairs(r) do
			local e = DarkRP.doorIndexToEnt(tonumber(row.idx))
			if not IsValid(e) then continue end

			e:addKeysDoorTeam(tonumber(row.job))
		end
	end)
end

function DarkRP.storeDoorGroup(ent, group)
	if not ent:CreatedByMap() then return end
	local map = MySQLite.SQLStr(string.lower(game.GetMap()))
	local index = ent:doorIndex()

	if group == "" or not group then
		MySQLite.query("DELETE FROM darkrp_doorgroups WHERE map = " .. map .. " AND idx = " .. index .. ";")
		return
	end

	MySQLite.query("REPLACE INTO darkrp_doorgroups VALUES(" .. index .. ", " .. map .. ", " .. MySQLite.SQLStr(group) .. ");");
end

function setUpGroupDoors()
	local map = MySQLite.SQLStr(string.lower(game.GetMap()))
	MySQLite.query("SELECT idx, doorgroup FROM darkrp_doorgroups WHERE map = " .. map, function(data)
		if not data then return end

		for _, row in pairs(data) do
			local ent = DarkRP.doorIndexToEnt(tonumber(row.idx))

			if not IsValid(ent) or not ent:isKeysOwnable() then
				continue
			end

			ent:setDoorGroup(row.doorgroup)
		end
	end)
end

I hope this is the right piece of code.

By the way I have not changed anything? :confused:

If you’ve not changed anything, then have you tried updating?

Tried updating each individual file, that didn’t work and I updated DarkRP and that didn’t work.