local Stor = 4545
local ActionsIds = {50022, 50023, 50024, 50025}
local Back =
{
[1] = {x=777, y=777, z=7}, --SVARGROND back position.
[2] = {x=666, y=666, z=6}, --VENORE back position
[3] = {x=555, y=555, z=5} --CARLIN back position.
}
--Put Unique ids to the gates.
local From =
{
--From Svargrond.
[50018] = {"Earth", 1, {2, 6}},
[50019] = {"Ice", 1, {2, 6}},
[50020] = {"Energy", 1, {1, 5}},
[50021] = {"Fire", 1, {1, 5}},
--From Venore.
[50118] = {"Earth", 2, {2, 6}},
[50119] = {"Ice", 2, {2, 6}},
[50120] = {"Energy", 2, {1, 5}},
[50121] = {"Fire", 2, {1, 5}},
--From Carlin
[50218] = {"Earth", 3, {2, 6}},
[50219] = {"Ice", 3, {2, 6}},
[50220] = {"Energy", 3, {1, 5}},
[50221] = {"Fire", 3, {1, 5}}
}
--Here the random 2 positions ~
local Locations =
{
["Earth"] =
{
{x=1013, y=897, z=6},
{x=1013, y=898, z=6}
},
["Ice"] =
{
{x=454, y=454, z=4},
{x=455, y=455, z=5}
},
["Energy"] =
{
{x=1013, y=897, z=6},
{x=1013, y=898, z=6}
},
["Fire"] =
{
{x=654, y=654, z=4},
{x=655, y=655, z=5}
}
}
local function MoveBack(cid, fromPosition, n)
if n == 2 then VocName = "Druids" else VocName = "Sorcerers" end
doCreatureSay(cid, "Only Premium ".. VocName .." of level 30 or higher are able to enter this portal.", TALKTYPE_ORANGE_1)
doTeleportThing(cid, fromPosition, TRUE)
end
function onStepIn(cid, item, position, fromPosition)
if isPlayer(cid) == TRUE then
local Gate = From[item.uid]
if Gate then
if isPremium(cid) == TRUE then
if getPlayerLevel(cid) >= 30 then
if isInArray(Gate[3], getPlayerVocation(cid)) == TRUE or getPlayerAccess(cid) >= 3 then
local nPos = Locations[Gate[1]][math.random(1, 2)]
doTeleportThing(cid, nPos, FALSE)
doSendMagicEffect(nPos, CONST_ME_TELEPORT)
setPlayerStorageValue(cid, Stor, Gate[2])
else
MoveBack(cid, fromPosition, Gate[3][1])
end
else
MoveBack(cid, fromPosition, Gate[3][1])
end
else
MoveBack(cid, fromPosition, Gate[3][1])
end
elseif isInArray(ActionsIds, item.actionid) == TRUE then
if Back[getPlayerStorageValue(cid, Stor)] then
local backPos = Back[getPlayerStorageValue(cid, Stor)]
doTeleportThing(cid, backPos, FALSE)
doSendMagicEffect(backPos, CONST_ME_TELEPORT)
else
--if the player does not have a storage he will be teleported here
doTeleportThing(cid, {x=1000, y=1000, z=7}, FALSE)
doSendMagicEffect({x=1000, y=1000, z=7}, CONST_ME_TELEPORT)
end
end
end
return TRUE
end