Hello!
I wanted to have NPC like, for example Cipfried from real tibia, who is healing a player when his hp is lower than 65.
But when player (having hp <65) says 'heal' to him, then NPC just says the text and doesn't heal him.
In my console I get this:
Here is my script for this NPC (texts which NPC has are in Polish
):
Please help me 
I wanted to have NPC like, for example Cipfried from real tibia, who is healing a player when his hp is lower than 65.
But when player (having hp <65) says 'heal' to him, then NPC just says the text and doesn't heal him.
In my console I get this:
Code:
[Error - Npc interface]
data/npc/scripts/heal.lua:onCreatureSay
Description:
(luaGetThingPosition) Thing not found
[Error - Npc interface]
data/npc/scripts/heal.lua:onCreatureSay
Description:
(luaDoCreatureAddHealth) Creature not found
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
-- OTServ event handling functions start
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
-- OTServ event handling functions end
-------------------------------------Healing Part------------------------------
function healCreature(cid, message, keywords, parameters)
if(getCreatureHealth(cid) < parameters.maxheal) then
position = getCreaturePosition(npcHandler.focus)
doSendMagicEffect(position, 12)
local healHP = parameters.maxheal - getCreatureHealth(cid)
doCreatureAddHealth(npcHandler.focus,healHP)
npcHandler:say('Wygladasz naprawde zle, pozwol ze cie wylecze.', cid)
else
npcHandler:say('Nie wygladasz az tak zle, ' .. getCreatureName(cid) .. '. Pomagam tylko w awaryjnych sytuacjach. Mozesz zwiekszyc ilosc swojego zycia dzieki jedzeniu.', cid)
end
return true
end
function healCreatureNoMsg(cid, maxheal)
if(getCreatureHealth(cid) < maxheal) then
position = getCreaturePosition(npcHandler.focus)
doSendMagicEffect(position, 12)
local healHP = maxheal - getCreatureHealth(cid)
doCreatureAddHealth(npcHandler.focus,healHP)
npcHandler:say('Hello, ' .. getCreatureName(cid) .. '! Wygladasz naprawde zle. Pozwol ze cie wylecze.', cid)
end
return true
end
function farewell(cid, message, keywords, parameters) return npcHandler:defaultFarewellHandler(cid, message, keywords, parameters) end
keywordHandler:addKeyword({'heal'}, healCreature, {maxheal = 65})
keywordHandler:addKeyword({'help'}, healCreature, {maxheal = 65})
npcHandler:addModule(FocusModule:new())