• 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!

Lua Npc Script healer in rookgaard!

Zorenia

Hoster of Zorenia
Joined
Jan 21, 2009
Messages
598
Reaction score
64
Location
The Netherlands
Request NPC SCRIPT, that heales in rookgaard when my hp below 65!! I can´t find any scripts does anyone have it for my? I use TFS 0.3b3

Thanks in advance,

Rick. :p
 
Cipfried.xml
Code:
<npc name="Cipfried" script="data/npc/scripts/healer.lua" autowalk="0" floorchange="0">
<health now="100" max="100"/>
<look type="57" head="0" body="0" legs="0" feet="0" corpse="3058"/>
<parameters>
<parameter key="message_greet" value="Greetings |PLAYERNAME|." />
<parameter key="message_farewell" value="Good bye |PLAYERNAME|." />
<parameter key="module_keywords" value="1" />
<parameter key="keywords" value="offer" />
<parameter key="keyword_reply1" value="I can heal you for free if you are hurt." />

</parameters>
</npc>

healer.lua
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)
		selfSay('You are looking really bad. Let me heal your wounds.')
	else
		selfSay('You aren\'t looking really bad, ' .. getCreatureName(cid) .. '. I only help in cases of real emergencies. Raise your health simply by eating food.')
	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)
		selfSay('Hello, ' .. getCreatureName(cid) .. '! You are looking really bad. Let me heal your wounds.')
	end	
	return true
end

function tradeItem(cid, message, keywords, parameters)     return npcHandler:defaultTradeHandler(cid, message, keywords, parameters) end
function confirmAction(cid, message, keywords, parameters) return npcHandler:defaultConfirmHandler(cid, message, keywords, parameters) end
function sayMessage(cid, message, keywords, parameters)     return npcHandler:defaultMessageHandler(cid, message, keywords, parameters) end
function greet(cid, message, keywords, parameters)       
    if (npcHandler.focus > 0 or not(npcHandler.queue:isEmpty()) and npcHandler.focus ~= cid) then
        selfSay('Please, ' .. creatureGetName(cid) .. '. Wait for your turn!.')
        if(not npcHandler.queue:isInQueue(cid)) then
            npcHandler.queue:pushBack(cid)
        end
    elseif(npcHandler.focus == 0) and (npcHandler.queue:isEmpty()) then
        npcHandler.focus = cid
        npcHandler.talkStart = os.clock()
		if(getCreatureHealth(cid) >= 200) then
			selfSay('Hello, ' .. creatureGetName(cid) .. '! I will heal you if you are injured. Feel free to ask me for help.')
		else
			healCreatureNoMsg(npcHandler.focus, 60)
		end		
    end
    
    return true
end

function farewell(cid, message, keywords, parameters)         return npcHandler:defaultFarewellHandler(cid, message, keywords, parameters) end

keywordHandler:addKeyword({'heal'},     healCreature, {maxheal = 60})
keywordHandler:addKeyword({'help'},     healCreature, {maxheal = 60})

keywordHandler:addKeyword({'yes'}, confirmAction, nil)
keywordHandler:addKeyword({'no'}, confirmAction, nil)

npcHandler:addModule(FocusModule:new())
 
Won´t work :( I hope anyone can fix it or help me :)

[06/02/2009 21:04:14] [C]: in function 'doSendMagicEffect'
[06/02/2009 21:04:14] data/npc/scripts/healer.lua:18: in function 'callback'
[06/02/2009 21:04:14] data/npc/lib/npcsystem/keywordhandler.lua:40: in function 'processMessage'
[06/02/2009 21:04:14] data/npc/lib/npcsystem/keywordhandler.lua:168: in function 'processNodeMessage'
[06/02/2009 21:04:14] data/npc/lib/npcsystem/keywordhandler.lua:128: in function 'processMessage'
[06/02/2009 21:04:14] data/npc/lib/npcsystem/npchandler.lua:371: in function 'onCreatureSay'
[06/02/2009 21:04:14] data/npc/scripts/healer.lua:9: in function <data/npc/scripts/healer.lua:9>
 
Back
Top