• 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. tfs0.3.6 - 8.6

niti

New Member
Joined
Nov 22, 2009
Messages
258
Reaction score
2
Hi all

I need a script that teleports you from the destination you're standing on to one another. I got boss events so I want them to be 8 players and when all stands on the pos that tps u when u click on the switch, they'll be tped to the boss arena. Any1 help?
 
I took my annihilator action script and changed it to this
add it as .lua to your action scripts and also add a line for it in your actions.xml
this is not tested / tfs 036 based
Code:
local config = {
    level = 100,
    entry =
    {
        {x = 9854, y = 10405, z = 12},
        {x = 9855, y = 10405, z = 12},
        {x = 9856, y = 10405, z = 12},
        {x = 9857, y = 10405, z = 12},
        {x = 9858, y = 10405, z = 12},
        {x = 9859, y = 10405, z = 12},
        {x = 9860, y = 10405, z = 12},
        {x = 9861, y = 10405, z = 12}
    },
    destination =
    {
        {x = 9855, y = 10377, z = 12},
        {x = 9856, y = 10377, z = 12},
        {x = 9857, y = 10377, z = 12},
        {x = 9858, y = 10377, z = 12},
        {x = 9859, y = 10377, z = 12},
        {x = 9860, y = 10377, z = 12},
        {x = 9861, y = 10377, z = 12},
        {x = 9862, y = 10377, z = 12}
    }
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if(item.itemid == 1946) then
        doTransformItem(item.uid, item.itemid - 1)
        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
 
I took my annihilator action script and changed it to this
add it as .lua to your action scripts and also add a line for it in your actions.xml
this is not tested / tfs 036 based
Code:
local config = {
    level = 100,
    entry =
    {
        {x = 9854, y = 10405, z = 12},
        {x = 9855, y = 10405, z = 12},
        {x = 9856, y = 10405, z = 12},
        {x = 9857, y = 10405, z = 12},
        {x = 9858, y = 10405, z = 12},
        {x = 9859, y = 10405, z = 12},
        {x = 9860, y = 10405, z = 12},
        {x = 9861, y = 10405, z = 12}
    },
    destination =
    {
        {x = 9855, y = 10377, z = 12},
        {x = 9856, y = 10377, z = 12},
        {x = 9857, y = 10377, z = 12},
        {x = 9858, y = 10377, z = 12},
        {x = 9859, y = 10377, z = 12},
        {x = 9860, y = 10377, z = 12},
        {x = 9861, y = 10377, z = 12},
        {x = 9862, y = 10377, z = 12}
    }
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if(item.itemid == 1946) then
        doTransformItem(item.uid, item.itemid - 1)
        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
What should the Line be in action xml? I used the same switch as you did, 1945! What should I write in XML could u send me the line so I don't do anything wrong
 
<action actionid="9999" event="script" value="script.lua"/>
Like this just replace with any action id that is not in use yet and put the real direction and name of your scripts .lua file

And when you place the lever on the map make sure to give the lever the action id that you used in your actions.xml in this example case its 9999

And make sure you changed the entry and destination x,y,z coordinates in the .lua to the ones from your map and you also change the level to the requirement you want..

This is very basic stuff not really anything that you can do wrong...
 
<action actionid="9999" event="script" value="script.lua"/>
Like this just replace with any action id that is not in use yet and put the real direction and name of your scripts .lua file

And when you place the lever on the map make sure to give the lever the action id that you used in your actions.xml in this example case its 9999

And make sure you changed the entry and destination x,y,z coordinates in the .lua to the ones from your map and you also change the level to the requirement you want..

This is very basic stuff not really anything that you can do wrong...
so if I put the action id like 14123 the action id in-game on the ladder has to be 14123?
 
if u need it movement u can use this
Code:
local config = {
    level = 100,
    entry =
    {
        {x = 1007, y = 1000, z = 4},
        {x = 1007, y = 1001, z = 4},
        {x = 1007, y = 1002, z = 4}                              
    },
    destination =
    {
       {x = 1000, y = 1000, z = 7},
        {x = 1000, y = 1000, z = 7},
        {x = 1000, y = 1000, z = 7}
    }
}

function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition)

    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], 65)
        doTeleportThing(pid, config.destination[i], false)
        doSendMagicEffect(config.destination[i], CONST_ME_ENERGYAREA)
    end
    return true
end
Code:
    <movevent type="StepIn" actionid="7549" event="script" value="tp.lua"/>
 
Back
Top