local positions = {
[1] = {x = 1099, y = 1205, z = 8}, --dont touch--
[2] = {x = 1100, y = 1205, z = 8}, --dont touch--
[3] = {x = 1101, y = 1205, z = 8} --dont touch--
}
local left_side = {x = 1098, y = 1205, z = 8} --dont touch--
local right_side = {x = 1102, y = 1205, z = 8} --dont touch--
local lever = 1945 --dont touch--
local lever2 = 1946 --dont touch--
local lever_pos = {x = 1098, y = 1204, z = 8} --dont touch--
local lever2_pos = {x = 1104, y = 1201, z = 8} --dont touch--
local uid = 4508 --dont touch--
local bridge_tile = 5770 --dont touch--
-------------EDIT HERE-------------------------
local water_id = 1111 --Set to any water id
local left_bank = 1111 -- set to item id of the left side water border (where water connects to land)
local right_bank = 1111 --Set to itemid of the right side water border (where water connects to land)
------------------------------------------------
function onUse(cid, item, frompos, item2, topos)
if item.itemid == lever and item.uid == uid then
------------Create Bridge-------------------
for i = 1, #positions do
doCreateItem(bridge_tile, 1, positions[i])
end
doTransformItem(getThingFromPos(lever_pos).uid, lever2)
doTransformItem(getThingFromPos(lever2_pos).uid, lever2)
doItemSetAttribute(getThingFromPos(lever_pos).uid, 'uid', uid)
doItemSetAttribute(getThingFromPos(lever2_pos).uid, 'uid', uid)
-------------------------------------------------
elseif item.itemid == lever2 and item.uid == uid then
----------TELEPORT ANY PLAYERS STANDING ON BRIDGE--------------------
for i = 1, #positions do
if isPlayer(getThingFromPos(positions[i]).uid) then
if positions[i] == positions[1] then
doTeleportThing(getThingFromPos(positions[i]).uid, left_side)
elseif positions[i] == positions[2] then
doTeleportThing(getThingFromPos(positions[i]).uid, left_side)
elseif positions[i] == positions[3] then
doTeleportThing(getThingFromPos(positions[i]).uid, right_side)
end
end
end
-----------------------------------------------------------------------
----------------------REMOVE BRIDGE-----------------------------------
for i = 1, #positions do
if positions[i] == positions[1] then
doTransformItem(getThingFromPos(positions[i]).uid, left_bank)
elseif positions[i] == positions[2] then
doTransformItem(getThingFromPos(positions[i]).uid, water_id)
elseif positions[i] == positions[3] then
doTransformItem(getThingFromPos(positions[i]).uid, right_bank)
end
end
doTransformItem(getThingFromPos(lever_pos).uid, lever1)
doTransformItem(getThingFromPos(lever2_pos).uid, lever1)
doItemSetAttribute(getThingFromPos(lever_pos).uid, 'uid', uid)
doItemSetAttribute(getThingFromPos(lever2_pos).uid, 'uid', uid)
end-----------------------------------------------------------------
return true
end