• 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 0.X Problem with stackpos?(I want if item appear the char will be pushedback)

shass

Banned User
Joined
Dec 3, 2017
Messages
67
Reaction score
6
Well im using this script to remove mwall after x secconds, the problem is that if a player stand over the sqm where the mwall will appear at x secconds the mwall never appears again
please any lua coder could help me?
my serv is a tfs 0.3.7

Lua:
local pos = {x = 32259, y = 31891, z = 10, stackpos = 1} <- i've tried with numbers 1,10,0 and 7 no succes
local wall = 1498
local seconds = 10 -- use 0 to disable
local event = 0
local function reset(leverPos)
        local lever = getTileItemById(leverPos, 1946).uid
    doTransformItem(lever, 1945)
    doCreateItem(wall, 1, pos)
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
          if item.itemid == 1945 then
                doRemoveItem(getTileItemById(pos,wall).uid)
                if seconds > 0 then
                    event = addEvent(reset, seconds * 1000, getThingPos(item.uid))
                end
        doTransformItem(item.uid,item.itemid+1)
    elseif item.itemid == 1946 then
        stopEvent(event)
        doTransformItem(item.uid,item.itemid-1)
        doCreateItem(wall, 1, pos)
end
return true
end

also i tried to add it at movements item id 1498( so if a player stand over that item it will walk back) but nothing happens (now mwall appears but the char doesnto walk back)
 
Last edited:
Solution
edit var backPos!
Lua:
local pos = { x = 94, y = 126, z = 7, stackpos = 7 }
local backPos = { x = 94, y = 126, z = 7, stackpos = 7 }
local wall = 3362
local seconds = 5 -- use 0 to disable
local event = 0

local function reset(leverPos)
    local lever = getTileItemById(leverPos, 1946).uid
    doTransformItem(lever, 1945)
    local creature = getTopCreature(pos)
    if isPlayer(creature.uid) then
        doTeleportThing(creature.uid, backPos)
    end
    doCreateItem(wall, 1, pos)
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if item.itemid == 1945 then
                doRemoveItem(getTileItemById(pos,wall).uid)
                if seconds > 0 then
                    event = addEvent(reset, seconds * 1000...
Hello
Lua:
local pos = {x = 32259, y = 31891, z = 10, stackpos = 7}
local wall = 1498
local seconds = 10 -- use 0 to disable
local event = 0
local function reset(leverPos)
    local lever = getTileItemById(leverPos, 1946).uid
    doTransformItem(lever, 1945)
    local creature = getTopCreature(pos)
    if isCreature(creature) then
        doRemoveCreature(creature)
    end
    doCreateItem(wall, 1, pos)
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if item.itemid == 1945 then
                doRemoveItem(getTileItemById(pos,wall).uid)
                if seconds > 0 then
                    event = addEvent(reset, seconds * 1000, getThingPos(item.uid))
                end
        doTransformItem(item.uid,item.itemid+1)
    elseif item.itemid == 1946 then
        stopEvent(event)
        doTransformItem(item.uid,item.itemid-1)
        doCreateItem(wall, 1, pos)
end
return true
end
 
Hello
Lua:
local pos = {x = 32259, y = 31891, z = 10, stackpos = 7}
local wall = 1498
local seconds = 10 -- use 0 to disable
local event = 0
local function reset(leverPos)
    local lever = getTileItemById(leverPos, 1946).uid
    doTransformItem(lever, 1945)
    local creature = getTopCreature(pos)
    if isCreature(creature) then
        doRemoveCreature(creature)
    end
    doCreateItem(wall, 1, pos)
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if item.itemid == 1945 then
                doRemoveItem(getTileItemById(pos,wall).uid)
                if seconds > 0 then
                    event = addEvent(reset, seconds * 1000, getThingPos(item.uid))
                end
        doTransformItem(item.uid,item.itemid+1)
    elseif item.itemid == 1946 then
        stopEvent(event)
        doTransformItem(item.uid,item.itemid-1)
        doCreateItem(wall, 1, pos)
end
return true
end

Hello

it's exacly the same script bro xd thanks :x
 
exacly no!
local function reset(leverPos) modified with if condition
mmm correct, ive tested the wallappears but the character is not pushed back


i've found this code to make playerbe pushed back but it wont work and imhaving error console, also error at line 20, this is what i did

[C]: in function 'getTopCreature'
Lua:
if isCreature(getTopCreature(playerTile).uid) then
            doTeleportThing(getTopCreature(playerTile).uid, {x = 32099, y = 31829, z = 8})
        end


Lua:
local pos = {x = 32259, y = 31891, z = 10, stackpos = 7}
local wall = 1498
local seconds = 10 -- use 0 to disable
local event = 0
local function reset(leverPos)
    local lever = getTileItemById(leverPos, 1946).uid
    doTransformItem(lever, 1945)
    local creature = getTopCreature(pos)
    if isCreature(creature) then
        doRemoveCreature(creature)
    end
    doCreateItem(wall, 1, pos)
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if item.itemid == 1945 then
                doRemoveItem(getTileItemById(pos,wall).uid)
                if seconds > 0 then
                    event = addEvent(reset, seconds * 1000, getThingPos(item.uid))
                end
                if isCreature(getTopCreature(playerTile).uid) then
            doTeleportThing(getTopCreature(playerTile).uid, {x = 32099, y = 31829, z = 8})
        end
        doTransformItem(item.uid,item.itemid+1)
    elseif item.itemid == 1946 then
        stopEvent(event)
        doTransformItem(item.uid,item.itemid-1)
        doCreateItem(wall, 1, pos)
end
return true
end

@Sarah Wesker
 
Last edited:
Lua:
local pos = { x = 94, y = 126, z = 7, stackpos = 7 }
local wall = 3362
local seconds = 5 -- use 0 to disable
local event = 0

local function reset(leverPos)
    local lever = getTileItemById(leverPos, 1946).uid
    doTransformItem(lever, 1945)
    local creature = getTopCreature(pos)
    if isPlayer(creature.uid) then
        local town = getPlayerTown(creature.uid)
        local townPosition = getTownTemplePosition(town)
        doTeleportThing(creature.uid, townPosition)
    end
    doCreateItem(wall, 1, pos)
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if item.itemid == 1945 then
                doRemoveItem(getTileItemById(pos,wall).uid)
                if seconds > 0 then
                    event = addEvent(reset, seconds * 1000, getThingPos(item.uid))
                end
        doTransformItem(item.uid,item.itemid+1)
    elseif item.itemid == 1946 then
        stopEvent(event)
        doTransformItem(item.uid,item.itemid-1)
        doCreateItem(wall, 1, pos)
end
return true
end
Test 100%
 
Lua:
local pos = { x = 94, y = 126, z = 7, stackpos = 7 }
local wall = 3362
local seconds = 5 -- use 0 to disable
local event = 0

local function reset(leverPos)
    local lever = getTileItemById(leverPos, 1946).uid
    doTransformItem(lever, 1945)
    local creature = getTopCreature(pos)
    if isPlayer(creature.uid) then
        local town = getPlayerTown(creature.uid)
        local townPosition = getTownTemplePosition(town)
        doTeleportThing(creature.uid, townPosition)
    end
    doCreateItem(wall, 1, pos)
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if item.itemid == 1945 then
                doRemoveItem(getTileItemById(pos,wall).uid)
                if seconds > 0 then
                    event = addEvent(reset, seconds * 1000, getThingPos(item.uid))
                end
        doTransformItem(item.uid,item.itemid+1)
    elseif item.itemid == 1946 then
        stopEvent(event)
        doTransformItem(item.uid,item.itemid-1)
        doCreateItem(wall, 1, pos)
end
return true
end
Test 100%



How do i make teleport player walk-back? //step back? not to teleport temple?

Lua:
if isPlayer(creature.uid) then
        local town = getPlayerTown(creature.uid)
        local townPosition = getTownTemplePosition(town)
 
edit var backPos!
Lua:
local pos = { x = 94, y = 126, z = 7, stackpos = 7 }
local backPos = { x = 94, y = 126, z = 7, stackpos = 7 }
local wall = 3362
local seconds = 5 -- use 0 to disable
local event = 0

local function reset(leverPos)
    local lever = getTileItemById(leverPos, 1946).uid
    doTransformItem(lever, 1945)
    local creature = getTopCreature(pos)
    if isPlayer(creature.uid) then
        doTeleportThing(creature.uid, backPos)
    end
    doCreateItem(wall, 1, pos)
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if item.itemid == 1945 then
                doRemoveItem(getTileItemById(pos,wall).uid)
                if seconds > 0 then
                    event = addEvent(reset, seconds * 1000, getThingPos(item.uid))
                end
        doTransformItem(item.uid,item.itemid+1)
    elseif item.itemid == 1946 then
        stopEvent(event)
        doTransformItem(item.uid,item.itemid-1)
        doCreateItem(wall, 1, pos)
end
return true
end
there is no function that returns the previous position
only if they were movements
 
Solution
edit var backPos!
Lua:
local pos = { x = 94, y = 126, z = 7, stackpos = 7 }
local backPos = { x = 94, y = 126, z = 7, stackpos = 7 }
local wall = 3362
local seconds = 5 -- use 0 to disable
local event = 0

local function reset(leverPos)
    local lever = getTileItemById(leverPos, 1946).uid
    doTransformItem(lever, 1945)
    local creature = getTopCreature(pos)
    if isPlayer(creature.uid) then
        doTeleportThing(creature.uid, backPos)
    end
    doCreateItem(wall, 1, pos)
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if item.itemid == 1945 then
                doRemoveItem(getTileItemById(pos,wall).uid)
                if seconds > 0 then
                    event = addEvent(reset, seconds * 1000, getThingPos(item.uid))
                end
        doTransformItem(item.uid,item.itemid+1)
    elseif item.itemid == 1946 then
        stopEvent(event)
        doTransformItem(item.uid,item.itemid-1)
        doCreateItem(wall, 1, pos)
end
return true
end
there is no function that returns the previous position
only if they were movements


Worked !! seriusly i been looking like a crazy

thanks Solved
 
Back
Top Bottom