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

Simple Fishing System Request

froie

Expert Mapper
Joined
May 27, 2013
Messages
196
Reaction score
4
Location
Canada
Hello, I was wondering if someone could help me find, or create a simple script for fishing. I have looked all over and tried many but none have worked so far for my server.
I use The Forgotten Server, version 0.3.7_SVN (Crying Damson) Client version 10.10

The fishing system I am looking for is plain and simple. I would like to use a normal fishing rod on water, and upon doing that you have a chance to catch 1 of the many fish such as ID 2667, 2669, 7158, 7159 and 15405
but I don't want to catch a fish every time, I want them to have a percentage to catch for example:

(fish) 2667 - 50% chance
(northern pike) 2669 - 30% chance
(rainbow trout) 7158 - 10% chance
(green pearch) 7159 - 5% chance
(sandfish) 15405 - 3% chance
(Giant shimmering pearl) 7632 - 1% chance

If possible I would like it to consume worms with each use, and also a chance for the fishing rod to break maybe 1/20 uses.

Any help is appreciated, I have searched to my best of knowledge and I don't have much knowledge with scripting. Thanks in advance
 
Solution
Thanks! that would be greatly appreciated.

Try this one homie.

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}

math.randomseed(os.time())
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local fishSkill = getPlayerSkillLevel(cid, SKILL_FISHING)
    local fishChance = math.random(1, fishSkill)
    local wormCheck = false

    if isInArray(waterIds, itemEx.itemid) then
        if math.random(1, 100) <= math.min(math.max(10 + (fishSkill - 10) * 0.597, 10), 50) then
            if itemEx.itemid ~= 493 then
                if useWorms and getPlayerItemById(cid, true, 3976) then
                    wormCheck =...
Hello, I was wondering if someone could help me find, or create a simple script for fishing. I have looked all over and tried many but none have worked so far for my server.
I use The Forgotten Server, version 0.3.7_SVN (Crying Damson) Client version 10.10

The fishing system I am looking for is plain and simple. I would like to use a normal fishing rod on water, and upon doing that you have a chance to catch 1 of the many fish such as ID 2667, 2669, 7158, 7159 and 15405
but I don't want to catch a fish every time, I want them to have a percentage to catch for example:

(fish) 2667 - 50% chance
(northern pike) 2669 - 30% chance
(rainbow trout) 7158 - 10% chance
(green pearch) 7159 - 5% chance
(sandfish) 15405 - 3% chance
(Giant shimmering pearl) 7632 - 1% chance

If possible I would like it to consume worms with each use, and also a chance for the fishing rod to break maybe 1/20 uses.

Any help is appreciated, I have searched to my best of knowledge and I don't have much knowledge with scripting. Thanks in advance

Here's the one I was talking about, updated cause the other was trash I made months ago, hope this ones better!

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}

math.randomseed(os.time())
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local player = Player(cid)
    local fishSkill = player:getSkillLevel(SKILL_FISHING)
    local fishChance = math.random(1, fishSkill)
    local wormCheck = false

    if isInArray(waterIds, itemEx:getId()) then
        if math.random(1, 100) <= math.min(math.max(10 + (fishSkill - 10) * 0.597, 10), 50) then
            if itemEx.itemid ~= 493 then
                if useWorms and player:getItemById(3976, true) then
                    wormCheck = true
                elseif not useWorms then
                    wormCheck = true
                end

                if wormCheck then
                    if fishChance < 15 then
                        player:addItem(2670, 1)
                    elseif fishChance > 14 and fishChance < 30 then
                        player:addItem(2667, 1)
                    elseif fishChance > 29 and fishChance < 45 then
                        player:addItem(7159, 1)
                    elseif fishChance > 44 and fishChance < 60 then
                        player:addItem(2669, 1)
                    elseif fishChance > 59 and fishChance < 75 then
                        player:addItem(7158, 1)
                    elseif fishChance > 74 and fishChance < 90 then
                        player:addItem(15405, 1)
                    elseif fishChance > 89 then
                        player:addItem(7963, 1)
                    end

                    if useWorms then
                        player:removeItem(3976, 1)
                    end
                end
            end
        end
        player:addSkillTries(SKILL_FISHING, 1)
        toPosition:sendMagicEffect(CONST_ME_LOSEENERGY)
        return true
    end
    return false
end
 
[12:27:39.899] [Error - Action Interface]
[12:27:39.906] data/actions/scripts/tools/fishing.lua:eek:nUse
[12:27:39.908] Description:
[12:27:39.915] data/actions/scripts/tools/fishing.lua:6: attempt to call global 'Player' (a nil value)
[12:27:39.919] stack traceback:
[12:27:39.922] data/actions/scripts/tools/fishing.lua:6: in function <data/actions/scripts/tools/fishing.lua:5>
 
[12:27:39.899] [Error - Action Interface]
[12:27:39.906] data/actions/scripts/tools/fishing.lua:eek:nUse
[12:27:39.908] Description:
[12:27:39.915] data/actions/scripts/tools/fishing.lua:6: attempt to call global 'Player' (a nil value)
[12:27:39.919] stack traceback:
[12:27:39.922] data/actions/scripts/tools/fishing.lua:6: in function <data/actions/scripts/tools/fishing.lua:5>

Seems like something with the server distro, most would say to upgrade to latest tfs but I guess you can try it this way. But I'm not sure how your distro works really.

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}

math.randomseed(os.time())
function onUse(player, item, fromPosition, itemEx, toPosition)
    local fishSkill = player:getSkillLevel(SKILL_FISHING)
    local fishChance = math.random(1, fishSkill)
    local wormCheck = false
    if isInArray(waterIds, itemEx:getId()) then
        if math.random(1, 100) <= math.min(math.max(10 + (fishSkill - 10) * 0.597, 10), 50) then
            if itemEx.itemid ~= 493 then
                if useWorms and player:getItemById(3976, true) then
                    wormCheck = true
                elseif not useWorms then
                    wormCheck = true
                end
                if wormCheck then
                    if fishChance < 15 then
                        player:addItem(2670, 1)
                    elseif fishChance > 14 and fishChance < 30 then
                        player:addItem(2667, 1)
                    elseif fishChance > 29 and fishChance < 45 then
                        player:addItem(7159, 1)
                    elseif fishChance > 44 and fishChance < 60 then
                        player:addItem(2669, 1)
                    elseif fishChance > 59 and fishChance < 75 then
                        player:addItem(7158, 1)
                    elseif fishChance > 74 and fishChance < 90 then
                        player:addItem(15405, 1)
                    elseif fishChance > 89 then
                        player:addItem(7963, 1)
                    end
                    if useWorms then
                        player:removeItem(3976, 1)
                    end
                end
            end
        end
        player:addSkillTries(SKILL_FISHING, 1)
        toPosition:sendMagicEffect(CONST_ME_LOSEENERGY)
        return true
    end
    return false
end
 
Seems like something with the server distro, most would say to upgrade to latest tfs but I guess you can try it this way. But I'm not sure how your distro works really.

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}

math.randomseed(os.time())
function onUse(player, item, fromPosition, itemEx, toPosition)
    local fishSkill = player:getSkillLevel(SKILL_FISHING)
    local fishChance = math.random(1, fishSkill)
    local wormCheck = false
    if isInArray(waterIds, itemEx:getId()) then
        if math.random(1, 100) <= math.min(math.max(10 + (fishSkill - 10) * 0.597, 10), 50) then
            if itemEx.itemid ~= 493 then
                if useWorms and player:getItemById(3976, true) then
                    wormCheck = true
                elseif not useWorms then
                    wormCheck = true
                end
                if wormCheck then
                    if fishChance < 15 then
                        player:addItem(2670, 1)
                    elseif fishChance > 14 and fishChance < 30 then
                        player:addItem(2667, 1)
                    elseif fishChance > 29 and fishChance < 45 then
                        player:addItem(7159, 1)
                    elseif fishChance > 44 and fishChance < 60 then
                        player:addItem(2669, 1)
                    elseif fishChance > 59 and fishChance < 75 then
                        player:addItem(7158, 1)
                    elseif fishChance > 74 and fishChance < 90 then
                        player:addItem(15405, 1)
                    elseif fishChance > 89 then
                        player:addItem(7963, 1)
                    end
                    if useWorms then
                        player:removeItem(3976, 1)
                    end
                end
            end
        end
        player:addSkillTries(SKILL_FISHING, 1)
        toPosition:sendMagicEffect(CONST_ME_LOSEENERGY)
        return true
    end
    return false
end

0.3.7 = 0.3.6
So you have to use the legacy functions.
 
Thanks! that would be greatly appreciated.

Try this one homie.

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}

math.randomseed(os.time())
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local fishSkill = getPlayerSkillLevel(cid, SKILL_FISHING)
    local fishChance = math.random(1, fishSkill)
    local wormCheck = false

    if isInArray(waterIds, itemEx.itemid) then
        if math.random(1, 100) <= math.min(math.max(10 + (fishSkill - 10) * 0.597, 10), 50) then
            if itemEx.itemid ~= 493 then
                if useWorms and getPlayerItemById(cid, true, 3976) then
                    wormCheck = true
                elseif not useWorms then
                    wormCheck = true
                end

                if wormCheck then
                    if fishChance < 15 then
                        doPlayerAddItem(cid, 2670, 1)
                    elseif fishChance > 14 and fishChance < 30 then
                        doPlayerAddItem(cid, 2667, 1)
                    elseif fishChance > 29 and fishChance < 45 then
                        doPlayerAddItem(cid, 7159, 1)
                    elseif fishChance > 44 and fishChance < 60 then
                        doPlayerAddItem(cid, 2669, 1)
                    elseif fishChance > 59 and fishChance < 75 then
                        doPlayerAddItem(cid, 7158, 1)
                    elseif fishChance > 74 and fishChance < 90 then
                        doPlayerAddItem(cid, 15405, 1)
                    elseif fishChance > 89 then
                        doPlayerAddItem(cid, 7963, 1)
                    end

                    if useWorms then
                        doPlayerRemoveItem(cid, 3976, 1)
                    end
                end
            end
        end

        doPlayerAddSkillTry(cid, SKILL_FISHING, 1)
        doSendMagicEffect(toPosition, CONST_ME_LOSEENERGY)
        return true
    end
    return false
end
 
Last edited:
Solution
wow it works perfectly!!! thank you so much man, no errors at all. If I wanted to make the chances of them dropping lower how would I do that, I am not entirely sure I understand how those numbers work in the script, I see many. And REP for you :) thanks again for the help
 
wow it works perfectly!!! thank you so much man, no errors at all. If I wanted to make the chances of them dropping lower how would I do that, I am not entirely sure I understand how those numbers work in the script, I see many. And REP for you :) thanks again for the help

This part is basically choosing a random number between one and your maximum fishing skill level. So if you are fishing level 50 it will never exceed 50.
Lua:
    local fishSkill = getPlayerSkillLevel(cid, SKILL_FISHING)
    local fishChance = math.random(1, fishSkill)

Then these parts control what's gonna drop, you can change any of the numbers within the if and elseif lines.
Lua:
                    if fishChance < 15 then
                        doPlayerAddItem(cid, 2670, 1)
                    elseif fishChance > 14 and fishChance < 30 then
                        doPlayerAddItem(cid, 2667, 1)
                    elseif fishChance > 29 and fishChance < 45 then
                        doPlayerAddItem(cid, 7159, 1)
                    elseif fishChance > 44 and fishChance < 60 then
                        doPlayerAddItem(cid, 2669, 1)
                    elseif fishChance > 59 and fishChance < 75 then
                        doPlayerAddItem(cid, 7158, 1)
                    elseif fishChance > 74 and fishChance < 90 then
                        doPlayerAddItem(cid, 15405, 1)
                    elseif fishChance > 89 then
                        doPlayerAddItem(cid, 7963, 1)
                    end

For instance, if you wanted it to be easier to obtain better fish then do something like this.

Lua:
                    if fishChance < 10 then
                        doPlayerAddItem(cid, 2670, 1)
                    elseif fishChance > 9 and fishChance < 25 then
                        doPlayerAddItem(cid, 2667, 1)
                    elseif fishChance > 24 and fishChance < 40 then
                        doPlayerAddItem(cid, 7159, 1)
                    elseif fishChance > 39 and fishChance < 55 then
                        doPlayerAddItem(cid, 2669, 1)
                    elseif fishChance > 54 and fishChance < 70 then
                        doPlayerAddItem(cid, 7158, 1)
                    elseif fishChance > 69 and fishChance < 85 then
                        doPlayerAddItem(cid, 15405, 1)
                    elseif fishChance > 84 then
                        doPlayerAddItem(cid, 7963, 1)
                    end

Lastly, if you want to do the break chance deal I suppose you could do something like this (add after line 5)

Lua:
if math.random(1, 20) == 1 then
    doPlayerRemoveItem(cid, item.itemid, 1)
    doSendMagicEffect(getPlayerPosition(cid), CONST_ME_BLOCKHIT)
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your fishing rod broke!")
    return true
end
 
Last edited:
Try this one homie.

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}

math.randomseed(os.time())
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local fishSkill = getPlayerSkillLevel(cid, SKILL_FISHING)
    local fishChance = math.random(1, fishSkill)
    local wormCheck = false

    if isInArray(waterIds, itemEx.itemid) then
        if math.random(1, 100) <= math.min(math.max(10 + (fishSkill - 10) * 0.597, 10), 50) then
            if itemEx.itemid ~= 493 then
                if useWorms and getPlayerItemById(cid, true, 3976) then
                    wormCheck = true
                elseif not useWorms then
                    wormCheck = true
                end

                if wormCheck then
                    if fishChance < 15 then
                        doPlayerAddItem(cid, 2670, 1)
                    elseif fishChance > 14 and fishChance < 30 then
                        doPlayerAddItem(cid, 2667, 1)
                    elseif fishChance > 29 and fishChance < 45 then
                        doPlayerAddItem(cid, 7159, 1)
                    elseif fishChance > 44 and fishChance < 60 then
                        doPlayerAddItem(cid, 2669, 1)
                    elseif fishChance > 59 and fishChance < 75 then
                        doPlayerAddItem(cid, 7158, 1)
                    elseif fishChance > 74 and fishChance < 90 then
                        doPlayerAddItem(cid, 15405, 1)
                    elseif fishChance > 89 then
                        doPlayerAddItem(cid, 7963, 1)
                    end

                    if useWorms then
                        doPlayerRemoveItem(cid, 3976, 1)
                    end
                end
            end
        end

        doPlayerAddSkillTry(cid, SKILL_FISHING, 1)
        doSendMagicEffect(toPosition, CONST_ME_LOSEENERGY)
        return true
    end
    return false
end
This work in 1.4.2 ?:D
 
This work in 1.4.2 ?:D
this one should work:

Lua:
local waterIds = {493, 4608, 4609, 4610, 4611, 4612, 4613, 4614, 4615, 4616, 4617, 4618, 4619, 4620, 4621, 4622, 4623, 4624, 4625, 7236}
local useWorms = true


function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local targetId = target.itemid
    if not table.contains(waterIds, targetId) then
        return false
    end

    local fishChance = math.random(1, player:getSkillLevel(SKILL_FISHING))

    toPosition:sendMagicEffect(CONST_ME_LOSEENERGY)
    player:addSkillTries(SKILL_FISHING, 1)
    if math.random(1, 100) <= math.min(math.max(10 + (player:getEffectiveSkillLevel(SKILL_FISHING) - 10) * 0.597, 10), 50) then
        if useWorms and not player:removeItem(3976, 1) then
            return true
        end

        if fishChance < 15 then
            player:addItem(2670, 1)
        elseif fishChance > 14 and fishChance < 30 then
            player:addItem(2667, 1)
        elseif fishChance > 29 and fishChance < 45 then
            player:addItem(7159, 1)
        elseif fishChance > 44 and fishChance < 60 then
            player:addItem(2669, 1)
        elseif fishChance > 59 and fishChance < 75 then
            player:addItem(7158, 1)
        elseif fishChance > 74 and fishChance < 90 then
            player:addItem(15405, 1)
        elseif fishChance > 89 then
            player:addItem(7963, 1)
        end
    end
    return true
end
 
this one should work:

Lua:
local waterIds = {493, 4608, 4609, 4610, 4611, 4612, 4613, 4614, 4615, 4616, 4617, 4618, 4619, 4620, 4621, 4622, 4623, 4624, 4625, 7236}
local useWorms = true


function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local targetId = target.itemid
    if not table.contains(waterIds, targetId) then
        return false
    end

    local fishChance = math.random(1, player:getSkillLevel(SKILL_FISHING))
    local breakRodChance = math.random(1, 100)

    toPosition:sendMagicEffect(CONST_ME_LOSEENERGY)
    player:addSkillTries(SKILL_FISHING, 1)
    if math.random(1, 100) <= math.min(math.max(10 + (player:getEffectiveSkillLevel(SKILL_FISHING) - 10) * 0.597, 10), 50) then
        if useWorms and not player:removeItem(3976, 1) then
            return true
        end
       
        if breakRodChance < 15 then
            item:remove()
            player:sendTextMessage(MESSAGE_STATUS_SMALL, "Your fishing rod broke.")
            return true
        end
       
        if fishChance < 15 then
            player:addItem(2670, 1)
        elseif fishChance > 14 and fishChance < 30 then
            player:addItem(2667, 1)
        elseif fishChance > 29 and fishChance < 45 then
            player:addItem(7159, 1)
        elseif fishChance > 44 and fishChance < 60 then
            player:addItem(2669, 1)
        elseif fishChance > 59 and fishChance < 75 then
            player:addItem(7158, 1)
        elseif fishChance > 74 and fishChance < 90 then
            player:addItem(15405, 1)
        elseif fishChance > 89 then
            player:addItem(7963, 1)
        end
    end
    return true
end
how change it to dont break? i see "if breakRodChance < 15 then "
 
Back
Top