• 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 auto fishing until walk, to no bots

hiwyn

Member
Joined
Aug 30, 2021
Messages
78
Reaction score
8
People are using macro/bots to fishing in my server and that's is because its boring as fuck...
To avoid it i would like to make fishing action automatic, i mean:
  • u click to fish
  • it still fishing forever until u walk
so no macros and on hands people could fishing fair
how to do this?

Code:
local config = {
    waters = {4614, 4615, 4616, 4617, 4618, 4619, 4620, 4621, 4622, 4623, 4624, 4625, 4665, 4666, 4820, 4821, 4822, 4823, 4824, 4825},
    fishable = {4608, 4609, 4610, 4611, 4612, 4613, 7236},
    spawning = {4614, 4615, 4616, 4617, 4618, 4619},
    holes = {7236},
    baitCount = 1,
    chance = 10
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local playerPosition = getCreaturePosition(cid)
    if getTileInfo(playerPosition).protection then
        doSendMagicEffect(playerPosition, CONST_ME_POFF)
        doPlayerSendCancel(cid, "You can not fish from a protection zone.")
        return true
    end
    
    if(isInArray(config.waters, itemEx.itemid)) then
        if(isInArray(config.spawning, itemEx.itemid)) then
            doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
        end

        doSendMagicEffect(toPosition, CONST_ME_LOSEENERGY)
        return true
    end

    if(not isInArray(config.fishable, itemEx.itemid)) then
        return false
    end
    if getPlayerLevel(cid) < 8 then
        doSendMagicEffect(getPlayerPosition(cid), 2)
        doPlayerPopupFYI(cid, 'You need at least level 8 to fish!')
        return false
    end


    local position, tries, myfisning = getThingPosition(cid), 0, getPlayerSkill(cid, SKILL_FISHING)
    config.allowFromPz = config.allowFromPz or not getTileInfo(position).protection
    if(getPlayerItemCount(cid, ITEM_WORM) >= config.baitCount) then
        tries = 1
        if(math.random(100) <= config.chance) then
            if(doPlayerRemoveItem(cid, ITEM_WORM, config.baitCount)) then
                tries = 2
                doPlayerAddItem(cid, 2667, 1)
            end
        end
    elseif(getPlayerItemCount(cid, 10224) >= 1) then
        tries = 1
        if(math.random(100) <= config.chance) then
            tries = 2
            doPlayerAddItem(cid, 2667, 1)
        end
    end

    if(tries > 1) then
        doPlayerAddSkillTry(cid, SKILL_FISHING, tries)
    if(not isInArray(config.holes, itemEx.itemid)) then
            doTransformItem(itemEx.uid, itemEx.itemid + 6)
        else
            doTransformItem(itemEx.uid, itemEx.itemid + 1)
        end
        doDecayItem(itemEx.uid)
    elseif(tries > 0) then
        -- no skill on fail
        -- doPlayerAddSkillTry(cid, SKILL_FISHING, 1)
    end

    doSendMagicEffect(toPosition, CONST_ME_LOSEENERGY)
    return true
end
 
Hi there,
I can share script I improved and it's based on
Nostalrius Fishing Rod Script
I'm not sure if it will work on 0.4x - I've tested it on 1.5 downgrade (Tibia 8.6), you can give it a try.

I've defined script for mechanical fishing rod
Lua:
<action itemid="10223" script="tools/mechanical_fishing.lua" allowfaruse="1" />

Assumptions:
  • You need at least 1 worm to start fishing
  • After use, you will be fishing until you run out of worms
  • You cannot start few fishing processes
  • You can stop fishing by moving your character
  • There is possibility to drop item or spawn monster
  • Success of fishing will slightly depend on your fishing skill (the greater the fishing skill, the greater the chance of catching prey)

Then added following action script
Lua:
local WORMID = 3976
local fishableThings = {
    [1] = {
        thingId = 2149, -- Small Emerald
        chance = 10,
        monster = false,
    },
    [2] = {
        thingId = 2147, -- Small Ruby
        chance = 7,
        monster = false,
    },
    [3] = {
        thingId = 2146, -- Small Saph
        chance = 6,
        monster = false,
    },
    [4] = {
        thingId = 2145, -- Small Diamond
        chance = 7,
        monster = false,
    },
    [5] = {
        thingId = 2144, -- Black Pearl
        chance = 10,
        monster = false,
    },
    [6] = {
        thingId = 7159, -- Green Perch
        chance = 50,
        monster = false,
    },
    [7] = {
        thingId = 2667, -- Fish
        chance = 300,
        monster = false,
    },
    [8] = {
        thingId = 5091, -- Treasure Map
        chance = 20,
        monster = false,
    },
    [9] = {
        thingId = "Quara Constrictor",
        chance = 10,
        monster = true,
    },
    [10] = {
        thingId = "Quara Hydromancer",
        chance = 10,
        monster = true,
    },
    [11] = {
        thingId = "Quara Mantassin",
        chance = 15,
        monster = true,
    },
    [12] = {
        thingId = "Quara Predator",
        chance = 8,
        monster = true,
    },
    [13] = {
        thingId = "Young Sea Serpent",
        chance = 5,
        monster = true,
    },
    [14] = {
        thingId = "Thul",
        chance = 1,
        monster = true,
    },
    [15] = {
        thingId = 2669, -- Northern pike
        chance = 30,
        monster = false,
    },
    [16] = {
        thingId = 7158, -- Rainbow trout
        chance = 40,
        monster = false,
    },
    [17] = {
        thingId = 5895, -- fish fin
        chance = 35,
        monster = false,
    },
}

local water = {
    4597, 4598, 4599, 4600, 4601, 4602, 4608,
    4609, 4610, 4611, 4612, 4613, 4614,
    4615, 4616, 4617, 4618, 4619, 4620,
    622
}

local fishableWater = {
    4597, 4598, 4599, 4600, 4601, 4602, 4608, 4611, 4609
}

function Player.fishRandom(self, fRepeat)
    local fMonster = false
    
    for i = 1, #fishableThings do
        local chanceRandom = math.random(1, 1000)
        if (chanceRandom < (fishableThings[i].chance)) then
            if fishableThings[i].monster then
                fMonster = true
            end
            fRepeat = false
            self:finishFishing(fMonster, fishableThings[i].thingId)
            break
        end
    end
    
    if fRepeat then
        self:fishRandom(true)
    end
return true
end

function Player.finishFishing(self, fMonster, resultingId)   
    if fMonster then
        Game.createMonster(resultingId, self:getPosition())
    else
        self:addItem(resultingId, 1)
    end
return true
end

function fishingProcess(playerId, params)
    local player = Player(playerId)
    local target = Tile(params.fishingTargetPosition):getGround()
    if(params.currentPos.x == player:getPosition().x and params.currentPos.y == player:getPosition().y and params.currentPos.z == player:getPosition().z ) then
        if player:getItemCount(WORMID) >= 1 then
            player:addSkillTries(SKILL_FISHING, 3)
            if(math.random(1, 100) < player:getSkillLevel(SKILL_FISHING)) then
                   player:fishRandom(true)
            
                if target:getId() ~= 622 then
                    target:transform(4609, 1)
                end
            end   
            target:decay()
            player:removeItem(WORMID, 1)
            params.wormsUsed = params.wormsUsed + 1
            target:getPosition():sendMagicEffect(2)
            if (getPlayerStorageValue(player:getId(), PlayerStorageKeys.mechanicalFishing) == -1 ) then
                setPlayerStorageValue(player:getId(), PlayerStorageKeys.mechanicalFishing, 1)
            end
            addEvent(fishingProcess, player:getVocation():getAttackSpeed(), player:getId(), params)
            return true
        else
            player:sendTextMessage(MESSAGE_STATUS_WARNING, "Fishing finished. You have used " .. params.wormsUsed .. " worms.")
            setPlayerStorageValue(player:getId(), PlayerStorageKeys.mechanicalFishing, -1)
            return true
        end
    end
    player:sendTextMessage(MESSAGE_STATUS_WARNING, "Fishing interrupted. You have used " .. params.wormsUsed .. " worms.")
    setPlayerStorageValue(player:getId(), PlayerStorageKeys.mechanicalFishing, -1)
    return false
end

function onUse(player, item, fromPosition, target, toPosition)
    if not target:isItem() then
        return false
    end
    
    if not table.contains(water, target:getId()) then
        return false
    end


    if (getPlayerStorageValue(player:getId(), PlayerStorageKeys.mechanicalFishing) ~= -1) then
        player:sendTextMessage(MESSAGE_STATUS_WARNING, "You are already fishing.")
        return false
    end

    if player:getItemCount(WORMID) < 1 then
        player:sendTextMessage(MESSAGE_STATUS_WARNING, "Worm is required to use mechanical fishing rod.")
        return false
    end
    local params = {}
    params.currentPos = player:getPosition()
    params.fishingTargetPosition = target:getPosition()
    params.wormsUsed = 0

    if not Tile(player:getPosition()):hasFlag(TILESTATE_PROTECTIONZONE) then
        player:sendTextMessage(MESSAGE_STATUS_WARNING, "Starting auto fishing with mechanical fishing rod...")
        fishingProcess(player:getId(), params)
        setPlayerStorageValue(player:getId(), PlayerStorageKeys.mechanicalFishing, -1)
    end
return true
end

Don't forget to set you custom Storage ID for fishing process (PlayerStorageKeys.mechanicalFishing).
 
Back
Top