• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

NPC - Error

Hultin

Member
Joined
Dec 2, 2008
Messages
262
Reaction score
17
Here is my error:
PHP:
[30/06/2010 20:29:02] [Error - LuaScriptInterface::loadFile] data/npc/scripts/blessings/first.lua:21: 'end' expected (to close 'function' at line 9) near '<eof>'
[30/06/2010 20:29:02] [Warning - NpcScript::NpcScript] Cannot load script: data/npc/scripts/blessings/first.lua
[30/06/2010 20:29:02] data/npc/scripts/blessings/first.lua:21: 'end' expected (to close 'function' at line 9) near '<eof>'

And here is my NPC code:
PHP:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)


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() 
if getPlayerLevel(cid) < 31 then
	cost = 2000
elseif(getPlayerLevel(cid) > 30 and getPlayerLevel(cid) < 121) then
	cost = ((getPlayerLevel(cid) - 30) * 200) + 2000
elseif(getPlayerLevel(cid) > 120) then
	cost = 20000
end

local node1 = keywordHandler:addKeyword({'blessing'}, StdModule.say, {npcHandle = npcHandler, onlyFocus = true, text = 'There are five blessings of this world. {Sanctifaction}, {Kings}, {Hope}, {Strength} and {Phoenix}'})
local node2 = keywordHandler:addKeyword({'Strength'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I can grant you blessing of Strengith for a sacrifice of '.. cost ..' gold. Do you wish to get blessed?'})
	node1:addChildKeyword({'yes'}, StdModule.bless, {npcHandler = npcHandler, number = 1, premium = false, baseCost = 2000, levelCost = 200, startLevel = 30, endLevel = 120})
	node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'I cannot help you without a sacrifice to the gods!'})

I've tried to fix this myself, but I just cannot seem to figure out what's wrong.

I do know what EOF means, End Of File.

I'm using the latest TFS 3.
 
I'm a rookie, so I just looked through the default npc files in TFS.

What this NPC is supposed to do is to Bless people, however only with one bless (number 1)

If you know a place for some tutorials or something, that'd be greatly appreciated. I'm really intrested in acctually learning this stuff and not just make things work (like many others) as I'm working on making my OT unique (Custom map, custom npcs etc..)
 
the embrace of tibia npc

humphrey
LUA:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Humphrey" script="The Embrace of Tibia.lua" walkinterval="2000" floorchange="0">
	<health now="100" max="100"/>
  <look type="133" head="0" body="115" legs="102" feet="95" addons="0" corpse="6080"/>
  	<parameters>
		<parameter key="message_greet" value="Hello |PLAYERNAME|."/>
        <parameter key="message_farewell" value="Good bye."/>
		<parameter key="message_walkaway" value="Farewell then.." />
    </parameters>
</npc>

LUA:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

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
--- start--
function creatureSayCallback(cid, type, msg)
	if(not npcHandler:isFocused(cid)) then
		return false
	end

	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

	if(msgcontains(msg, 'The Embrace of Tibia') or msgcontains(msg, 'the embrace of tibia')) then
		selfSay('Child of nature on a blessed pilgrimage, would you like to receive the embrace of Tibia for 10000 gold coins?', cid)
		talkState[talkUser] = 1
	elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
			if(doPlayerRemoveMoney(cid, 10000) == TRUE) then
				doPlayerAddBlessing(cid, 2)
				selfSay('So receive the embrace of Tibia, pilgrim. This is the second of five available blessings.', cid)
				doSendMagicEffect(getCreaturePosition(cid), math.random(39, 39))
			else
				selfSay('Sorry, You need to sacrifce 10000 gold coins.', cid)
			end
		talkState[talkUser] = 0
	elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser]) == TRUE) then
		talkState[talkUser] = 0
		selfSay('Okay, come back later.', cid)
	end

	return true
end
-- ends--
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

edit some of that with your script and you should get it working :)
 
Back
Top