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

Solved Problem with boat npc

biel-kun

New Member
Joined
Sep 4, 2007
Messages
31
Reaction score
0
Guys, I have this NPC script[globalBoatNpc.lua]:
PHP:
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

local travelNode = keywordHandler:addKeyword({'city1'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = True, Text = 'Do you wish To travel To city1 For 240 gold coins?'})
	travelNode:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = false, level = 8, cost = 240, destination = {x=1839, y=1819, z=6} })
	travelNode:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'I wouldn\'t go there either.'})

local travelNode = keywordHandler:addKeyword({'city2'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = True, Text = 'Do you wish To travel To city2 For 200 gold coins?'})
	travelNode:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = false, level = 8, cost = 200, destination = {x=1214, y=1802, z=6} })
	travelNode:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'I wouldn\'t go there either.'})

local travelNode = keywordHandler:addKeyword({'city3'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = True, Text = 'Do you wish To travel To city3 For 150 gold coins?'})
	travelNode:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = false, level = 8, cost = 150, destination = {x=1509, y=1252, z=6} })
	travelNode:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'I wouldn\'t go there either.'})

keywordHandler:addKeyword({'destination'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I can take you to City1 or city2 or city3 For just a small fee.'})

-- Makes sure the npc reacts when you say hi, bye etc.
npcHandler:addModule(FocusModule:new())

In game, when I say 'city1' or any other option the npc not responds and I have this error in console:
Lua Script Error: [Npc interface]
data/npc/scripts/globalBoatNpc.lua:onCreatureSay

data/npc/lib/npcsystem/npchandler.lua:301: bad argument #1 to 'gsub' (string expected, got nil)
stack traceback:
[C]: in function 'gsub'
data/npc/lib/npcsystem/npchandler.lua:301: in function 'parseMessage'
data/npc/lib/npcsystem/modules.lua:55: in function 'callback'
data/npc/lib/npcsystem/keywordhandler.lua:40: in function 'processMessage'
data/npc/lib/npcsystem/keywordhandler.lua:168: in function 'processNodeMessage'
data/npc/lib/npcsystem/keywordhandler.lua:128: in function 'processMessage'
data/npc/lib/npcsystem/npchandler.lua:381: in function 'onCreatureSay'
data/npc/scripts/globalBoatNpc.lua:10: in function <data/npc/scripts/globalBoatNpc.lua:10>

It's an error with jiddo's library version I'm using?

Thanks
 
Last edited:
Here is my boat npc. Try it. It works fine for me.
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

	local travelNode = keywordHandler:addKeyword({'gengia'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Gengia is only accesable for donators (check donate page at vmo.mine.nu if not), are you a donator?'})
        	travelNode:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = true, level = 0, cost = 0, destination = {x=34472, y=32697, z=6} })
        	travelNode:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Then stay here!'}) 
	
	local travelNode = keywordHandler:addKeyword({'pyre'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Pyre is only accesable for donators (check donate page at vmo.mine.nu if not), are you a donator?'})
        	travelNode:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = true, level = 0, cost = 0, destination = {x=33623, y=4003, z=6} })
        	travelNode:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Then stay here!'}) 

	local travelNode = keywordHandler:addKeyword({'oken'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Oken is only accesable for donators (check donate page at vmo.mine.nu if not), are you a donator?'})
        	travelNode:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = true, level = 0, cost = 0, destination = {x=19990, y=20008, z=6} })
        	travelNode:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Then stay here!'}) 

npcHandler:addModule(FocusModule:new())
 
Back
Top