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

Rope action like 7.4 TFS 1.2

armyman

Member
Joined
Feb 15, 2014
Messages
318
Reaction score
13
I need a action of my rope in server 7.72 to not work with item or player in rope spot.

this is my rope script

Lua:
local OPENED_HOLE = {294, 383, 469, 470, 482, 482, 485, 489, 430}
local OPENED_TRAP = {462}
local DOWN_LADDER = {369, 370, 408, 409, 427, 428, 3135, 3136, 5545, 5763}
local ROPE_SPOT = {384, 418}
local allowed_items_inway = {2016, 2017, 2018, 2019, 2020, 2021, 1903, 1904, 1905}

function onUse(cid, item, frompos, item2, topos)
    newPos = {x = topos.x, y = topos.y, z = topos.z, stackpos = 0}
    groundItem = getThingfromPos(newPos)
   
    BlockItemPos = {x = topos.x, y = topos.y, z = topos.z, stackpos = 2}
    blockingItem = getThingfromPos(BlockItemPos)
    BlockItem1 = {x = topos.x, y = topos.y, z = topos.z, stackpos = 1}
    blockiItem1 = getThingfromPos(BlockItem1)
    if (isInArray(ROPE_SPOT, groundItem.itemid) == TRUE) then
        newPos.y = newPos.y + 1
        newPos.z = newPos.z - 1
        if blockingItem.itemid <= 0 or blockiItem1.itemid <= 0 or (isInArray(allowed_items_inway, blockingItem.itemid) == TRUE) then
        doTeleportThing(cid, newPos)
        end
    elseif (isInArray(OPENED_HOLE, groundItem.itemid) == TRUE or isInArray(OPENED_TRAP, groundItem.itemid) == TRUE or isInArray(DOWN_LADDER, groundItem.itemid) == TRUE) then
        newPos.y = newPos.y + 1
        downPos = {x = topos.x, y = topos.y, z = topos.z + 1, stackpos = 255}
        downItem = getThingfromPos(downPos)
        if (downItem.itemid > 0) then
            doTeleportThing(downItem.uid, newPos)
        else
            doPlayerSendCancel(cid, "Sorry, not possible.")
        end
    else
        return FALSE
    end
    return TRUE
end
 
Solution
Try this one:
Code:
local OPENED_HOLE = {294, 383, 469, 470, 482, 482, 485, 489, 430}
local OPENED_TRAP = {462}
local DOWN_LADDER = {369, 370, 408, 409, 427, 428, 3135, 3136, 5545, 5763}
local ROPE_SPOT = {384, 418}
local allowed_items_inway = {2016, 2017, 2018, 2019, 2020, 2021, 1903, 1904, 1905}
function onUse(cid, item, frompos, item2, topos)
    newPos = {x = topos.x, y = topos.y, z = topos.z, stackpos = 0}
    groundItem = getThingfromPos(newPos)
    blockingItem = getThingfromPos({x = topos.x, y = topos.y, z = topos.z, stackpos = 1})
    if(isInArray(ROPE_SPOT, groundItem.itemid) == TRUE) then
        newPos.y = newPos.y + 1
        newPos.z = newPos.z - 1
        if((blockingItem.itemid > 0 and not isInArray(allowed_items_inway...
change
Lua:
if (downItem.itemid > 0) then
to
Lua:
if isCreature(downItem.uid) and not isPlayer(downItem.uid) and not isNpc(downItem.uid) then

Fairly certain .uid is required for it to check for creatures..
But it's 11pm, and I don't feel like doing some tests on my own server.. zzzzz
 
Rope like 7.4, i can rope creatures, player or items if i stay in other floor, but if me stay in same floor of the rope spot, and have items, players, creatures, i can't use rope for up floor

Imo it should be like:
Code:
if(downItem.itemid > 0 or isMonster(downItem.uid)) then

i got error in console now

Lua:
Lua Script Error: [Action Interface]
data/actions/scripts/tools/rope.lua:onUse
data/actions/scripts/tools/rope.lua:18: attempt to index global 'downItem' (a ni
l value)
stack traceback:
        [C]: in function '__index'
        data/actions/scripts/tools/rope.lua:18: in function <data/actions/script
s/tools/rope.lua:7>
 
Last edited by a moderator:
Try this one:
Code:
local OPENED_HOLE = {294, 383, 469, 470, 482, 482, 485, 489, 430}
local OPENED_TRAP = {462}
local DOWN_LADDER = {369, 370, 408, 409, 427, 428, 3135, 3136, 5545, 5763}
local ROPE_SPOT = {384, 418}
local allowed_items_inway = {2016, 2017, 2018, 2019, 2020, 2021, 1903, 1904, 1905}
function onUse(cid, item, frompos, item2, topos)
    newPos = {x = topos.x, y = topos.y, z = topos.z, stackpos = 0}
    groundItem = getThingfromPos(newPos)
    blockingItem = getThingfromPos({x = topos.x, y = topos.y, z = topos.z, stackpos = 1})
    if(isInArray(ROPE_SPOT, groundItem.itemid) == TRUE) then
        newPos.y = newPos.y + 1
        newPos.z = newPos.z - 1
        if((blockingItem.itemid > 0 and not isInArray(allowed_items_inway, blockingItem.itemid)) or isCreature(groundItem.uid)) then
           doPlayerSendCancel(cid, "Sorry, not possible.")
       else
           doTeleportThing(cid, newPos)
        end
    elseif(isInArray(OPENED_HOLE, groundItem.itemid) == TRUE or isInArray(OPENED_TRAP, groundItem.itemid) == TRUE or isInArray(DOWN_LADDER, groundItem.itemid) == TRUE) then
        newPos.y = newPos.y + 1
        downPos = {x = topos.x, y = topos.y, z = topos.z + 1, stackpos = 255}
        downItem = getThingfromPos(downPos)
        if(downItem.itemid > 0) then
            doTeleportThing(downItem.uid, newPos)
        else
            doPlayerSendCancel(cid, "Sorry, not possible.")
        end
    end
    return true
end
 
Solution
im trying to implement this and it's not working , can someone help me? im using otx3 based on tfs1.2

this isthe code related to the rope in lib/actions.lua
Code:
function onUseRope(player, item, fromPosition, target, toPosition)
    local tile = Tile(toPosition)
    if not tile then
        return false
    end

    if table.contains(ropeSpots, tile:getGround():getId()) or tile:getItemById(14435) then
        tile = Tile(toPosition:moveUpstairs())
        if tile:hasFlag(TILESTATE_PROTECTIONZONE) and player:isPzLocked() then
            player:sendTextMessage(MESSAGE_STATUS_SMALL, Game.getReturnMessage(RETURNVALUE_PLAYERISPZLOCKED))
            return true
        end
        player:teleportTo(toPosition, false)
        return true
    elseif table.contains(holeId, target.itemid) then
        toPosition.z = toPosition.z + 1
        tile = Tile(toPosition)
        if tile then
            local thing = tile:getTopVisibleThing()
            if thing:isPlayer() then
                tile = Tile(toPosition:moveUpstairs())
                if tile:hasFlag(TILESTATE_PROTECTIONZONE) and thing:isPzLocked() then
                    return false
                end
                return thing:teleportTo(toPosition, false)
            end
            if thing:isItem() and thing:getType():isMovable() then
                return thing:moveTo(toPosition:moveUpstairs())
            end
        end

        player:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
        return true
    end

    return false
end

and in actions/tools/rope.lua i got this
Code:
function onUse(player, item, fromPosition, target, toPosition)
    return onUseRope(player, item, fromPosition, target, toPosition)
end


and changed it by the code of Garqet but is not working.
 
Back
Top