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

Lua switch script needs a small edit

Calon

Experienced Member
Joined
Feb 6, 2009
Messages
1,070
Reaction score
21
hello i just trying to add something like when the player remove the stone and the tp spawn,
then after 1 min or something everything back the stone back to the position and the tp disappear again
rep ++
Code:
-- >> By SasiR --
-- Stone Item ID.
local stoneItemID = 1355

-- Stone Position.
local stonePos = {x = 33314, y = 31592, z = 15, stackpos = 1}

-- Position where the teleport will spawn.
local teleportPos = {x = 33316, y = 31591, z = 15, stackpos = 254}

-- Position where the teleporter will teleport you to.
local tpToPos = {x = 33328, y = 31592, z = 14, stackpos = 255}
-- Config << --

-- Main function.
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if (item.itemid == 1945) then
        local stone = getTileItemById(stonePos, stoneItemID)

        -- Avoid removing a non-existent stone.
        if (stone.itemid == stoneItemID) then doRemoveItem(stone.uid) end
        local cueball = getTileItemById(teleportPos, 1387)

        -- Avoid creating 2 teleports.
        if (cueball.itemid == 1387) then doRemoveItem(cueball.uid) end

        doCreateTeleport(1387, tpToPos, teleportPos)
        doSendMagicEffect(teleportPos, CONST_ME_TELEPORT)
        doSendMagicEffect(stonePos, CONST_ME_POFF)
        doTransformItem(item.uid, item.itemid + 1)
    elseif (item.itemid == 1946) then
        local stone = getTileItemById(stonePos, stoneItemID)

        -- Avoid placing a 2nd stone.
        if (stone.itemid == stoneItemID) then doRemoveItem(stone.uid) end

        local cueball = getTileItemById(teleportPos, 1387)

        -- Avoid removing a non-existent teleport.
        if (cueball.itemid == 1387) then doRemoveItem(cueball.uid) end

        doCreateItem(stoneItemID, 1, stonePos)
        doSendMagicEffect(stonePos, CONST_ME_TELEPORT)
        doSendMagicEffect(teleportPos, CONST_ME_POFF)
        doTransformItem(item.uid, item.itemid - 1)
    end
    return TRUE
end
 
Last edited:
LUA:
-- >> By SasiR --
-- Stone Item ID.
local stoneItemID = 1355

-- Stone Position.
local stonePos = {x = 33314, y = 31592, z = 15, stackpos = 1}

-- Position where the teleport will spawn.
local teleportPos = {x = 33316, y = 31591, z = 15, stackpos = 254}

-- Position where the teleporter will teleport you to.
local tpToPos = {x = 33328, y = 31592, z = 14, stackpos = 255}
-- Config << --

local function restoreStone(leverPos, telPos, stonePos)
        local stone = getTileItemById(stonePos, stoneItemID)

        if (stone.itemid == stoneItemID) then doRemoveItem(stone.uid) end

        local cueball = getTileItemById(teleportPos, 1387)
        if (cueball.itemid == 1387) then doRemoveItem(cueball.uid) end

        doCreateItem(stoneItemID, 1, stonePos)
        doSendMagicEffect(stonePos, CONST_ME_TELEPORT)
        doSendMagicEffect(teleportPos, CONST_ME_POFF)
	
	local lever = getTileItemById(leverPos, 1946)
	if lever.uid > 0 then
		doTransformItem(lever.uid, lever.itemid - 1)
	end
end

-- Main function.
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if (item.itemid == 1945) then
        local stone = getTileItemById(stonePos, stoneItemID)

        -- Avoid removing a non-existent stone.
        if (stone.itemid == stoneItemID) then doRemoveItem(stone.uid) end
        local cueball = getTileItemById(teleportPos, 1387)

        -- Avoid creating 2 teleports.
        if (cueball.itemid == 1387) then doRemoveItem(cueball.uid) end

        doCreateTeleport(1387, tpToPos, teleportPos)
        doSendMagicEffect(teleportPos, CONST_ME_TELEPORT)
        doSendMagicEffect(stonePos, CONST_ME_POFF)
        doTransformItem(item.uid, item.itemid + 1)
	
	addEvent(restoreStone, 60 * 1000, fromPosition, teleportPos, stonePos)
    end
    return TRUE
end
 
Back
Top