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

Captain npc not working

wafuboe

Active Member
Joined
Dec 24, 2010
Messages
884
Solutions
2
Reaction score
26
heres the script i am using tfs 1.2 otx server

seems like traveling doesnt work
when i say the city, the npc says nothing
seems like one addTravelKeyword is the problem

heres the script.

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

local voices = { {text = 'Passages to Valhedge, Sonoba, Al\'Ahad, Freljord, Avalon, Candima, Obre and Lacandona.'} }
npcHandler:addModule(VoiceModule:new(voices))

-- Travel
local function addTravelKeyword(keyword, cost, destination)
    local travelKeyword = keywordHandler:addKeyword({keyword}, StdModule.say, {npcHandler = npcHandler, text = 'Do you seek a passage to ' .. keyword:titleCase() .. ' for |TRAVELCOST|?', cost = cost, discount = 'postman'})
        travelKeyword:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = true, cost = cost, discount = 'postman', destination = destination})
        travelKeyword:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, text = 'We would like to serve you some time.', reset = true})
end

addTravelKeyword('Valhedge', 30, Position(431, 420, 6))
addTravelKeyword('Sonoba', 30, Position(400, 481, 6))
addTravelKeyword('Freljord', 150, Position(394, 196, 6))
addTravelKeyword('Al\'Ahad', 100, Position(875, 1070, 6))
addTravelKeyword('Avalon', 70, Position(518, 401, 6))
addTravelKeyword('Candima', 60, Position(815, 499, 6))
addTravelKeyword('Obre', 100, Position(433, 606, 6))
addTravelKeyword('Lacandona', 160, Position(1088, 966, 6))


-- Kick
keywordHandler:addKeyword({'kick'}, StdModule.kick, {npcHandler = npcHandler, destination = {Position(32952, 32031, 6), Position(32955, 32031, 6), Position(32957, 32032, 6)}})

-- Basic
keywordHandler:addKeyword({'sail'}, StdModule.say, {npcHandler = npcHandler, text = 'Where do you want to go? To {Valhedge}, {Sonoba}, {Al\'Ahad}, {Candima}, {Obre} or {Lacandona}?'})
keywordHandler:addKeyword({'travel'}, StdModule.say, {npcHandler = npcHandler, text = 'Where do you want to go? To {Valhedge}, {Sonoba}, {Al\'Ahad}, {Candima}, {Obre} or {Lacandona}?'})

npcHandler:setMessage(MESSAGE_GREET, 'Welcome on board, |PLAYERNAME|. Where can I {sail} you today?')
npcHandler:setMessage(MESSAGE_FAREWELL, 'Good bye. Recommend us if you were satisfied with our service.')
npcHandler:setMessage(MESSAGE_WALKAWAY, 'Good bye then.')

npcHandler:addModule(FocusModule:new())
 
The problem which is causing NPC to not respond is inside addTravelKeyword you have town names start with uppercase which is not necessary. -> keyword:titleCase() already does this for you when player asks for the town name.

TL;DR
Change:
LUA:
addTravelKeyword('Valhedge', 30, Position(431, 420, 6))
addTravelKeyword('Sonoba', 30, Position(400, 481, 6))
addTravelKeyword('Freljord', 150, Position(394, 196, 6))
addTravelKeyword('Al\'Ahad', 100, Position(875, 1070, 6))
addTravelKeyword('Avalon', 70, Position(518, 401, 6))
addTravelKeyword('Candima', 60, Position(815, 499, 6))
addTravelKeyword('obre', 100, Position(433, 606, 6))
addTravelKeyword('Lacandona', 160, Position(1088, 966, 6))

To:
LUA:
addTravelKeyword('valhedge', 30, Position(431, 420, 6))
addTravelKeyword('sonoba', 30, Position(400, 481, 6))
addTravelKeyword('freljord', 150, Position(394, 196, 6))
addTravelKeyword('al\'ahad', 100, Position(875, 1070, 6))
addTravelKeyword('avalon', 70, Position(518, 401, 6))
addTravelKeyword('candima', 60, Position(815, 499, 6))
addTravelKeyword('obre', 100, Position(433, 606, 6))
addTravelKeyword('lacandona', 160, Position(1088, 966, 6))
 
Back
Top