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

2 Bugged NPCS in TFS 0.2

Ninkobi

Owner /Founder of Syphera
Joined
Apr 5, 2008
Messages
206
Reaction score
1
Location
England
I made a new NPC for a quest and it is bugged it gives the error <eof> expected near end or a error about needing a extra end.
Here it is:
Code:
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()						npcHandler:onThink()						end

function creatureSayCallback(cid, type, msg)
	-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
if(not npcHandler:isFocused(cid)) then
		return false
	end

		if msgcontains(msg, 'ingredient') then
        selfSay('Do you want to help me find the ingredients?')
        talk_state = 1
		elseif msgcontains(msg, 'yes') and talk_state == 1 and getPlayerStorageValue(cid,83279) == -1 then
            selfSay('The first ingredients I need are 30 glowing sands. Please come back to me and say glowing sands to get the next ingredients I need.')
                talk_state = 2
					setPlayerStorageValue(cid,83279,1)
		elseif msgcontains(msg, 'glowing sands') and getPlayerItemCount(cid,8204) >= 30 and getPlayerStorageValue(cid,83280) == -1 and getPlayerStorageValue(cid,83279) == 1 then
			if doPlayerTakeItem(cid,8204,30) == 0 then
            selfSay('Thank you very much! The next ingredient I need is 5 golden armors. Please come back to me and say golden armor to get the next ingredient I need.')
					setPlayerStorageValue(cid,83280,1)
		elseif msgcontains(msg, 'golden armor') and getPlayerItemCount(cid,2466) >= 5 and getPlayerStorageValue(cid,83280) == 1 and getPlayerStorageValue(cid,83281) == -1 then
			if doPlayerTakeItem(cid,2466,5) == 0 then
            selfSay('Thank you very much! The next ingredient I need is 1 strange herb. I believe it can be found in a crate at Mordor Demons. Please come back to me and say strange herb to get the next ingredients I need.')
					setPlayerStorageValue(cid,83281,1)
		elseif msgcontains(msg, 'strange herb') and getPlayerItemCount(cid,7248) >= 1 and getPlayerStorageValue(cid,83281) == 1 and getPlayerStorageValue(cid,83282) == -1 then
			if doPlayerTakeItem(cid,7248,1) == 0 then
            selfSay('Thank you very much! The final ingredient I need is a blood orb. Rumours say this can be found in a chest in the depth of Mordor Behemoths. Please come back to me and say blood orb.')
					setPlayerStorageValue(cid,83282,1)
		elseif msgcontains(msg, 'blood orb') and getPlayerStorageValue(cid,87642) == 1 and getPlayerStorageValue(cid,83283) == -1 and getPlayerItemCount(cid,2363) >= 1 then
			if doPlayerTakeItem(cid,2363,1) == 0 then
            selfSay('Thank you very much! I have a old spellbook you can have and I will enchant you with some experience for all your troubles.')
					setPlayerStorageValue(cid,83283,1)
			doPlayerAddExp(cid, 3000000)
			doSendMagicEffect(getPlayerPosition(cid), 27)
					doPlayerAddItem(cid, 2217, 1)
elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 3) then
			selfSay('Good Bye. |PLAYERNAME|!')
			talk_state = 0
		end
end
	-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
	return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

My second NPC is the boat man, he doesn't automatically teleport when you say "Bring me to <destination>".
Script:
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
 
 
 
-- Makes sure the npc reacts when you say hi, bye etc.
npcHandler:addModule(FocusModule:new())

XML:
Code:
<npc name="Captain" script="data/npc/scripts/theboat.lua" walkinterval="0000" floorchange="0" access="5" level="1" maglevel="1">
	<health now="150" max="150"/>
	<look type="151" head="124" body="114" legs="114" feet="114" addons="3"/>
  corpse="2212"/>
	<parameters>
		<parameter key="module_travel" value="1" />
		<parameter key="message_greet" value="Hello |PLAYERNAME|. I can take you to: Thais, Venore, Carlin, Edron, Ankrahmun, Ab dendriel, Port hope, Darashia, Svargrond, Goroma, Gengia, Nabu, Pyre and Oken for free." />
		<parameter key="travel_destinations" value="thais,32311,32210,6,0;venore,32954,32022,6,0;carlin,32388,31821,6,0;ab dendriel,32733,31669,6,0;ankrahmun,33092,32883,6,0;darashia,33288,32482,6,0;edron,33176,31765,6,0;port hope,32528,32784,6,0;svargrond,32431,31162,6,0;goroma,31994,32565,6,0;gengia,34472,32697,6,0;nabu,20270,20065,7,0;pyre,33623,4003,6,0;oken,19990,20008,6,0;" />
	</parameters>
</npc>

Thanks in advance!
 
You need to end any if statements inside of your if/elseif statements, for example:
Code:
		elseif msgcontains(msg, 'strange herb') and getPlayerItemCount(cid,7248) >= 1 and getPlayerStorageValue(cid,83281) == 1 and getPlayerStorageValue(cid,83282) == -1 then
			if doPlayerTakeItem(cid,7248,1) == 0 then
            selfSay('Thank you very much! The final ingredient I need is a blood orb. Rumours say this can be found in a chest in the depth of Mordor Behemoths. Please come back to me and say blood orb.')
					setPlayerStorageValue(cid,83282,1)
You need to end the 'if doPlayerTakeItem(cid, 7248,1)....' and you need to do that for any if statements you have inside your main if statement.

Jo3
 
You need to end any if statements inside of your if/elseif statements, for example:
Code:
		elseif msgcontains(msg, 'strange herb') and getPlayerItemCount(cid,7248) >= 1 and getPlayerStorageValue(cid,83281) == 1 and getPlayerStorageValue(cid,83282) == -1 then
			if doPlayerTakeItem(cid,7248,1) == 0 then
            selfSay('Thank you very much! The final ingredient I need is a blood orb. Rumours say this can be found in a chest in the depth of Mordor Behemoths. Please come back to me and say blood orb.')
					setPlayerStorageValue(cid,83282,1)
You need to end the 'if doPlayerTakeItem(cid, 7248,1)....' and you need to do that for any if statements you have inside your main if statement.

Jo3
I did that (i put 6 ends) but it still gave a error <EOF> expected near end
 
I didn't test it:
Code:
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()						npcHandler:onThink()						end
function creatureSayCallback(cid, type, msg)


if(not npcHandler:isFocused(cid)) then
	return false
end


	if msgcontains(msg, 'ingredient') then
		selfSay('Do you want to help me find the ingredients?')
		talk_state = 1
	

	elseif msgcontains(msg, 'yes') and talk_state == 1 and getPlayerStorageValue(cid,83279) == -1 then
		selfSay('The first ingredients I need are 30 glowing sands. Please come back to me and say glowing sands to get the next ingredients I need.')
		talk_state = 2
		setPlayerStorageValue(cid,83279,1)


	elseif msgcontains(msg, 'glowing sands') and getPlayerItemCount(cid,8204) >= 30 and getPlayerStorageValue(cid,83280) == -1 and getPlayerStorageValue(cid,83279) == 1 then
		if doPlayerTakeItem(cid,8204,30) == 0 then
			selfSay('Thank you very much! The next ingredient I need is 5 golden armors. Please come back to me and say golden armor to get the next ingredient I need.')
			setPlayerStorageValue(cid,83280,1)
		end


	elseif msgcontains(msg, 'golden armor') and getPlayerItemCount(cid,2466) >= 5 and getPlayerStorageValue(cid,83280) == 1 and getPlayerStorageValue(cid,83281) == -1 then
		if doPlayerTakeItem(cid,2466,5) == 0 then
			selfSay('Thank you very much! The next ingredient I need is 1 strange herb. I believe it can be found in a crate at Mordor Demons. Please come back to me and say strange herb to get the next ingredients I need.')
			setPlayerStorageValue(cid,83281,1)
		end


	elseif msgcontains(msg, 'strange herb') and getPlayerItemCount(cid,7248) >= 1 and getPlayerStorageValue(cid,83281) == 1 and getPlayerStorageValue(cid,83282) == -1 then
		if doPlayerTakeItem(cid,7248,1) == 0 then
			selfSay('Thank you very much! The final ingredient I need is a blood orb. Rumours say this can be found in a chest in the depth of Mordor Behemoths. Please come back to me and say blood orb.')
			setPlayerStorageValue(cid,83282,1)
		end


	elseif msgcontains(msg, 'blood orb') and getPlayerStorageValue(cid,87642) == 1 and getPlayerStorageValue(cid,83283) == -1 and getPlayerItemCount(cid,2363) >= 1 then
		if doPlayerTakeItem(cid,2363,1) == 0 then
			selfSay('Thank you very much! I have a old spellbook you can have and I will enchant you with some experience for all your troubles.')
			setPlayerStorageValue(cid,83283,1)
			doPlayerAddExp(cid, 3000000)
			doSendMagicEffect(getPlayerPosition(cid), 27)
			doPlayerAddItem(cid, 2217, 1)
		end


	elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 3) then
		selfSay('Good Bye. |PLAYERNAME|!')
		talk_state = 0
	end


return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Jo3
 
Back
Top Bottom