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

Script doesn't work - please see and help!

harry127

Member
Joined
Jul 19, 2009
Messages
435
Reaction score
5
Location
Poland
Hello.
This script doesn't work - it have to teleport all creatures in range, but it doesn't teleport first creature on the left...

Code:
function getCreaturesInRange(fromPos, toPos, player)
	local array = {}
	local mpos = {}
	for x = fromPos.x, toPos.x do
		for y = fromPos.y, toPos.y do
			mpos = {x = x, y = y, z = fromPos.z, stackpos = 253}
			if getThingFromPos(mpos) then
				if isCreature(getThingFromPos(mpos).uid) and ((not player) or isPlayer(getThingFromPos(mpos).uid)) then
					table.insert(array, getThingFromPos(mpos))
				end
			end
		end
	end
	return array
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
	local toPositions = {
		pos(5376, 3670, 6),
		pos(5376, 3869, 6),
		pos(5375, 3869, 6),
		pos(5377, 3868, 6),
		pos(5376, 3868, 6),
		pos(5375, 3868, 6)
	}
	local players = getCreaturesInRange(pos(5374, 3877, 13), pos(5380, 3877, 13), false)
	local switch = {[1945] = 1946, [1946] = 1945}
	if #players < 3 or getDistanceBetween(getCreaturePosition(cid), pos(fromPosition.x - 1, fromPosition.y, fromPosition.z)) > 0 then
		doTransformItem(item.uid, switch[item.itemid])
		doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
		return false
	end
	for i = 1, #players do
		doTeleportThing(players[i], toPositions[i])
	end
end
 
Code:
for _, monster in ipairs(getCreaturesInRange({x = 5374, y = 3877, z = 13}, {x = 5380, y = 3877, z = 13}, false)) do
	doRemoveCreature(monster)
end
 
Code:
for _, monster in ipairs(getCreaturesInRange({x = 5374, y = 3877, z = 13}, {x = 5380, y = 3877, z = 13}, false)) do
	doTeleportThing(monster, {x = , y= , z =})
end

Ok?
 
Back
Top