Guerra
Member
Dear,
I would like to ask for help with an error that is happening with my custom Captain Dreadnought NPC. It is only in the distro the error, because the npc is working perfectly but for aesthetics and even to avoid problems on the server I would like a help to solve. Below the error print and the script I use.
I ask for help to resolve this error !!
I would like to ask for help with an error that is happening with my custom Captain Dreadnought NPC. It is only in the distro the error, because the npc is working perfectly but for aesthetics and even to avoid problems on the server I would like a help to solve. Below the error print and the script I use.
LUA:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local vocation = {}
local town = {}
local config = {
towns = {
["artemisias"] = 1,
["egeu"] = 2
},
vocations = {
["wizzard"] = {
text = "Um Wizzard! Tem certeza? Vocacao que domina o uso da Mana para conjurar magias poderosas! Deseja prosseguir? sua Decisao e irreversivel.",
vocationId = 1,
--Cointainer Lunar Staff
{{7424, 1}}
},
["warrior"] = {
text = "Um Guerreiro! Tem certeza? Vocacao que domina o uso de armas melee e combate de curto alcance. Deseja prosseguir? sua Decisao e irreversivel.",
vocationId = 4,
--container umbral blade, slayer, axe, shopper, mace e hammer.
{{22399, 1}, {22402, 1}, {22405, 1}, {22408, 1}, {22411, 1}, {22414, 1}}
},
["shooter"] = {
text = "Um Shooter! Tem certeza? Vocacao que domina o uso de armas e ataques a distancia. Deseja prosseguir? sua Decisao e irreversivel..",
vocationId = 9,
--container umbral bow
{{22417, 1}}
},
["healer"] = {
text = "Um Healer! Tem certeza? Vocacao que domina o uso da Mana para conjurar Buffs e Debuffs. Deseja prosseguir? sua Decisao e irreversivel.",
vocationId = 12,
--container Lunar Staff
{{7424, 1}}
}
}
}
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end
local function greetCallback(cid)
local player = Player(cid)
local level = player:getLevel()
if level < 20 then
npcHandler:say("somente nivel 20 voce podera completar a {The Acess} Quest. Nada mais, nada menos! Volte quando estiver pronto.", cid)
npcHandler:resetNpc(cid)
return false
elseif level > 20 then
npcHandler:say(player:getName() .."Me Desculpe, voce perdeu a oportunidade. Somente Jogadores level 20 podem fazer a quest {The Acess}.", cid)
npcHandler:resetNpc(cid)
return false
elseif player:getVocation():getId() > 0 then
npcHandler:say("Voce Ja possui Vocacao!", cid)
npcHandler:resetNpc(cid)
return false
else
npcHandler:setMessage(MESSAGE_GREET, player:getName() .." Esta Preparado para novas aventuras?")
end
return true
end
local function creatureSayCallback(cid, type, msg)
if not npcHandler:isFocused(cid) then
return false
end
local player = Player(cid)
if npcHandler.topic[cid] == 0 then
if msgcontains(msg, "sim") then
npcHandler:say("Para onde deseja que eu te leve: {ARTEMISIAS} ou {EGEU}?", cid)
npcHandler.topic[cid] = 1
end
elseif npcHandler.topic[cid] == 1 then
local cityTable = config.towns[msg:lower()]
if cityTable then
town[cid] = cityTable
npcHandler:say("IN ".. string.upper(msg) .."E Qual vocacao voce escolheu: {WIZZARD}, {WARRIOR}, {SHOOTER}, ou {HEALER}?", cid)
npcHandler.topic[cid] = 2
else
npcHandler:say("Para onde deseja que eu te leve: {ARTEMISIAS} ou {EGEU}?", cid)
end
elseif npcHandler.topic[cid] == 2 then
local vocationTable = config.vocations[msg:lower()]
if vocationTable then
npcHandler:say(vocationTable.text, cid)
npcHandler.topic[cid] = 3
vocation[cid] = vocationTable.vocationId
else
npcHandler:say("{WIZZARD}, {WARRIOR}, {SHOOTER}, ou {HEALER}?", cid)
end
elseif npcHandler.topic[cid] == 3 then
if msgcontains(msg, "sim") then
npcHandler:say("Que Assim Seja!", cid)
player:setVocation(Vocation(vocation[cid]))
player:setTown(Town(town[cid]))
player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
player:teleportTo(Town(town[cid]):getTemplePosition())
player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Vou te presentear com alguns itens basicos para que possa sobreviver nos niveis iniciais.")
local targetVocation = config.vocations[Vocation(vocation[cid]):getName():lower()]
for i = 1, #targetVocation[1] do
player:addItem(targetVocation[1][i][1], targetVocation[1][i][2])
end
local backpack = player:addItem(1988)
for i = 1, #targetVocation[2] do
backpack:addItem(targetVocation[2][i][1], targetVocation[2][i][2])
end
else
npcHandler:say("Entao o que sera? {WIZZARD}, {WARRIOR}, {SHOOTER}, ou {HEALER}?", cid)
npcHandler.topic[cid] = 2
end
end
return true
end
local function onAddFocus(cid)
town[cid] = 0
vocation[cid] = 0
end
local function onReleaseFocus(cid)
town[cid] = nil
vocation[cid] = nil
end
npcHandler:setCallback(CALLBACK_ONADDFOCUS, onAddFocus)
npcHandler:setCallback(CALLBACK_ONRELEASEFOCUS, onReleaseFocus)
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setMessage(MESSAGE_FAREWELL, "Fale comigo novamente quando estiver pronto!")
npcHandler:setMessage(MESSAGE_WALKAWAY, "Fale comigo novamente quando estiver pronto!")
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
I ask for help to resolve this error !!
