• 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!

Lua What is the problem in this script? [ HELP PLZ ]

viniciusturko

New Member
Joined
Jun 23, 2009
Messages
94
Reaction score
2
Location
Brasil
The script :

function onStepIn(cid, item, position, fromPosition)
for i, creature in pairs(getSpectators({x = 1390, y = 1042, z = 7}, 1, 1, false)) do
if isPlayer(creature) then
doTeleportThing(cid, {x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y + 1, z = getCreaturePosition(cid).z})
doSendMagicEffect(getCreaturePosition(cid), 2)
doPlayerSendTextMessage(cid, 19, "You cannot enter. There someone doing the quest now. Wait a minute.")
return 1
elseif isMonster(creature) then
doRemoveCreature(creature)
end
end
return true
end

The error :

mww104.jpg


Where is the error?
 
The problem is "bad argument to #1 to 'pairs' (table expected, got nil)"

;)!

LUA:
function onStepIn(cid, item, position, fromPosition)

	local list = getSpectators({x = 1390, y = 1042, z = 7}, 1, 1, false) or {}
	if #list > 0 then
		for _, creature in pairs(list) do
			if isPlayer(creature) then
				doTeleportThing(cid, {x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y + 1, z = getCreaturePosition(cid).z})
				doSendMagicEffect(getCreaturePosition(cid), 2)
				doPlayerSendTextMessage(cid, 19, "You cannot enter. There someone doing the quest now. Wait a minute.")
				return true
			elseif isMonster(creature) then
				doRemoveCreature(creature)
			end
		end
	end
	return true
end
 
LUA:
function onStepIn(cid, item, pos, fromPos)
	if isPlayer(cid) then
		local t = {}
		for _, v in ipairs(getSpectators({x=1390, y=1042, z=7}, 1, 1) or {}) do
			if isPlayer(v) then
				pos.y = pos.y + 1
				doTeleportThing(cid, pos)
				doSendMagicEffect(pos, CONST_ME_POFF)
				doPlayerSendTextMessage(cid, MESSAGE_EVENT_ORANGE, 'You cannot enter. There\'s someone doing the quest now. Wait a minute.')
				return
			elseif isMonster(v) then
				table.insert(t, v)
			end
		end
		for i = 1, #t do
			doRemoveCreature(t[i])
		end
	end
end
 
Back
Top