function onUse(cid, item, frompos, item2, topos)
-- Item ID and Uniqueid --
switchUniqueID = 5200
switchID = 1945
switch2ID = 1946
swordID = 2376
crossbowID = 2455
appleID = 2674
spellbookID = 2175
--------------------------
-- Level to do the quest --
questlevel = 40
---------------------------
----------------------------------------------
piece1pos = {x=1256, y=590, z=8, stackpos=1} -- Where the first piece will be placed
getpiece1 = getThingfromPos(piece1pos)
--
piece2pos = {x=1262, y=585, z=8, stackpos=1} -- Where the second piece will be placed
getpiece2 = getThingfromPos(piece2pos)
--
piece3pos = {x=1256, y=579, z=8, stackpos=1} -- Where the third piece will be placed
getpiece3 = getThingfromPos(piece3pos)
--
piece4pos = {x=1250, y=585, z=8, stackpos=1} -- Where the fourth piece will be placed
getpiece4 = getThingfromPos(piece4pos)
----------------------------------------------
-------------------------------------------------
player1pos = {x=1256, y=589, z=8, stackpos=255} -- Where player1 will stand before pressing lever
player1 = getThingfromPos(player1pos)
--
player2pos = {x=1260, y=585, z=8, stackpos=255} -- Where player2 will stand before pressing lever
player2 = getThingfromPos(player2pos)
--
player3pos = {x=1256, y=581, z=8, stackpos=255} -- Where player3 will stand before pressing lever
player3 = getThingfromPos(player3pos)
--
player4pos = {x=1252, y=585, z=8, stackpos=255} -- Where player4 will stand before pressing lever
player4 = getThingfromPos(player4pos)
-------------------------------------------------
---------------
if player1.itemid > 0 and --
player2.itemid > 0 and --
player3.itemid > 0 and --
player4.itemid > 0 then --
-----------------------------------------------
paladin = getThingfromPos(player1pos) -- change knight and pally etc untill the right positions are linked to the right vocations
knight = getThingfromPos(player2pos)
druid = getThingfromPos(player3pos)
sorcerer = getThingfromPos(player4pos)
paladinvoc = getPlayerVocation(paladin.uid) -- The vocation of paladin pos
knightvoc = getPlayerVocation(knight.uid) -- The vocation of knight pos
druidvoc = getPlayerVocation(druid.uid) -- The vocation of the druid pos
sorcerervoc = getPlayerVocation(sorcerer.uid) -- The vocation of the sorc pos
-----------------------------------------------
------------------------------------
nplayer1pos = {x=1257, y=560, z=8} -- The new position of player1
nplayer2pos = {x=1257, y=559, z=8} -- The new position of player2
nplayer3pos = {x=1256, y=559, z=8} -- The new position of player3
nplayer4pos = {x=1256, y=560, z=8} -- The new position of player4
------------------------------------
---------------------------------------------
player1level = getPlayerLevel(player1.uid) -- Checking the level of player1
player2level = getPlayerLevel(player2.uid) -- Checking the level of player2
player3level = getPlayerLevel(player3.uid) -- Checking the level of player3
player4level = getPlayerLevel(player4.uid) -- Checking the level of player4
---------------------------------------------
-- check if all players has the right vocation --
if((knightvoc == 4 or knightvoc == 8) and
(paladinvoc == 3 or paladinvoc == 7) and
(druidvoc == 2 or druidvoc == 6) and
(sorcerervoc == 1 or sorcerervoc == 5)) then
-------------------------------------------------
-- check if they all players are on right positions -------------------------------------------------------------------
-------------------------------------
if player1level >= questlevel and
player2level >= questlevel and
player3level >= questlevel and
player4level >= questlevel then
-------------------------------------
-----------------------------------------------
if item.uid == switchUniqueID and
item.itemid == switchID and
getpiece1.itemid == swordID and
getpiece2.itemid == crossbowID and
getpiece3.itemid == appleID and
getpiece4.itemid == spellbookID then
-----------------------------------------------
-- sends an "poof" to the old pos --
doSendMagicEffect(player1pos,2)
doSendMagicEffect(player2pos,2)
doSendMagicEffect(player3pos,2)
doSendMagicEffect(player4pos,2)
------------------------------------
-- teleports the players to the new pos ---
doTeleportThing(player1.uid,nplayer1pos)
doTeleportThing(player2.uid,nplayer2pos)
doTeleportThing(player3.uid,nplayer3pos)
doTeleportThing(player4.uid,nplayer4pos)
-------------------------------------------
-- sends an "glimmer" to the new pos --
doSendMagicEffect(nplayer1pos,10)
doSendMagicEffect(nplayer2pos,10)
doSendMagicEffect(nplayer3pos,10)
doSendMagicEffect(nplayer4pos,10)
---------------------------------------
-- removes the items ---------------
doRemoveItem(getpiece1.uid,1)
doRemoveItem(getpiece2.uid,1)
doRemoveItem(getpiece3.uid,1)
doRemoveItem(getpiece4.uid,1)
------------------------------------
------------------------------------------
doTransformItem(item.uid,item.itemid+1)
------------------------------------------
------------------------------------------
--elseif item.uid == switchUniqueID and --Why? then you will still pull the lever when the items are incorrect and no error messages will be send
--item.itemid == switch2ID then
--doTransformItem(item.uid,item.itemid-1)
------------------------------------------
else
doPlayerSendCancel(cid,"Sorry, you need to put the correct items on the correct basins.")
end
else
return 0
end
else
doPlayerSendCancel(cid,"Sorry, all players in your team must be at least level " .. questlevel .. ".")
end
else
doPlayerSendCancel(cid,"Sorry not possible.")
end
return 1
end