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

Lever that requires players on tile.

juansanchez

Intermediate OT User
Joined
Apr 2, 2015
Messages
217
Reaction score
130
Hey everyone, i've been trying to make a simple lever script however i am very bad at scripting, i tried editing other existing scripts with a similar function but i couldn't make it work.

So, all i need is:

I-) Players must stay on specific tile.
II-) Once everyone is on their tiles someone pulls the lever.
III-) Once the lever is pulled, a stone is removed from its position.
IV-) The lever cannot be pulled again so the wall stays down until server save.

That's it guys. That's all i need. I Hope someone can help me out.

I'm using: The Forgotten Server, version 0.3.7_SVN (Crying Damson) (I am aware it's a bad TFS).
 
funny co-inkidink I had 0.3.6 (Crying Damson) on my laptop from a long time ago, so you're in luck (not that I couldn't have helped you but this makes it easier anyway)
this is the annihilator.lua I plucked from there
Lua:
local config = {
    daily = "no", -- allow only one enter per day? (like in global Tibia)
    level = 100,
    storage = 30015,
    entry =
    {
        {x = 247, y = 659, z = 13},
        {x = 247, y = 660, z = 13},
        {x = 247, y = 661, z = 13},
        {x = 247, y = 662, z = 13}
    },
    destination =
    {
        {x = 189, y = 650, z = 13},
        {x = 189, y = 651, z = 13},
        {x = 189, y = 652, z = 13},
        {x = 189, y = 653, z = 13}
    }
}

config.daily = getBooleanFromString(config.daily)
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if(item.itemid == 1946) then
        if(config.daily) then
            doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
        else
            doTransformItem(item.uid, item.itemid - 1)
        end

        return true
    end

    if(item.itemid ~= 1945) then
        return true
    end

    local players = {}
    for _, position in ipairs(config.entry) do
        local pid = getTopCreature(position).uid
        if(pid == 0 or not isPlayer(pid) or getCreatureStorage(pid, config.storage) > 0 or getPlayerLevel(pid) < config.level) then
            doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
            return true
        end

        table.insert(players, pid)
    end

    for i, pid in ipairs(players) do
        doSendMagicEffect(config.entry[i], CONST_ME_POFF)
        doTeleportThing(pid, config.destination[i], false)
        doSendMagicEffect(config.destination[i], CONST_ME_ENERGYAREA)
    end

    doTransformItem(item.uid, item.itemid + 1)
    return true
end
this sounds like its very similar to what you want but first of all you don't want to teleport the players anywhere so we don't need these lines
Lua:
    for i, pid in ipairs(players) do
        doSendMagicEffect(config.entry[i], CONST_ME_POFF)
        doTeleportThing(pid, config.destination[i], false)
        doSendMagicEffect(config.destination[i], CONST_ME_ENERGYAREA)
    end
what you want instead is the stone to be removed, the best way to do this is probably to set the uniqueid of the stone in the mapeditor and then use this line
Lua:
doRemoveItem(uid)
alternatively, there are many functions that govern getting things from positions
but I cannot be sure what exists on your distro and my memory is a little hazy of how 0.x handles things
I'm pretty sure that if the stone is immovable then
Lua:
getThingfromPos(pos)
will return the stone
otherwise try one of these
Lua:
getTileThingByPos(position)
getTileThingByTopOrder(position, topOrder)
getTileItemById(position, itemId, ...)
getTileItemByType(position, itemType)
[TFS 1.0 / 1.2] LUA Functions
good luck
 
Back
Top Bottom