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

Action Desert Quest Switch

chojrak

Banned User
Joined
Oct 25, 2008
Messages
5,832
Solutions
2
Reaction score
160
I don't know why, but when i saw this thread: http://otland.net/f81/might-good-someone-desert-quest-easy-configure-48895/. I decide to write my own, maybe i don't like Ezzam's code (no loops etc.) xD

Code is untested but shuold work:
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	-- Positions/ID's/Vocations order: paladin, sorcerer, knight, druid.
	local positions = {
		players = {
			{x = 100, y = 100, z = 7, stackpos = 253},
			{x = 100, y = 100, z = 7, stackpos = 253},
			{x = 100, y = 100, z = 7, stackpos = 253},
			{x = 100, y = 100, z = 7, stackpos = 253}
		}
		items = {
			{x = 100, y = 100, z = 7, stackpos = 2},
			{x = 100, y = 100, z = 7, stackpos = 2},
			{x = 100, y = 100, z = 7, stackpos = 2},
			{x = 100, y = 100, z = 7, stackpos = 2}
		}
		new = {
			{x = 100, y = 100, z = 7},
			{x = 100, y = 100, z = 7},
			{x = 100, y = 100, z = 7},
			{x = 100, y = 100, z = 7}
		}
	}

	local vocations = {3, 1, 4, 2}
	local items = {2455, 2376, 2674, 2175}

	-- don't touch below.
	local check = {
		players = true,
		vocations = true,
		items = true
	}

	if (item.itemid == 1945) then
		for i = 1, 4 do
			if (not isPlayer(getThingFromPos(positions.players[i]).uid)) then
				doPlayerSendCancel(cid, "You need 4 players.")
				check.players = false
				break
			end
		end
		for i = 1, 4 do
			if (getPlayerVocation(getThingFromPos(positions.players[i]).uid) ~= vocations[i]) then
				doPlayerSendCancel(cid, "Wrong vocations.")
				check.vocations = false
				break
			end
		end
		for i = 1, 4 do
			if (getThingFromPos(positions.items[i]).itemid ~= items[i]) then
				doPlayerSendCancel(cid, "Wrong items.")
				check.items = false
				break
			end
		end
		if (check.players and check.vocations and check.items) then
			for i = 1, 4 do
				doTeleportThing(getThingFromPos(positions.players[i]).uid, positions.new[i])
				doSendMagicEffect(positions.players[i], CONST_ME_POFF)
				doSendMagicEffect(positions.new[i], CONST_ME_TELEPORT)
				doTransformItem(item.uid, item.itemid + 1)
			end
		end
	elseif (item.itemid == 1946) then
		doTransformItem(item.uid, item.itemid - 1)
	end

	return TRUE
end
 
Last edited:
You have to test it and pos result here, I will fix it ;p
 
Code:
for xx = y, zzz do
xd()
end

Code:
while xxxx do
xd()
end

Code:
repeat
xd()
until xxx

Loops :d
 
Lol, non-loop version will give lot of useless code. >.<
 
Not tested.
Code:
-- Positions/IDs/Vocations order: paladin, sorcerer, knight, druid.
local positions = {
	players = {
		{x = 100, y = 100, z = 7},
		{x = 100, y = 100, z = 7},
		{x = 100, y = 100, z = 7},
		{x = 100, y = 100, z = 7}
	}[COLOR="Red"],[/COLOR]
	items = {
		{x = 100, y = 100, z = 7},
		{x = 100, y = 100, z = 7},
		{x = 100, y = 100, z = 7},
		{x = 100, y = 100, z = 7}
	}[COLOR="red"],[/COLOR]
	new = {
		{x = 100, y = 100, z = 7},
		{x = 100, y = 100, z = 7},
		{x = 100, y = 100, z = 7},
		{x = 100, y = 100, z = 7}
	}
}

local vocations = {3, 1, 4, 2}
local items = {2455, 2376, 2674, 2175}

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if(item.itemid == 1945) then
		for i = 1, 4 do
			local failed = true
			if (not isPlayer(getThingFromPos(positions.players[i]).uid)) then
				doPlayerSendCancel(cid, "You need 4 players.")
				break
			elseif (getPlayerVocation(getThingFromPos(positions.players[i]).uid) ~= vocations[i]) then
				doPlayerSendCancel(cid, "Wrong vocations.")
				break
			elseif (getTileItemById(positions.items[i], items[i]).uid == 0) then
				doPlayerSendCancel(cid, "Wrong items.")
				break
			else
				failed = false
			end
		end
		if(not failed) then
			for i = 1, 4 do
				[COLOR="Red"][B]doRemoveItem(getTileItemById(positions.items[i], items[i]).uid)[/B][/COLOR]
				doTeleportThing(getTopCreature(positions.players[i]).uid, positions.new[i])
				doSendMagicEffect(positions.players[i], CONST_ME_POFF)
				doSendMagicEffect(positions.new[i], CONST_ME_TELEPORT)
				doTransformItem(item.uid, item.itemid + 1)
			end
		end
	elseif(item.itemid == 1946) then
		doTransformItem(item.uid, item.itemid - 1)
	end
	return TRUE
end
 
Last edited:
Not tested.
Code:
-- Positions/IDs/Vocations order: paladin, sorcerer, knight, druid.
local positions = {
	players = {
		{x = 100, y = 100, z = 7},
		{x = 100, y = 100, z = 7},
		{x = 100, y = 100, z = 7},
		{x = 100, y = 100, z = 7}
	},
	items = {
		{x = 100, y = 100, z = 7},
		{x = 100, y = 100, z = 7},
		{x = 100, y = 100, z = 7},
		{x = 100, y = 100, z = 7}
	},
	new = {
		{x = 100, y = 100, z = 7},
		{x = 100, y = 100, z = 7},
		{x = 100, y = 100, z = 7},
		{x = 100, y = 100, z = 7}
	}
}

local vocations = {3, 1, 4, 2}
local items = {2455, 2376, 2674, 2175}

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if(item.itemid == 1945) then
		for i = 1, 4 do
			local failed = true
			if (not isPlayer(getThingFromPos(positions.players[i]).uid)) then
				doPlayerSendCancel(cid, "You need 4 players.")
				break
			elseif (getPlayerVocation(getThingFromPos(positions.players[i]).uid) ~= vocations[i]) then
				doPlayerSendCancel(cid, "Wrong vocations.")
				break
			elseif (getTileItemById(positions.items[i], items[i]).uid == 0) then
				doPlayerSendCancel(cid, "Wrong items.")
				break
			else
				failed = false
			end
		end
		if(not failed) then
			for i = 1, 4 do
				doTeleportThing(getTopCreature(positions.players[i]).uid, positions.new[i])
				doSendMagicEffect(positions.players[i], CONST_ME_POFF)
				doSendMagicEffect(positions.new[i], CONST_ME_TELEPORT)
				doTransformItem(item.uid, item.itemid + 1)
			end
		end
	elseif(item.itemid == 1946) then
		doTransformItem(item.uid, item.itemid - 1)
	end
	return TRUE
end

I will test it now on 0.3.5 pl1

EDIT: No errors while reloading, gonna test the quest now after restart.
 
Back
Top