silveralol
Advanced OT User
- Joined
- Mar 16, 2010
- Messages
- 1,480
- Solutions
- 9
- Reaction score
- 211
i get a error in line 135, with "bosses"
Could you post the error along with your config?i get a error in line 135, with "bosses"
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 lootTrash = {2234, 2238, 2376, 2509, 2667}
local lootCommon = {2152, 2167, 2168, 2669, 7588, 7589}
local lootRare = {2143, 2146, 2149, 7158, 7159}
local lootVeryRare = {7632, 7633, 10220}
local useWorms = true
-- Config for monster fishing
local config = {
enabled = true, -- enable or disable monster fishing
debug = false, -- enable debug messages in console
verifyMonsters = true, -- disable this if you are having problems with Monster fishing::Warning - Invalid monster name
chance = 50, -- chance to catch a monster in % - 50 means you have a 50/50 chance of getting a monster or a fish
bossLevel = 300, -- min level to catch a "boss"
bossSkill = 90, -- min fishing skill to catch a "boss"
monsters = {
-- [minLevel] = {"monster", "names", "for", "level"}
[100] = {"Quara Hydromancer", "Quara Constrictor", "Quara Mantassin"},
[150] = {"Water Elemental", "Massive Water Elemental"},
[200] = {"Quara Pincher", "Quara Predator"},
[300] = {"Sea Serpent"},
},
bosses = {
-- Monsters that can only be caught with atleast "bossLevel" and "bossSkill"
"Leviathan",
}
}
-- Validate monsters configuration
if config.verifyMonsters then
local m = {}
for minLevel, monsters in pairs(config.monsters) do
m[minLevel] = {}
if config.debug then print("#monsters", #monsters) end
for i = 1, #monsters do
if MonsterType(monsters[i]) then
table.insert(m[minLevel], monsters[i])
else
print("Monster fishing::Warning - Invalid monster name:", monsters[i])
end
end
if config.debug then print("Monster fishing::Debug - #monsters added", #m[minLevel]) end
end
config.monsters = m
end
function onUse(player, item, fromPosition, itemEx, toPosition, isHotkey)
local targetId = itemEx.itemid
if not isInArray(waterIds, itemEx.itemid) then
return false
end
if targetId == 10499 then
local targetItem = Item(itemEx.uid)
local owner = targetItem:getAttribute(ITEM_ATTRIBUTE_CORPSEOWNER)
if owner ~= 0 and owner ~= player:getId() then
player:sendTextMessage(MESSAGE_STATUS_SMALL, "You are not the owner.")
return true
end
toPosition:sendMagicEffect(CONST_ME_WATERSPLASH)
targetItem:remove()
local rareChance = math.random(1, 100)
if rareChance == 1 then
player:addItem(lootVeryRare[math.random(#lootVeryRare)], 1)
elseif rareChance <= 3 then
player:addItem(lootRare[math.random(#lootRare)], 1)
elseif rareChance <= 10 then
player:addItem(lootCommon[math.random(#lootCommon)], 1)
else
player:addItem(lootTrash[math.random(#lootTrash)], 1)
end
return true
end
if targetId ~= 7236 then
toPosition:sendMagicEffect(CONST_ME_LOSEENERGY)
end
if targetId == 493 or targetId == 15402 then
return true
end
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("worm", 1) then
return true
end
if targetId == 15401 then
local targetItem = Item(itemEx.uid)
targetItem:transform(targetId + 1)
targetItem:decay()
if math.random(1, 100) >= 97 then
player:addItem(15405, 1)
return true
end
elseif targetId == 7236 then
local targetItem = Item(itemEx.uid)
targetItem:transform(targetId + 1)
targetItem:decay()
local rareChance = math.random(1, 100)
if rareChance == 1 then
player:addItem(7158, 1)
return true
elseif rareChance <= 4 then
player:addItem(2669, 1)
return true
elseif rareChance <= 10 then
player:addItem(7159, 1)
return true
end
end
if config.enabled and math.random(100) <= config.chance then
print("#tmpMonsters: "..#tmpMonsters)
local level = player:getLevel()
local skill = player:getSkillLevel(SKILL_FISHING)
local tmpMonsters = {}
for minLevel, monsters in pairs(config.monsters) do
if config.debug then print("Monster fishing::Debug - Level check:", level, ">=", minLevel) end
if level >= minLevel then
if config.debug then print("Monster fishing::Debug - Level check passed - #monsters:", #monsters) end
for i = 1, #monsters do
if config.debug then print("Monster fishing::Debug - Found monster:", monsters[i]) end
table.insert(tmpMonsters, monsters[i])
end
end
end
if level >= config.bossLevel and skill >= config.bossSkill then
for i = 1, #config.bosses do
table.insert(tmpMonsters, bosses[i])
end
end
if config.debug then print("Monster fishing::Debug - #tmpMonsters: "..#tmpMonsters) end
if #tmpMonsters > 0 then
local pos = player:getPosition()
Game.createMonster(tmpMonsters[math.random(1, #tmpMonsters)], pos)
return true
end
end
player:addItem("fish", 1)
end
return true
end
I apparently forgot config. before bosses, it should be:my config is your config in the post
my erros is here
if level >= config.bossLevel and skill >= config.bossSkill then
for i = 1, #config.bosses do
table.insert(tmpMonsters, bosses)
end
end
in the console say that "attempt to global index at line ..........." don't remember, my server is closed now, but is this
Code: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 lootTrash = {2234, 2238, 2376, 2509, 2667} local lootCommon = {2152, 2167, 2168, 2669, 7588, 7589} local lootRare = {2143, 2146, 2149, 7158, 7159} local lootVeryRare = {7632, 7633, 10220} local useWorms = true -- Config for monster fishing local config = { enabled = true, -- enable or disable monster fishing debug = false, -- enable debug messages in console verifyMonsters = true, -- disable this if you are having problems with Monster fishing::Warning - Invalid monster name chance = 50, -- chance to catch a monster in % - 50 means you have a 50/50 chance of getting a monster or a fish bossLevel = 300, -- min level to catch a "boss" bossSkill = 90, -- min fishing skill to catch a "boss" monsters = { -- [minLevel] = {"monster", "names", "for", "level"} [100] = {"Quara Hydromancer", "Quara Constrictor", "Quara Mantassin"}, [150] = {"Water Elemental", "Massive Water Elemental"}, [200] = {"Quara Pincher", "Quara Predator"}, [300] = {"Sea Serpent"}, }, bosses = { -- Monsters that can only be caught with atleast "bossLevel" and "bossSkill" "Leviathan", } } -- Validate monsters configuration if config.verifyMonsters then local m = {} for minLevel, monsters in pairs(config.monsters) do m[minLevel] = {} if config.debug then print("#monsters", #monsters) end for i = 1, #monsters do if MonsterType(monsters[i]) then table.insert(m[minLevel], monsters[i]) else print("Monster fishing::Warning - Invalid monster name:", monsters[i]) end end if config.debug then print("Monster fishing::Debug - #monsters added", #m[minLevel]) end end config.monsters = m end function onUse(player, item, fromPosition, itemEx, toPosition, isHotkey) local targetId = itemEx.itemid if not isInArray(waterIds, itemEx.itemid) then return false end if targetId == 10499 then local targetItem = Item(itemEx.uid) local owner = targetItem:getAttribute(ITEM_ATTRIBUTE_CORPSEOWNER) if owner ~= 0 and owner ~= player:getId() then player:sendTextMessage(MESSAGE_STATUS_SMALL, "You are not the owner.") return true end toPosition:sendMagicEffect(CONST_ME_WATERSPLASH) targetItem:remove() local rareChance = math.random(1, 100) if rareChance == 1 then player:addItem(lootVeryRare[math.random(#lootVeryRare)], 1) elseif rareChance <= 3 then player:addItem(lootRare[math.random(#lootRare)], 1) elseif rareChance <= 10 then player:addItem(lootCommon[math.random(#lootCommon)], 1) else player:addItem(lootTrash[math.random(#lootTrash)], 1) end return true end if targetId ~= 7236 then toPosition:sendMagicEffect(CONST_ME_LOSEENERGY) end if targetId == 493 or targetId == 15402 then return true end 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("worm", 1) then return true end if targetId == 15401 then local targetItem = Item(itemEx.uid) targetItem:transform(targetId + 1) targetItem:decay() if math.random(1, 100) >= 97 then player:addItem(15405, 1) return true end elseif targetId == 7236 then local targetItem = Item(itemEx.uid) targetItem:transform(targetId + 1) targetItem:decay() local rareChance = math.random(1, 100) if rareChance == 1 then player:addItem(7158, 1) return true elseif rareChance <= 4 then player:addItem(2669, 1) return true elseif rareChance <= 10 then player:addItem(7159, 1) return true end end if config.enabled and math.random(100) <= config.chance then print("#tmpMonsters: "..#tmpMonsters) local level = player:getLevel() local skill = player:getSkillLevel(SKILL_FISHING) local tmpMonsters = {} for minLevel, monsters in pairs(config.monsters) do if config.debug then print("Monster fishing::Debug - Level check:", level, ">=", minLevel) end if level >= minLevel then if config.debug then print("Monster fishing::Debug - Level check passed - #monsters:", #monsters) end for i = 1, #monsters do if config.debug then print("Monster fishing::Debug - Found monster:", monsters[i]) end table.insert(tmpMonsters, monsters[i]) end end end if level >= config.bossLevel and skill >= config.bossSkill then for i = 1, #config.bosses do table.insert(tmpMonsters, bosses[i]) end end if config.debug then print("Monster fishing::Debug - #tmpMonsters: "..#tmpMonsters) end if #tmpMonsters > 0 then local pos = player:getPosition() Game.createMonster(tmpMonsters[math.random(1, #tmpMonsters)], pos) return true end end player:addItem("fish", 1) end return true end
table.insert(tmpMonsters, config.bosses[i])
There is nothing wrong with the monsters part, it's not working on config.monsters directly. If you changed that you broke it.bro have to put in monsters too
table.insert(tmpMonsters, config.monsters)
and have an error, when I have level and Boss skill, I always catch a boss...
edit the if, put one math random
table.insert(tmpMonsters, monsters[i])
table.insert(tmpMonsters, config.monsters[i])
i don`t see the lineWhat @Himii said will let you use any item with that action id to fish with.
If you want to make it possible to catch monsters only from water tiles with a certain action id, then change this line:
To:Code:if config.enabled then
Replace 1234 with the action id you you want to use and add that action id to the water tiles you want to catch monsters from in your map editor.Code:if config.enabled and Item(itemEx.uid):getActionId() == 1234 then
Looking at the default script, gaining fishing skill without worms is normal, however you will never be able to get a fish that way (with useWorms = true). Are you sure you had worms in your backpack? I just tried it again and it works fine for me.
lol do not be that specificd
i don`t see the line
if config.enabled then
if config.enabled and math.random(100) <= config.chance then
Replace this linewant it to work as an action id not a item id like monsters can only be fished with water actionid xxxx also is thear a way to broadcast when a boss is cuaght?
if config.enabled and math.random(100) <= config.chance then
if config.enabled and Item(itemEx.uid):getActionId() == YOUR_ACTIONID and math.random(100) <= config.chance then
if #tmpMonsters > 0 then
local pos = player:getPosition()
Game.createMonster(tmpMonsters[math.random(1, #tmpMonsters)], pos)
return true
end
if #tmpMonsters > 0 then
local pos = player:getPosition()
local name = tmpMonsters[math.random(1, #tmpMonsters)]
Game.createMonster(name, pos)
if isInArray(config.bosses, name) then
Game.broadcastMessage(player:getName() .. " caught " .. name .. "!", MESSAGE_STATUS_WARNING)
end
return true
end
well that don`t seem to do anythingthnaks so much also could it be configured for diffrent lvl bosses? such as this
bosses = {
-- Monsters that can only be caught with atleast "bossLevel" and "bossSkill"
[100] = "Orshabaal",
[150] ="Morgaroth",
}
}
Which TFS version are you using?[11:53:22.610] [Error - Test Interface]
[11:53:22.613] data/actions/scripts/other/monsterFishing.lua
[11:53:22.614] Description:
[11:53:22.616] data/actions/scripts/other/monsterFishing.lua:37: attempt to call global 'MonsterType' (a nil value)
[11:53:22.618] [Error - Event::checkScript] Cannot load script (data/actions/scripts/other/monsterFishing.lua)