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

TFS 1.X+ how to kick monsters and items off a wall in lever script tfs 1.5

bpm91

Intermediate OT User
Joined
May 23, 2019
Messages
880
Solutions
7
Reaction score
122
Location
Brazil
YouTube
caruniawikibr
hello, as the title says, want to know how do I kick monsters and items from the position where items respawn when pulling the lever that removes the item

Lua:
function onUse(cid, item, frompos, item2, topos)
gatepos = {x=32095, y=32173, z=8, stackpos=1}
getgate = getThingfromPos(gatepos)

dumppos = {x=32095, y=32174, z=8}

if item.itemid == 1945 then
doRemoveItem(getgate.uid,1)
doTransformItem(item.uid,item.itemid+1)

elseif item.itemid == 1946 then
doCreateItem(1026,1,gatepos)
doTransformItem(item.uid,item.itemid-1)
else
doPlayerSendCancel(cid,"Sorry not possible.")
end
  return 1
  end

Screenshot_1.pngScreenshot_2.png
 
Work, ty XIKINI ,<3
Post automatically merged:

in the case of a fire field for example, is it possible to remove it?Screenshot_1.png
 
Last edited:
I have an example here


But to be more direct..
Lua:
local function transposeFields(fromPosition, toPosition, transpose)
    local tile = Tile(fromPosition)
    if tile then
        local items = tile:getItems()
        if items then
            for i, item in ipairs(items) do
                if transpose == true then
                    item:moveTo(toPosition)
                else
                    item:remove()
                end
            end
        end
    end
end

transpose means to move..
So if you set transpose to true, it'll move the firefield.. if set to false, it'll destroy the firefield

But same thing as above.

Lua:
local gatePos = Position(32095, 32173, 8)
local dumpPos = Position(32095, 32174, 8)

local tile = Tile(gatePos)
if tile then
    tile:relocateTo(dumpPos)
    transposeFields(gatePos, dumpPos, false)
end

And looking back.. technically it's transposing all items.. not just fields.
Oh well. xP
As long as you use relocateTo first.. the only thing left will be field items.
 
thank you xikini <3
Post automatically merged:

for bridges, how would you fit item and field removal?

I tried to do the same for walls but it doesn't work and it doesn't give an error either


Lua:
local config = {
    bridgePositions = {
        Position(32627, 31699, 10),
        Position(32628, 31699, 10),
        Position(32629, 31699, 10)
    },
    removeCreaturePosition = Position(32630, 31699, 10),
    bridgeID = 5770,
    waterID = 493
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local tile, thing, creature
    for i = 1, #config.bridgePositions do
        tile = Tile(config.bridgePositions[i])
        if tile then
            thing, creature = tile:getItemById(item.itemid == 1945 and config.waterID or config.bridgeID), tile:getTopCreature()
            if thing then
                thing:transform(item.itemid == 1945 and config.bridgeID or config.waterID)
            end
            
            if creature then
                creature:teleportTo(config.removeCreaturePosition)
            end
        end
    end   
    
    Item(item.uid):transform(item.itemid == 1945 and 1946 or 1945)
    return true
end
Post automatically merged:

I would also like to know how do I remove the player from 2 floors for example in 2 getpos

local gatePos = Position(32100, 32205, 8)
local dumpPos = Position(32102, 32205, 8)

local tile = Tile(gatePos)
if tile then
tile:relocateTo(dumpPos)
end
 
Last edited:
Does anyone know how to make players who step on one side of the bridge be thrown to 1 side, and players from the other side to the other side? as well as the items that are on 1 side are thrown to one side and items on the other side are thrown to the other side, in addition to erasing the field launched on the bridge?

Screenshot_1.png



Lua:
local config = {
    bridgePositions = {
        Position(32627, 31699, 10),
        Position(32628, 31699, 10),
        Position(32629, 31699, 10)
    },
    removeCreaturePosition = Position(32630, 31699, 10),
    bridgeID = 1284,
    waterID = 493
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local tile, thing, creature
    for i = 1, #config.bridgePositions do
        tile = Tile(config.bridgePositions[i])
        if tile then
            thing, creature = tile:getItemById(item.itemid == 1945 and config.waterID or config.bridgeID), tile:getTopCreature()
            if thing then
                thing:transform(item.itemid == 1945 and config.bridgeID or config.waterID)
            end
            if creature then
                creature:teleportTo(config.removeCreaturePosition)
            end
        end
    end   
    Item(item.uid):transform(item.itemid == 1945 and 1946 or 1945)
    return true
end
Post automatically merged:

in this other case i have 2 levers but i can't have 4 dumppos for example only dumpposs 1 would work
Lua:
function onUse(cid, item, frompos, item2, topos)
stonepos1 = {x=32604, y=31904, z=3, stackpos=1}
getstone1 = getThingfromPos(stonepos1)
stonepos2 = {x=32605, y=31904, z=3, stackpos=1}
getstone2 = getThingfromPos(stonepos2)
stonepos3 = {x=32604, y=31905, z=3, stackpos=1}
getstone3 = getThingfromPos(stonepos3)
stonepos4 = {x=32605, y=31905, z=3, stackpos=1}
getstone4 = getThingfromPos(stonepos4)
--

--

switch1 = {x=32604, y=31908, z=3}
switch2 = {x=32603, y=31901, z=4}

if item.itemid == 1945 then
doRemoveItem(getstone1.uid, 1)
doRemoveItem(getstone2.uid, 1)
doRemoveItem(getstone3.uid, 1)
doRemoveItem(getstone4.uid, 1)
doTransformItem(getTileItemById(switch1, 1945).uid,1946)
doTransformItem(getTileItemById(switch2, 1945).uid,1946)

elseif item.itemid == 1946 then

doCreateItem(1300, 1, stonepos1)
doCreateItem(1301, 1, stonepos2)
doCreateItem(1302, 1, stonepos3)
doCreateItem(1303, 1, stonepos4)
doTransformItem(getTileItemById(switch1, 1946).uid,1945)
doTransformItem(getTileItemById(switch2, 1946).uid,1945)
end
return 1
end


Screenshot_3.pngScreenshot_2.png
 
Last edited:
Does anyone know how to make players who step on one side of the bridge be thrown to 1 side, and players from the other side to the other side? as well as the items that are on 1 side are thrown to one side and items on the other side are thrown to the other side, in addition to erasing the field launched on the bridge?

View attachment 74444



Lua:
local config = {
    bridgePositions = {
        Position(32627, 31699, 10),
        Position(32628, 31699, 10),
        Position(32629, 31699, 10)
    },
    removeCreaturePosition = Position(32630, 31699, 10),
    bridgeID = 1284,
    waterID = 493
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local tile, thing, creature
    for i = 1, #config.bridgePositions do
        tile = Tile(config.bridgePositions[i])
        if tile then
            thing, creature = tile:getItemById(item.itemid == 1945 and config.waterID or config.bridgeID), tile:getTopCreature()
            if thing then
                thing:transform(item.itemid == 1945 and config.bridgeID or config.waterID)
            end
            if creature then
                creature:teleportTo(config.removeCreaturePosition)
            end
        end
    end
    Item(item.uid):transform(item.itemid == 1945 and 1946 or 1945)
    return true
end
Post automatically merged:

in this other case i have 2 levers but i can't have 4 dumppos for example only dumpposs 1 would work
Lua:
function onUse(cid, item, frompos, item2, topos)
stonepos1 = {x=32604, y=31904, z=3, stackpos=1}
getstone1 = getThingfromPos(stonepos1)
stonepos2 = {x=32605, y=31904, z=3, stackpos=1}
getstone2 = getThingfromPos(stonepos2)
stonepos3 = {x=32604, y=31905, z=3, stackpos=1}
getstone3 = getThingfromPos(stonepos3)
stonepos4 = {x=32605, y=31905, z=3, stackpos=1}
getstone4 = getThingfromPos(stonepos4)
--

--

switch1 = {x=32604, y=31908, z=3}
switch2 = {x=32603, y=31901, z=4}

if item.itemid == 1945 then
doRemoveItem(getstone1.uid, 1)
doRemoveItem(getstone2.uid, 1)
doRemoveItem(getstone3.uid, 1)
doRemoveItem(getstone4.uid, 1)
doTransformItem(getTileItemById(switch1, 1945).uid,1946)
doTransformItem(getTileItemById(switch2, 1945).uid,1946)

elseif item.itemid == 1946 then

doCreateItem(1300, 1, stonepos1)
doCreateItem(1301, 1, stonepos2)
doCreateItem(1302, 1, stonepos3)
doCreateItem(1303, 1, stonepos4)
doTransformItem(getTileItemById(switch1, 1946).uid,1945)
doTransformItem(getTileItemById(switch2, 1946).uid,1945)
end
return 1
end


View attachment 74445View attachment 74446
1
Lua:
local waspBridge = Action()
local waspConfig = {  ---- wasps bridge de abdendriel
    {bridgePos = Position(32627, 31699, 10), relocateTo = Position(32626, 31699, 10), bridgeId = 1284, oldId = 508},
    {bridgePos = Position(32628, 31699, 10), relocateTo = Position(32626, 31699, 10), bridgeId = 1284, oldId = 493},
    {bridgePos = Position(32629, 31699, 10), relocateTo = Position(32630, 31699, 10), bridgeId = 1284, oldId = 509}
}
function waspBridge.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if not item then return false end
  
    local tile, tmpItem, bridge
    for i = 1, #waspConfig do
        bridge = waspConfig[i]
        tile = Tile(bridge.bridgePos)
        if not tile then
            return false
        end

        tmpItem = tile:getGround()
        if not tmpItem then
            return false
        end

        if item.itemid == 1945 then
            tmpItem:transform(bridge.bridgeId)
        else
            tile:relocateTo(bridge.relocateTo)
            tmpItem:transform(bridge.oldId)
        end
    end
  
    if item.itemid == 1945 then
        item:transform(1946)
    else
        item:transform(1945)
    end

    return true
end

waspBridge:uid(1000)
waspBridge:register()


2
Lua:
local kazzStone = Action()
local kazzStoneConfig = {
    {stonePos = Position(32605, 31904, 3), relocateTo = Position(32605, 31903, 3), stoneId = 1301},
    {stonePos = Position(32604, 31904, 3), relocateTo = Position(32604, 31903, 3), stoneId = 1300},
    {stonePos = Position(32605, 31905, 3), relocateTo = Position(32605, 31906, 3), stoneId = 1303},
    {stonePos = Position(32604, 31905, 3), relocateTo = Position(32604, 31906, 3), stoneId = 1302}
}
function kazzStone.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item.itemid == 1945 then
        for i = 1, #kazzStoneConfig do
            local stone = kazzStoneConfig[i]
            local bigStone = Tile(stone.stonePos):getItemById(stone.stoneId)
            if bigStone then
                bigStone:remove()
            end
        end
        item:transform(1946)
    else
        for i = 1, #kazzStoneConfig do
            local stone = kazzStoneConfig[i]
            local bigStone = Tile(stone.stonePos):getItemById(stone.stoneId)
            if not bigStone then
                local creatures = Tile(stone.stonePos):getTopCreature()
                if creatures then
                    creatures:teleportTo(stone.relocateTo, true)
                end
                local items = Tile(stone.stonePos):getItems()
                if items then
                    for i = 1, #items do
                        items[i]:moveTo(stone.relocateTo)
                    end
                end
                Game.createItem(stone.stoneId, 1, stone.stonePos)
            end
        end
        item:transform(1945)
    end

    return true
end
kazzStone:uid(1000)
kazzStone:register()

ps.: I already have that, but used chatgpt to update hahaha
 
Last edited:
Back
Top