• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

newFishing how to move top stackpos item from position to another

Competitibia

Pain & Glory WHole
Joined
Apr 1, 2021
Messages
545
Solutions
3
Reaction score
211
LUA:
local useWorms = FALSE
local waterIds = {493, 4608, 4609, 4610, 4611, 4612, 4613, 4614, 4615, 4616, 4617, 4618, 4619, 4620, 4621, 4622, 4623, 4624, 4625}
function onUse(cid, item, fromPosition, itemEx, toPosition)

    if isInArray(waterIds, itemEx.itemid) == TRUE then
        if itemEx.itemid ~= 493 then
            if math.random(1, (100 + (getPlayerSkill(cid, SKILL_FISHING) / 10))) <= getPlayerSkill(cid, SKILL_FISHING) then
                if useWorms == TRUE then
                    if getPlayerItemCount(cid, ITEM_WORM) > 0 then
                        doPlayerRemoveItem(cid, ITEM_WORM, 1)
                        doPlayerAddItem(cid, ITEM_FISH, 1)
                    end
                else
                    doPlayerAddItem(cid, ITEM_FISH, 1)
                end
            end
            doPlayerAddSkillTry(cid, SKILL_FISHING, 1)
        end
        doSendMagicEffect(toPosition, CONST_ME_LOSEENERGY)
        return TRUE
    elseif isSightClear(fromPosition, toPosition, floorCheck) and not getTileInfo(toPosition).house then
    doRelocate(toPosition, getPlayerPosition(cid),false, false)
    --moveitem
    else
    doSendAnimatedText(toPosition, "THIEF!", TEXTCOLOR_YELLOW)
    doSendAnimatedText(getPlayerPosition(cid), "THIEF!", TEXTCOLOR_YELLOW)
    doSendMagicEffect(toPosition, 83)
    end
    return FALSE
end


current code moves whole stack i want it to only move the top item in position will i have to rewrite doRelocate function or is there a way?
am I blind or missing something?
 
LUA:
local useWorms = FALSE
local waterIds = {493, 4608, 4609, 4610, 4611, 4612, 4613, 4614, 4615, 4616, 4617, 4618, 4619, 4620, 4621, 4622, 4623, 4624, 4625}
function onUse(cid, item, fromPosition, itemEx, toPosition)

    if isInArray(waterIds, itemEx.itemid) == TRUE then
        if itemEx.itemid ~= 493 then
            if math.random(1, (100 + (getPlayerSkill(cid, SKILL_FISHING) / 10))) <= getPlayerSkill(cid, SKILL_FISHING) then
                if useWorms == TRUE then
                    if getPlayerItemCount(cid, ITEM_WORM) > 0 then
                        doPlayerRemoveItem(cid, ITEM_WORM, 1)
                        doPlayerAddItem(cid, ITEM_FISH, 1)
                    end
                else
                    doPlayerAddItem(cid, ITEM_FISH, 1)
                end
            end
            doPlayerAddSkillTry(cid, SKILL_FISHING, 1)
        end
        doSendMagicEffect(toPosition, CONST_ME_LOSEENERGY)
        return TRUE
    elseif isSightClear(fromPosition, toPosition, floorCheck) and not getTileInfo(toPosition).house then
    doRelocate(toPosition, getPlayerPosition(cid),false, false)
    --moveitem
    else
    doSendAnimatedText(toPosition, "THIEF!", TEXTCOLOR_YELLOW)
    doSendAnimatedText(getPlayerPosition(cid), "THIEF!", TEXTCOLOR_YELLOW)
    doSendMagicEffect(toPosition, 83)
    end
    return FALSE
end


current code moves whole stack i want it to only move the top item in position will i have to rewrite doRelocate function or is there a way?
am I blind or missing something?

try using something like:
local tile = Tile(toPosition)
local thing = tile:getTopVisibleThing()
if thing:isItem() and thing:getType():isMovable() then
return thing:moveTo(player pos?)

a tip, fyi, you don't have to check variables == TRUE, to check if them are true..
i.e.
if isInArray(waterIds, itemEx.itemid) == TRUE then
if useWorms == TRUE then

use instead:
if isInArray(waterIds, itemEx.itemid) then
if useWorms then
 
look how is done in rope script and copy from there
dont know how to use ur answer as correct one but thats all folks

that actually is what i needed thanks! however im leaving mine as is because it works as anti trash tool aswell which can be quite great on 7.4 with the amount of botters
ROPE SCRIPT FOR ANYONE INTERESTED:
LUA:
local SEWER_GRATE = {430}
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, 369, 370, 408, 409, 427, 428, 3135, 3136, 5545, 5763}

function onUse(cid, item, frompos, item2, topos)
if topos.x == 65535 then
return 0
end

if item2.itemid == 0 then
return 0
end
    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 = 1}
    blockingItem = getThingfromPos(BlockItemPos)
    if (isInArray(ROPE_SPOT, groundItem.itemid) == TRUE) then
        newPos.y = newPos.y + 1
        newPos.z = newPos.z - 1
        if blockingItem.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 or isInArray(SEWER_GRATE, item2.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
 
Back
Top