potinho
Intermediate OT User
Hello everyone, everything good?
I have a script that is bothering me: it searches for the monsters that I have and some information about it. Everything works normal, including when I type a wrong or invalid name, it shows me the table with the name of the monsters and the alert that I typed wrong, but even with everything working, when I type a wrong name it returns the following error in console, could you help me remove this error? I have typed "/info blasduhadsuh" and return me a warning and table of monster.
But my console got error:
[25/3/2021 20:25:59] [Error - TalkAction Interface]
[25/3/2021 20:25:59] data/talkactions/scripts/info.luanSay
[25/3/2021 20:25:59] Description:
[25/3/2021 20:25:59] (LuaInterface::luaGetMonsterInfo) Monster not found
Follow my script:
I have a script that is bothering me: it searches for the monsters that I have and some information about it. Everything works normal, including when I type a wrong or invalid name, it shows me the table with the name of the monsters and the alert that I typed wrong, but even with everything working, when I type a wrong name it returns the following error in console, could you help me remove this error? I have typed "/info blasduhadsuh" and return me a warning and table of monster.
But my console got error:
[25/3/2021 20:25:59] [Error - TalkAction Interface]
[25/3/2021 20:25:59] data/talkactions/scripts/info.luanSay
[25/3/2021 20:25:59] Description:
[25/3/2021 20:25:59] (LuaInterface::luaGetMonsterInfo) Monster not found
Follow my script:
Lua:
function getDirMonsterByNameMonster(name)
t = {}
local monster = io.open("data/monster/monsters.xml", "r")
for i in monster:read("*a"):gmatch('<monster name="'..tostring(name)..'" file="(.-)"/>') do
table.insert(t, tostring(i))
end
return t[1] or 0
end
function getMonsterLootItens(name)
local dir = "data/monster/"..getDirMonsterByNameMonster(name)..""
local monster = io.open(""..dir.."", "r")
str = ""
for i in monster:read("*a"):gmatch('id="(.-)"') do
str = ""..str.." - "..getItemNameById(i)..""
end
return str
end
function getAllMonster()
local str = ""
local monster = io.open("data/monster/monsters.xml", "r")
str = "Voce digitou incorretamente o nome do monstro veja a lista de monstro\n"
for i in monster:read("*a"):gmatch('<monster name="(.-)"') do
str = ""..str.." - "..i..""
end
return str
end
function getAttrMonster(name)
return "Life = "..getMonsterInfo(name).health.."\nExp = "..getMonsterInfo(name).experience.."\n"
end
function onSay(cid, words, param, channel)
if param == "" or not param or param == " " then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Voce precisa dizer o nome do monstro")
return true
end
local name = param:lower()
if getMonsterInfo(name) then
name = name:gsub("(%l)(%w*)", function(a,b) return string.upper(a)..b end)
doShowTextDialog(cid, 1397, "Info Monster "..name.."\n"..getAttrMonster(name).."\n\nLoots = "..getMonsterLootItens(name).."")
else
doShowTextDialog(cid, 1397, getAllMonster())
return true
end
return true
end