• 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 1.4] Monster Fishing

Itutorial

Excellent OT User
Joined
Dec 23, 2014
Messages
2,307
Solutions
68
Reaction score
982
Based on previous monster fishing codes just converted to revscript

1) Chance to catch monsters when fishing
2) Fish is water, lava, swamp, and tar (level based)
3) Different fishing rods give different chances
4) Higher chance with higher skill level
5) Able to create a fishing scroll that gives higher chance
6) Fishing skill rate changes base on skill level (not the same as default skill leveling process)
7) Different effects when casting based on item and type of fishing.

Lua:
local fishing = Action()
local waterIds = {493, 4608, 4609, 4610, 4611, 4612, 4613, 4614, 4615, 4616, 4617, 4618, 4619, 4620, 4621, 4622, 4623, 4624, 4625, 7236, 10499, 15401, 15402}
local lavaIds = {599, 600, 601, 23846, 23848, 23849, 23850, 23851, 23857, 23858, 23859, 23860, 23868, 23861, 23862, 23863, 23864, 23865, 23866, 23867}
local swampIds = {4691, 4692, 2693, 2694, 2695, 2696, 2697, 2698, 2699, 2700, 2701, 2702, 2703, 2704, 2705, 2706, 2707, 2708, 2709, 2710, 2711, 2712, 4749, 4750, 4751, 4752, 4753, 4754, 4755}
local tarIds = {708}

--[[
level - Level required to catch the fish.
fishing - Fishing level required to catch the fish.
vowel - If the name starts with a vowel set this to true. This is used when broadcasting a message to change a to an.
chance - Chance to catch the fish.
key - Used to store how many fish a player has caught
scroll - If players must have a fishing scroll active to catch the fish
bowlable - Monster is able to be bowled (You will need the bowl code that I release later on set to false for now)
serverBC - Broadcast the catch to all players online
broadcast - The message that will be broadcasted
]]--

local waterMonsters = {
    [1] = {name = "???", level = 10000, vowel = true, fishing = 160, chance = 200, key = 19, scroll = true, bowlable = true, serverBC = true, broadcast = "|PLAYERNAME| has caught an ???!"},
    [2] = {name = "Oceanus", level = 8000, vowel = true, fishing = 150, chance = 1000, key = 18, scroll = true, bowlable = true, serverBC = true, broadcast = "|PLAYERNAME| has caught an Oceanus!"},
    [3] = {name = "Lady Ashzara", level = 7500, fishing = 140, chance = 2500, key = 17, scroll = true, bowlable = true, serverBC = true, broadcast = "A dark figure is rising from the abyssal depths. Lady Ashzara has come for |PLAYERNAME| head!"},
    [4] = {name = "Leviathan", level = 6500, fishing = 145, chance = 5000, key = 16, scroll = true, bowlable = true, serverBC = true, broadcast = "The clouds have begun to darken the skies of Volantis, lightning is striking from all angles. The water around |PLAYERNAME| has turned to steam. The Laviathan has come to break havoc on the land!"},
    [5] = {name = "Kraken", level = 6500, fishing = 140, chance = 10000, key = 15, scroll = true, bowlable = true, serverBC = true, broadcast = "A disastrous entity is drawing near the shores of Volantis as giant tentacles surface from the depths of the ocean. The Kraken has been unleashed upon |PLAYERNAME|!"},
    [6] = {name = "Blastoise", level = 6000, fishing = 140, chance = 20000, key = 14, scroll = false, bowlable = true, serverBC = true, broadcast = "|PLAYERNAME| accidently hit a Blastoise on the head with their hook. Blastoise attacked!"},
    [7] = {name = "Calypso", level = 5500, fishing = 135, chance = 30000, key = 13, scroll = true, bowlable = true, serverBC = true, broadcast = "|PLAYERNAME| fishing line has washed up on the mythical island of Ogygia. Enraged by their filth, Calypso has been released to bring forth ruin!"},
    [8] = {name = "Sobek", level = 5500, fishing = 135, chance = 50000, key = 12, scroll = false, bowlable = true, serverBC = true, broadcast = "A creature has been spotted lurking in the shallows of the Nile! Sobek has emerged to chomp down on |PLAYERNAME|!"},
    [9] = {name = "Jaws", level = 5000, fishing = 130, chance = 90000, key = 11, scroll = false, bowlable = true, serverBC = true, broadcast = "Blood on |PLAYERNAME| hook has lured sharks. Jaws has surfaced!"},
    [10] = {name = "Aekre", level = 4500, vowel = true, fishing = 125, chance = 100000, key = 10, scroll = true, bowlable = true, serverBC = true, broadcast = "The water begins to stir near |PLAYERNAME|! Aekre has emerged from the sea!"},
    [11] = {name = "Nessie", level = 4000, fishing = 125, chance = 200000, key = 9, scroll = false, bowlable = true, serverBC = true, broadcast = "|PLAYERNAME| cast has reached the Isles of Scotland. Nessie the Loch Ness monster has come to defend her territory!"},
    [12] = {name = "Aegaeus", level = 3500, vowel = true, fishing = 120, chance = 300000, key = 8, scroll = true, bowlable = true, serverBC = true, broadcast = "|PLAYERNAME| has angered the sea gods. The sea gods have ordered Aegaeus to slay the land dwellers!"},
    [13] = {name = "Triton", level = 3000, fishing = 120, chance = 500000, key = 7, scroll = false, bowlable = true, serverBC = true, broadcast = "Triton has become very disgruntled due to |PLAYERNAME|!"},
    [14] = {name = "Kingler", level = 2500, fishing = 120, chance = 1000000, key = 6, scroll = true, bowlable = false, serverBC = false, broadcast = "A wild Kingler has appeared. Kingler is attacking |PLAYERNAME|!"},
    [15] = {name = "Doctor Octagonapus", level = 1500, fishing = 110, chance = 1150000, key = 5, scroll = false, bowlable = false, serverBC = false, broadcast = "|PLAYERNAME| is being violently attacked by Doctor Octagonapus!"},
    [16] = {name = "Tyria", level = 750, fishing = 110, chance = 1500000, key = 4, scroll = false, bowlable = false, serverBC = false, broadcast = "Tyria The Sea Goddess has been angered by |PLAYERNAME|!"},
    [17] = {name = "Krabby", level = 500, fishing = 100, chance = 2000000, key = 3, scroll = true, bowlable = false, serverBC = false, broadcast = "A wild Krabby has appeared. Krabby is attacking |PLAYERNAME|!"},
    [18] = {name = "Hydros", level = 400, fishing = 100, chance = 2500000, key = 2, scroll = false, bowlable = false, serverBC = false, broadcast = "A Hydros has been caught by |PLAYERNAME|!"},
    [19] = {name = "Enraged Water Spirit", vowel = true, level = 200, fishing = 100, chance = 5000000, key = 1, scroll = false, bowlable = false}
}

local lavaMonsters = {
    [1] = {name = "Volcanis", level = 7500, fishing = 145, chance = 20000, key = 43, scroll = true, bowlable = true, serverBC = true, broadcast = "How dare you |PLAYERNAME|. Do you think lava is some kind of TOY?!? I will show you how it feels to be burned. I Volcanis will send you to a FIERY GRAVE"},
    [2] = {name = "Molten Fury", level = 7000, fishing = 140, chance = 20000, key = 42, scroll = true, bowlable = true, serverBC = true, broadcast = "|PLAYERNAME| flesh has been seared! A Molten Fury has appeared to scorch the lands!"},
    [3] = {name = "Lavos", level = 6500, fishing = 140, chance = 20000, key = 41, scroll = true, bowlable = true, serverBC = true, broadcast = "The horrid smell of smoke has began to linger around the vicinity of |PLAYERNAME|. Lavos has come for his prey!"},
    [4] = {name = "Pyria", level = 6000, fishing = 140, chance = 20000, key = 40, scroll = false, bowlable = true, serverBC = true, broadcast = "Pyria The Incinerator has entered the mortal realm to immolate |PLAYERNAME|!"},
    [5] = {name = "Hephaestus", level = 5500, fishing = 135, chance = 20000, key = 39, scroll = false, bowlable = true, serverBC = true, broadcast = "A barrage of arrows zooms past |PLAYERNAME| head. Hephaestus has come to test |PLAYERNAME| might!"},
    [6] = {name = "Krakatoa", level = 5000, fishing = 130, chance = 20000, key = 38, scroll = false, bowlable = true, serverBC = true, broadcast = "A Krakatoa has descended upon |PLAYERNAME|!"},
    [7] = {name = "Onyx", level = 4500, fishing = 125, vowel = true, chance = 20000, key = 37, scroll = true, bowlable = true, serverBC = true, broadcast = "The ground around |PLAYERNAME| is torn asunder by a great force from below. Onyx has been unsealed!"},
    [8] = {name = "Engorged Magmaworm", level = 4000, vowel = true, fishing = 125, chance = 20000, key = 36, scroll = false, serverBC = true, bowlable = true, broadcast = "|PLAYERNAME| has caused the lava to spit out a blazing hot Engorged Magmaworm!"},
    [9] = {name = "Chimera", level = 3500, fishing = 120, chance = 20000, key = 35, scroll = true, bowlable = true, serverBC = true, broadcast = "Chimera, the three-headed demon has arose from Hell to obliterate |PLAYERNAME|!"},
    [10] = {name = "Charmander", level = 3000, fishing = 120, chance = 20000, key = 34, scroll = false, bowlable = true, serverBC = true, broadcast = "A wild Charmander appeared! |PLAYERNAME| used tail whip!"},
    [11] = {name = "Ember of Draconis", level = 2500, vowel = true, fishing = 120, chance = 20000, key = 33, scroll = true, bowlable = false, serverBC = false, broadcast = "|PLAYERNAME| has caught an Ember of Draconis"},
    [12] = {name = "Firebat", level = 2500, fishing = 120, chance = 20000, key = 22, scroll = false, bowlable = false, serverBC = false, broadcast = "|PLAYERNAME| is being lit up by a Firebat!"},
    [13] = {name = "Unstable Pyroclast", level = 2000, vowel = true, fishing = 120, chance = 20000, key = 32, scroll = false, bowlable = false, serverBC = false, broadcast = "|PLAYERNAME| has awoken an Unstable Pyroclast!"},
    [14] = {name = "Molten Magma Crab", level = 1500, fishing = 120, chance = 20000, key = 31, scroll = false, bowlable = false, serverBC = false, broadcast = "A Molten Magma Crab has appeared before |PLAYERNAME|!"},
    [15] = {name = "Magma Minion", level = 1000, fishing = 120, chance = 20000, key = 30, scroll = false, bowlable = false}
}

local swampMonsters = {
    [1] = {name = "Swamp Blob", level = 1000, vowel = true, fishing = 120, chance = 100000, key = 60, scroll = true, bowlable = true, serverBC = false, broadcast = "|PLAYERNAME| has caught an Swamp Blob!"},
}

local tarMonsters = {
    [1] = {name = "???", level = 10000, vowel = true, fishing = 140, chance = 200, key = 80, scroll = true, bowlable = true, serverBC = true, broadcast = "|PLAYERNAME| has caught an ???!"},
}

-- Chance to catch monster is (catchMonsterRandom / difficulty) [[Difficulty shown below]]
local catchMonstersRandom = 1000000000

-- Effects shown on water, lava, ect when a players casts (based on the item used to fish)--
local castEffects = {
    [1] = {[2580] = CONST_ME_LOSEENERGY, [10223] = CONST_ME_WATERSPLASH}, -- Water Effects
    [2] = {[2580] = CONST_ME_HITBYFIRE, [10223] = CONST_ME_FIREAREA}, -- Lava Effects
    [3] = {[2580] = CONST_ME_ENERGYHIT, [10223] = CONST_ME_ENERGYAREA}, -- Swamp Effects
    [4] = {[2580] = CONST_ME_LOSEENERGY, [10223] = CONST_ME_WATERSPLASH} -- Tar Effects
}

function fishing.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if not target or not target.itemid then
        return false
    end
    
    if Tile(player:getPosition()):hasFlag(TILESTATE_PROTECTIONZONE) then
        return player:sendCancelMessage("You cannot fish in protection zones.")
    end
    
    -- Check which type of fishing is being done and assign a monster table --
    local fishingMonsters
    local effect
    if isInArray(waterIds, target.itemid) then
        fishingMonsters = waterMonsters
        effect = castEffects[1][itemid]
    elseif isInArray(lavaIds, target.itemid) then
        if player:getSkillLevel(SKILL_FISHING) < 120 then
            return player:sendCancelMessage("You cannot fish in lava until level 120 fishing.")
        end
        fishingMonsters = lavaMonsters
        effect = castEffects[2][itemid]
    elseif isInArray(swampIds, target.itemid) then
        if player:getSkillLevel(SKILL_FISHING) < 120 then
            return player:sendCancelMessage("You cannot fish in swamps until level 120 fishing.")
        end
        fishingMonsters = swampMonsters
        effect = castEffects[3][itemid]
    elseif isInArray(tarIds, target.itemid) then
        if player:getSkillLevel(SKILL_FISHING) < 140 then
            return player:sendCancelMessage("You cannot fish in tar until level 140 fishing.")
        end
        fishingMonsters = tarMonsters
        effect = castEffects[4][itemid]
    end
    
    if not fishingMonsters then
        return false
    end
    
    -- Difficulty based on different items, fishing scroll, and skill level --
    local difficulty = 2.00
    local skillModifier = 0.0
    local itemModifier = 0.0
    if player:getSkillLevel(SKILL_FISHING) > 100 then
        skillModifier = (100 / player:getSkillLevel(SKILL_FISHING))
    end
    
    difficulty = difficulty - math.abs(skillModifier)
    
    if itemid == 10223 then
        itemModifier = 0.25
    end
    
    difficulty = difficulty - math.abs(itemModifier)
    ---------------------------------------------------------------------------

    local realMonsterChance = catchMonstersRandom * difficulty
    
    -- Catch Monsters --
    for i = 1, #fishingMonsters do
        if player:getLevel() >= fishingMonsters[i].level and player:getSkillLevel(SKILL_FISHING) >= fishingMonsters[i].fishing then
            local extraChance = player:getSkillLevel(SKILL_FISHING) * 200
            if Game.randNumbers(realMonsterChance) <= (fishingMonsters[i].chance + extraChance) then
                local MONS = Game.createMonster(fishingMonsters[i].name, player:getPosition(), true, false)
                if MONS then
                    player:addCatch(fishingMonsters[i].key, 1)
                
                    if fishingMonsters[i].broadcast then
                        local msg = fishingMonsters[i].broadcast:gsub("|PLAYERNAME|", player:getName())
                        local players = Game.getPlayers()
                        for x, v in ipairs(players) do
                            v:sendChannelMessage("", msg, TALKTYPE_CHANNEL_O, 9)
                        end
                        if fishingMonsters[i].serverBC then
                            Game.broadcastMessage(msg, MESSAGE_EVENT_ADVANCE)
                        end
                    end
                    
                    if fishingMonsters[i].vowel then 
                        player:sendTextMessage(MESSAGE_INFO_DESCR, "You have caught an "..fishingMonsters[i].name.."!")
                    else
                        player:sendTextMessage(MESSAGE_INFO_DESCR, "You have caught a "..fishingMonsters[i].name.."!")
                    end
                    toPosition:sendMagicEffect(CONST_ME_WATERCREATURE)
                    -FISHINGMONSTERS[MONS:getId()] = {owner = player:getName(), status = 1}
                end
                break
            end
        end
    end
    
    -- Change fishing skill rate based on level --
    if player:getSkillLevel(SKILL_FISHING) < 80 then
        player:addSkillTries(SKILL_FISHING, 5)
    else
        player:addSkillTries(SKILL_FISHING, 1)
    end
    --------------
    
    toPosition:sendMagicEffect(effect)
    return true
end

fishing:allowFarUse(true)
fishing:id(2580)
fishing:id(10223)
fishing:register()
 
Last edited by a moderator:
-BOWLING CODE-
Ability to bowl monsters that are fished by players (or any other monsters that you want) This can easily be configured for a pokemon type server.

You can also release the monsters from the bowl if not in a protection zone and there is enough room for it to spawn.
Add this inside your global.lua (or any global lib file)
Lua:
FISHINGMONSTERS = {}

Bowl itemids are 5928 5929
Lua:
local bowl = Action()

local monsters = {
    [1] = {name = "Triton", aid = 2000, plural = "a Triton"},
    [2] = {name = "Aegaeus", aid = 2001, plural = "an Aegaeus"},
}

function bowl.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if not target or not target:isMonster() then
        return false
    end
 
    local MONS = nil
 
    for i = 1, #monsters do
        if target:getName() == monsters[i].name then
            MONS = monsters[i]
            break
        end
    end
 
    if not MONS then
        return player:sendCancelMessage("You cannot bowl that monster.")
    end
 
    if FISHINGMONSTERS[target:getId()] then
        if FISHINGMONSTERS[target:getId()].owner ~= player:getName() then
            return player:sendCancelMessage("That is not yours to bowl.")
        end
    else
        if player:getAccountType() < ACCOUNT_TYPE_GOD then
            return player:sendCancelMessage("That is not yours to bowl.")
        end
    end
 
    FISHINGMONSTERS[target:getId()] = nil
    target:remove()
    item:transform(5929)
    item:setAttribute("description", "It contains "..MONS.plural..".")
    item:setAttribute("aid", MONS.aid)
    return true
end

bowl:id(5928)
bowl:register()

local unBowl = Action()
function unBowl.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local MONS = nil
    for i = 1, #monsters do
        if item.actionid == monsters[i].aid then
            MONS = monsters[i]
            break
        end
    end
 
    if not MONS then return false end
 
    local pos = item:getPosition()
 
    local MONSTER = Game.createMonster(MONS.name, pos)
 
    if MONSTER then
        FISHINGMONSTERS[MONSTER:getId()] = {owner = player:getName(), status = 2}
        item:remove(1)
    else
        return player:sendCancelMessage("Could not unbowl monster.")
    end
    return true
end

unBowl:id(5929)
unBowl:register()

Also add this in events/player.lua onLook
Lua:
if thing:isMonster() then
        if FISHINGMONSTERS[thing:getId()] then
            if FISHINGMONSTERS[thing:getId()].status == 1 then
                description = description.."\n It was caught by "..FISHINGMONSTERS[thing:getId()].owner.."."
            else
                description = description.."\n It was released by "..FISHINGMONSTERS[thing:getId()].owner.."."
            end
        end
    end

It will allow you to look at the bowl and see whats inside and who owns the fish.
Post automatically merged:

To add player catches create a new table in your database and name it player_catchs
It should have 3 values name, key, value

Name is the players name, key is the fishes identifier, and value is the amount of fish they caught.

add this in lib/core/player.lua
Lua:
function Player.addCatch(self, key, amount)
    local query = db.storeQuery("SELECT `key` FROM `player_catchs` WHERE `key` = "..key.." AND `name` = '"..self:getName().."';")
 
    if not query then return false end
 
    local ret = result.getNumber(query, "key")
    result.free(query)
 
    if not ret or ret == nil or ret <= 0 then
        return db.query("INSERT INTO `player_catchs` (`name`, `key`, `value`) VALUES ('"..self:getName().."', "..key..", 1);")
    else
        return db.query("UPDATE `player_catchs` SET `value` = `value` + "..amount.." WHERE `key` = "..key.." and `name` = '"..self:getName().."';")
    end
end

Post automatically merged:

TALKACTION FOR PLAYERS TO SEE WHEN THEY CAN CATCH FISH
Lua:
local fishing = TalkAction("!fishing")

local monsters = {
    [1] = {name = "Enraged Water Spirit", level = 200, fishing = 100, scroll = false},
 
    [2] = {name = "Magma Minion", level = 1000, fishing = 120, scroll = false},
 
    [3] = {name = "Swamp Blob", level = 1000, fishing = 120, scroll = false},
 
    [4] = {name = "Tar Blob", level = 1000, fishing = 120, scroll = false}
}

function fishing.onSay(player, words, param)
    local text = "[Monster Fishing]\nName - Level - Fishing level - scroll\n\n[Water Monsters]\n"
 
    for i = 1, #monsters do
        if monsters[i].scroll then
            text = text..""..monsters[i].name..": "..monsters[i].level.."/"..monsters[i].fishing.."/yes\n"
        else
            text = text..""..monsters[i].name..": "..monsters[i].level.."/"..monsters[i].fishing.."/no\n"
        end

         -- Change 2, 3, 4 to whenever the next set of fish are for different fishing types --
        if i == 2 then
            text = text.."\n[Lava Monsters]\n"
        end
   
        if i == 3 then
            text = text.."\n[Swamp Monsters]\n"
        end
   
        if i == 4 then
            text = text.."\n[Tar Monsters]\n"
        end
    end

    player:showTextDialog(2580, text)
    return false
end

fishing:separator(" ")
fishing:register()

TALKACTION FOR PLAYERS TO CHECK THEIR OWN OR OTHER PEOPLES CATCHS

Add this is lib/core/player.lua
Lua:
function Player.getCatch(self, key)
    local query = db.storeQuery("SELECT `key` FROM `player_catchs` WHERE `key` = "..key.." AND `name` = '"..self:getName().."';")
 
    if not query then return false end
 
    local ret = result.getNumber(query, "key")
    result.free(query)
    return ret
end

Add this in global.lua
Lua:
function isRealPlayer(name)
    local query = db.storeQuery("SELECT id FROM `players` WHERE name = '"..name.."';")
    if not query then
        return false
    end
 
    local ret = result.getNumber(query, "id")
    result.free(query)
 
    if not ret or ret < 0 then
        return false
    end
    return true
end

and this is the talkaction
Lua:
local catchs = TalkAction("!catchs")

local monsters = {
    -- Water Fish --
    [1] = {name = "Enraged Water Spirit", key = 1},

    -- Lava Fish --
    [2] = {name = "Magma Minion", key = 19},

    -- Swamp Fish --
    -[3] = {name = "Volcanis", key = 50},
 
    -- Tar Fish --
    -[4] = {name = "Volcanis", key = 70}
}

function catchs.onSay(player, words, param)
    local target = nil
 
    if not param or param == "" then
        target = player:getName()
    else
        target = param
    end
 
    if not isRealPlayer(target) then
        player:sendCancelMessage("Player does not exist.")
        return false
    end
 
    local text = "["..target.." Catchs]\n\n"
 
    text = text.."--[Water Fishing]--\n"
 
    for i = 1, #monsters do
        local info = player:getCatch(self, monsters[i].key)
        if not info or info == nil or info == -1 then
            player:addCatch(monsters[i].key, 1)
        end
     
        -- Change 2, 3, 4 to whenever the next set of fish are for different fishing types --
        if i == 2 then
            text = text.."\n--[Lava Fishing]--\n"
        end
     
        if i == 3 then
            text = text.."\n--[Swamp Fishing]--\n"
        end
     
        if i == 4 then
            text = text.."\n--[Tar Fishing]--\n"
        end
     
        text = text.."["..monsters[i].name.."]: "..player:getCatch(self, monsters[i].key).."\n"
    end
 

    player:showTextDialog(2580, text)
    return false
end

catchs:separator(" ")
catchs:register()

I hope you guys enjoy (whoever uses it) let me know if you need help with anything or have any issues. This is a pretty big system so sorry for all the work to get it going.
 
Last edited:
Insane script, you delivered a totally complete system, huge props to you.
 
I noticed there is an issue in the fishing code. I didn't remove both - from a comment.

Lua:
-FISHINGMONSTERS[MONS:getId()] = {owner = player:getName(), status = 1}

remove the - before FISHINGMONSTERS
 
A mod accidentally removed line 162 so make sure you add
Lua:
FISHINGMONSTERS[MONS:getId()] = {owner = player:getName(), status = 1}

under line 161

P.S. I forgot to mention that you can create a chatchannel with id 9 that players can see the fishing catchs in.

Lua:
function onSpeak(player, type, message)
    player:sendCancelMessage("You cannot speak in this channel.")
    return false
end
 
Just a warning to anyone that may use this script in the future, also a note to the author:

The isRealPlayer(player) function is potentially vulnerable to a SQL injection as it doesn't sanitize the "param" input which is fed directly into a SQL query.

Other SQL queries in this system are also potentially vulnerable, but not as easily.

If you're going to use this system, be sure to replace all variables in queries with db.escapeString(variableName).

PS. The below code never does anything as itemid is not defined.

Lua:
if itemid == 10223 then
    itemModifier = 0.25
end
 
For anyone thinking about using this, please be careful using this due to SQL injection vulnerability. Huge yikes.
 
Id be more worried about your SQL injection vulnerability tbh
I can't modify the original post. Anyone that wants to fix it can. How about you come on my test server and show me the vulnerability in real-time.

I have always said and maintained I don't release perfect code. There are a few people (who usually already know this stuff) that actually deserve perfect code on most of these open sights. Most the people that use free codes are trying to copy paste a server to make money. This has been known for a long time.

You must be mad Alex that I released a code that is actually pretty close to being complete to the code you run on your server. I am sure there are differences but not much and not anything I couldn't replicate in 10 minutes. Why don't you guys remove the fishing hotspot idea you got from me.
 
Last edited:
I can't modify the original post. Anyone that wants to fix it can. How about you come on my test server and show me the vulnerability in real-time.

I have always said and maintained I don't release perfect code. There are a few people (who usually already know this stuff) that actually deserve perfect code on most of these open sights. Most the people that use free codes are trying to copy paste a server to make money. This has been known for a long time.

You must be mad Alex that I released a code that is actually pretty close to being complete to the code you run on your server. I am sure there are differences but not much and not anything I couldn't replicate in 10 minutes. Why don't you guys remove the fishing hotspot idea you got from me.
Not mad at all, just putting it out there for the benefit of whoever may stumble across this code and decide to implement it. There was no malice or hate intended.
 
I can't modify the original post. Anyone that wants to fix it can.

If you have a fix for it you can report the main post with it and a moderator will edit the post for you.
 
did I add them wrong?

CREATE TABLE player_catchs (
name varchar(255) NOT NULL default '0',
value int(11) NOT NULL default '0',
key int(11) NOT NULL default '0',
);
 
Last edited:
adicionei errado?

CRIAR TABELA player_catchs (
nome varchar(255) NOT NULL default '0',
valor int(11) NOT NULL padrão '0',
chave int(11) NOT NULL padrão '0',
);

CREATE TABLE player_catchs(
name VARCHAR(255) NOT NULL,
key INT NOT NULL,
value INT NOT NULL
);

u inside in wrong order
Post automatically merged:

Also add this in events/player.lua onLook
Lua:
function Player.addCatch(self, key, amount)
    local query = db.storeQuery("SELECT `key` FROM `player_catchs` WHERE `key` = "..key.." AND `name` = '"..self:getName().."';")
 
    if not query then return false end
 
    local ret = result.getNumber(query, "key")
    result.free(query)
 
    if not ret or ret == nil or ret <= 0 then
        return db.query("INSERT INTO `player_catchs` (`name`, `key`, `value`) VALUES ('"..self:getName().."', "..key..", 1);")
    else
        return db.query("UPDATE `player_catchs` SET `value` = `value` + "..amount.." WHERE `key` = "..key.." and `name` = '"..self:getName().."';")
    end
end

In this part, not working for me..
I change for this:

Lua:
function Player.addCatch(self, key, amount)
    local query = db.storeQuery("SELECT `key` FROM `player_catchs` WHERE `key` = "..key.." AND `name` = '"..self:getName().."';")
 
    if query == nil then return false end --changed this line
 
    local ret = result.getNumber(query, "key")
    result.free(query)
 
    if not ret or ret == nil or ret <= 0 then
        return db.query("INSERT INTO `player_catchs` (`name`, `key`, `value`) VALUES ('"..self:getName().."', "..key..", 1);")
    else
        return db.query("UPDATE `player_catchs` SET `value` = `value` + "..amount.." WHERE `key` = "..key.." and `name` = '"..self:getName().."';")
    end
end
 
Last edited:
@Itutorial I think what you mention @amgau is this:
1667541028375.png

1667540990734.png
I don't know how serious this is, but you could put some funny stuff in the message.
It's basically letting players enter text into the SQL string it's trying to execute.

however this code is wrong so it's not the only thing you need to worry about.
1667541374179.png
try to test your scripts before publishing and check the console for possible errors.
 
@Sarah Wesker, @Itutorial or can someone help me with this?

I have this as a result after some changes as the original code is also wrong.

But I'm not thinking about thinking the logic to work in the list of various monsters.

The code follows below.
1667618594832.png


Lua:
local fishing = TalkAction("!fishing")
local monsters = {
    [1] = {type = 'Water', name = "Enraged Water Spirit", level = 200, fishing = 100, scroll = true, bowlable = 'yes'},
 
    [2] = {type = 'Lava', name = "Magma Minion", level = 1000, fishing = 120, scroll = false, bowlable = 'yes'},
 
    [3] = {type = 'Swamp', name = "Swamp Blob", level = 1000, fishing = 120, scroll = false, bowlable = 'yes'},
 
    [4] = {type = 'Tar', name = "Tar Blob", level = 1000, fishing = 120, scroll = false, bowlable = 'yes'}
}
function fishing.onSay(player, words, param)
    local text = ""
 
    for i = 1, #monsters do
        if monsters then
            text = monsters[i].name.."\n".."lvl: "..monsters[i].level.." - ".."skill: "..monsters[i].fishing.." - ".."bowlable: "..monsters[i].bowlable.. " \n\n"..text
        end
        if i == 1 then
            text = "\n[Water Monsters]\n"..text
        end
        if i == 2 then
            text = "\n[Lava Monsters]\n"..text
        end
 
        if i == 3 then
            text = "\n[Swamp Monsters]\n"..text
        end
 
        if i == 4 then
            text = "\n[Tar Monsters]\n"..text
        end
    end
    player:showTextDialog(2580, text)
    return false
end
fishing:separator(" ")
fishing:register()
Post automatically merged:

To update ur code @Itutorial

-- Bowling System
function Player.addCatch(self, key, amount)
local query = db.storeQuery("SELECT key FROM player_catchs WHERE key = " .. db.escapeString(key) .." AND name = " .. db.escapeString(self:getName()) .. ";")

if query == nil then return false end

local ret = result.getNumber(query, "key")
result.free(query)

if not ret or ret == nil or ret <= 0 then
return db.query("INSERT INTO player_catchs (name, key, value) VALUES (" .. db.escapeString(self:getName()) .. ", ".. db.escapeString(key) ..", 1);")
else
return db.query("UPDATE player_catchs SET value = value + ".. db.escapeString(amount) .." WHERE key = ".. db.escapeString(key) .." and name = " .. db.escapeString(self:getName()) .. ";")
end
end
 
Back
Top