local fragsRequired = 10
function onUse(cid, item, fromPosition, itemEx, toPosition)
local charPos = getCreaturePosition(cid)
local doorPos = getThingPos(item.uid)
if item.actionid == 1219 then
if getPlayerFrags(cid) >= fragsRequired then
if isInArray(verticalOpenDoors, item.itemid + 1) == TRUE then
if ( charPos.x == doorPos.x - 1 and charPos.z == doorPos.z ) then
doTeleportThing(cid, doorPos)
doMoveCreature(cid, 1)
doSendMagicEffect({x = doorPos.x + 1, y = doorPos.y, z = doorPos.z}, 12)
elseif ( charPos.x == doorPos.x + 1 and charPos.z == doorPos.z ) then
doTeleportThing(cid, doorPos)
doMoveCreature(cid, 3)
doSendMagicEffect({x = doorPos.x - 1, y = doorPos.y, z = doorPos.z}, 12)
end
elseif isInArray(horizontalOpenDoors, item.itemid + 1) == TRUE then
if ( charPos.y == doorPos.y - 1 and charPos.z == doorPos.z ) then
doTeleportThing(cid, doorPos)
doMoveCreature(cid, 2)
doSendMagicEffect({x = doorPos.x, y = doorPos.y + 1, z = doorPos.z}, 12)
elseif ( charPos.y == doorPos.y + 1 and charPos.z == doorPos.z ) then
doTeleportThing(cid, doorPos)
doMoveCreature(cid, 0)
doSendMagicEffect({x = doorPos.x, y = doorPos.y - 1, z = doorPos.z}, 12)
end
end
else
doPlayerSendTextMessage(cid, 24, "You need "..fragsRequired.." to pass! [Frags remaining: "..-(getPlayerFrags(cid)-fragsRequired).."]")
doSendMagicEffect(getCreaturePos(cid), 2)
end
else
doPlayerSendTextMessage(cid, 24, "Sorry, not possible.")
doSendMagicEffect(getCreaturePos(cid), 2)
end
return TRUE
end