• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

bad argument #1 to 'pairs' (table expected, got nil)

Ub Kenobi

Member
Joined
Apr 10, 2009
Messages
144
Reaction score
8
Location
Sweden
Code:
[3/1/2013 22:23:39] [Error - Action Interface] 
[3/1/2013 22:23:39] data/actions/scripts/theend/quests/hermesquestsystem.lua:onUse
[3/1/2013 22:23:39] Description: 
[3/1/2013 22:23:39] data/actions/scripts/theend/quests/hermesquestsystem.lua:24: bad argument #1 to 'pairs' (table expected, got nil)
[3/1/2013 22:23:39] stack traceback:
[3/1/2013 22:23:39] 	[C]: in function 'pairs'
[3/1/2013 22:23:39] 	data/actions/scripts/theend/quests/hermesquestsystem.lua:24: in function <data/actions/scripts/theend/quests/hermesquestsystem.lua:1>

LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if(getPlayerCustomFlagValue(cid, PlayerCustomFlag_GamemasterPrivileges) == TRUE) then
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You are not allowed to get rewards from quests.")
		return TRUE
	end
	if isInArray({1990, 2400, 2431, 2494}, item.uid) == TRUE then
		if getPlayerStorageValue(cid, 30015) < 0 then
			if getPlayerFreeCap(cid) >= getItemWeightById(item.uid, 1, FALSE) then
				if item.uid == 1990 then
					local container = doPlayerAddItem(cid, 1987, 1)
					doAddContainerItem(container, 2326, 1)
				else
					doPlayerAddItem(cid, item.uid, 1)
				end
				doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'You have found a ' .. getItemNameById(item.uid) .. '.')
				setPlayerStorageValue(cid, 30015, 1)
			else
				doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'You have found a ' .. getItemNameById(item.uid) .. ' weighing ' .. getItemWeightById(item.uid, 1, FALSE) .. ' oz it\'s too heavy.')
			end
		else
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "It is empty.")
		end
	end
	for _, questTable in pairs(questList) do
		if(isInArray({questTable.uniqueId}, item.uid) == TRUE) then
			if(getPlayerStorageValue(cid, questTable.uniqueId) < 0) then
				if(getPlayerLevel(cid) < questTable.neededLevel) then
					doPlayerSendCancel(cid, "You need to have " .. questTable.neededLevel .. " level to open this chest")
					return TRUE
				end
				local itemWeight = getItemWeightById(questTable.itemReward, 1, FALSE)
				if(getPlayerFreeCap(cid) < itemWeight) then
					doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'You have found a ' .. getItemNameById(questTable.itemReward) .. ' weighing ' .. itemWeight .. ' oz it\'s too heavy.')
					return TRUE
				end
				if(questTable.experience > 0 and questTable.itemReward > 0) then
					doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "You have found " .. getItemArticleById(questTable.itemReward) .. " " .. getItemNameById(questTable.itemReward) .. " and gained " .. questTable.experience .. " experience points.")
					doPlayerAddItem(cid, questTable.itemReward, 1)
					doPlayerAddExp(cid, questTable.experience)
					doSendAnimatedText(getPlayerPosition(cid), '' .. questTable.experience .. '', 215)
				elseif(questTable.experience == 0) then
					doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "You have found " .. getItemArticleById(questTable.itemReward) .. " " .. getItemNameById(questTable.itemReward) .. ".")
					doPlayerAddItem(cid, questTable.itemReward, 1)
				elseif(questTable.itemReward == 0) then
					doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "You have gained " .. questTable.experience .. " experience points.")
					doPlayerAddExp(cid, questTable.experience)
					doSendAnimatedText(getPlayerPosition(cid), '' .. questTable.experience .. '', 215)
				end
				setPlayerStorageValue(cid, questTable.uniqueId, 1)
				return TRUE
			else
				doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "It is empty.")
			end
		else
			return FALSE
		end
	end
	return TRUE
end

I use TFS 0.4.
 
Where do I put that? It seems like the whole quest system on my map is built with this script. All chest got an uid and when someone click on them I got got the console error. I would like to fix it in an easy way. I hope I don't have to replace this script with something else.
 
Well, I don't know, it depends where you got your script from.
questList is just simply undefined, based on what you have shown me so far.
 
Back
Top