function StdModule.travel(cid, message, keywords, parameters, node)
local npcHandler = parameters.npcHandler
if npcHandler == nil then
error("StdModule.travel called without any npcHandler instance.")
end
if not npcHandler:isFocused(cid) then
return false
end
local player = Player(cid)
if player:isPremium() or not parameters.premium then
if player:isPzLocked() then...
function StdModule.travel(cid, message, keywords, parameters, node)
local npcHandler = parameters.npcHandler
if npcHandler == nil then
error("StdModule.travel called without any npcHandler instance.")
end
if not npcHandler:isFocused(cid) then
return false
end
local player = Player(cid)
if player:isPremium() or not parameters.premium then
if player:isPzLocked() then
npcHandler:say("First get rid of those blood stains! You are not going to ruin my vehicle!", cid)
elseif parameters.level and player:getLevel() < parameters.level then
npcHandler:say("You must reach level " .. parameters.level .. " before I can let you go there.", cid)
elseif not player:removeMoney(parameters.cost) then
npcHandler:say("You don't have enough money.", cid)
else
npcHandler:say(parameters.msg or "Set the sails!", cid)
npcHandler:releaseFocus(cid)
local destination = Position(parameters.destination)
local position = player:getPosition()
player:teleportTo(destination)
position:sendMagicEffect(CONST_ME_TELEPORT)
destination:sendMagicEffect(CONST_ME_TELEPORT)
end
else
npcHandler:say("I'm sorry, but you need a premium account in order to travel onboard our ships.", cid)
end
npcHandler:resetNpc(cid)
return true
end
if player:isPremium() or not parameters.premium then
else
npcHandler:say("I'm sorry, but you need a premium account in order to travel onboard our ships.", cid)
end
Perhaps your boat NPC? Could you post the XML and Lua code for him?
![]()
How to display CODE properly in your post
This thread is to inform users about how they should tag their codes in their threads. [code=html] HTML CODE HERE [/code] Hello! Hello World! This is coded in HTML! [code=XML] XML CODE HERE [/code] [code=php]...otland.net
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 Carlin, Ab\'Dendriel, Edron, Venore, Port Hope, Liberty Bay, Yalahar, Roshamuul and Svargrond.'} }
npcHandler:addModule(VoiceModule:new(voices))
-- Travel
local function addTravelKeyword(keyword, cost, destination, action)
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}, nil, action)
travelKeyword:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, text = 'We would like to serve you some time.', reset = true})
end
addTravelKeyword('carlin', 110, Position(32387, 31820, 6), function(player) if player:getStorageValue(Storage.postman.Mission01) == 1 then player:setStorageValue(Storage.postman.Mission01, 2) end end)
addTravelKeyword('ab\'dendriel', 130, Position(32734, 31668, 6))
addTravelKeyword('edron', 160, Position(33175, 31764, 6))
addTravelKeyword('venore', 170, Position(32954, 32022, 6))
addTravelKeyword('port hope', 160, Position(32527, 32784, 6))
addTravelKeyword('roshamuul', 210, Position(33494, 32567, 7))
addTravelKeyword('svargrond', 180, Position(32341, 31108, 6))
addTravelKeyword('liberty bay', 180, Position(32285, 32892, 6))
addTravelKeyword('yalahar', 200, Position(32816, 31272, 6))
-- Kick
keywordHandler:addKeyword({'kick'}, StdModule.kick, {npcHandler = npcHandler, destination = {Position(32320, 32219, 6), Position(32321, 32210, 6)}})
-- Basic
keywordHandler:addKeyword({'name'}, StdModule.say, {npcHandler = npcHandler, text = 'My name is Captain Bluebear from the Royal Tibia Line.'})
keywordHandler:addKeyword({'job'}, StdModule.say, {npcHandler = npcHandler, text = 'I am the captain of this sailing-ship.'})
keywordHandler:addKeyword({'captain'}, StdModule.say, {npcHandler = npcHandler, text = 'I am the captain of this sailing-ship.'})
keywordHandler:addKeyword({'ship'}, StdModule.say, {npcHandler = npcHandler, text = 'The Royal Tibia Line connects all seaside towns of Tibia.'})
keywordHandler:addKeyword({'line'}, StdModule.say, {npcHandler = npcHandler, text = 'The Royal Tibia Line connects all seaside towns of Tibia.'})
keywordHandler:addKeyword({'company'}, StdModule.say, {npcHandler = npcHandler, text = 'The Royal Tibia Line connects all seaside towns of Tibia.'})
keywordHandler:addKeyword({'route'}, StdModule.say, {npcHandler = npcHandler, text = 'The Royal Tibia Line connects all seaside towns of Tibia.'})
keywordHandler:addKeyword({'tibia'}, StdModule.say, {npcHandler = npcHandler, text = 'The Royal Tibia Line connects all seaside towns of Tibia.'})
keywordHandler:addKeyword({'good'}, StdModule.say, {npcHandler = npcHandler, text = 'We can transport everything you want.'})
keywordHandler:addKeyword({'passenger'}, StdModule.say, {npcHandler = npcHandler, text = 'We would like to welcome you on board.'})
keywordHandler:addKeyword({'trip'}, StdModule.say, {npcHandler = npcHandler, text = 'Where do you want to go? To {Carlin}, {Ab\'Dendriel}, {Edron}, {Venore}, {Port Hope}, {Liberty Bay}, {Yalahar}, {Roshamuul} or {Svargrond}?'})
keywordHandler:addKeyword({'passage'}, StdModule.say, {npcHandler = npcHandler, text = 'Where do you want to go? To {Carlin}, {Ab\'Dendriel}, {Edron}, {Venore}, {Port Hope}, {Liberty Bay}, {Yalahar}, {Roshamuul} or {Svargrond}?'})
keywordHandler:addKeyword({'town'}, StdModule.say, {npcHandler = npcHandler, text = 'Where do you want to go? To {Carlin}, {Ab\'Dendriel}, {Edron}, {Venore}, {Port Hope}, {Liberty Bay}, {Yalahar}, {Roshamuul} or {Svargrond}?'})
keywordHandler:addKeyword({'destination'}, StdModule.say, {npcHandler = npcHandler, text = 'Where do you want to go? To {Carlin}, {Ab\'Dendriel}, {Edron}, {Venore}, {Port Hope}, {Liberty Bay}, {Yalahar}, {Roshamuul} or {Svargrond}?'})
keywordHandler:addKeyword({'sail'}, StdModule.say, {npcHandler = npcHandler, text = 'Where do you want to go? To {Carlin}, {Ab\'Dendriel}, {Edron}, {Venore}, {Port Hope}, {Liberty Bay}, {Yalahar}, {Roshamuul} or {Svargrond}?'})
keywordHandler:addKeyword({'go'}, StdModule.say, {npcHandler = npcHandler, text = 'Where do you want to go? To {Carlin}, {Ab\'Dendriel}, {Edron}, {Venore}, {Port Hope}, {Liberty Bay}, {Yalahar}, {Roshamuul} or {Svargrond}?'})
keywordHandler:addKeyword({'ice'}, StdModule.say, {npcHandler = npcHandler, text = 'I\'m sorry, but we don\'t serve the routes to the Ice Islands.'})
keywordHandler:addKeyword({'senja'}, StdModule.say, {npcHandler = npcHandler, text = 'I\'m sorry, but we don\'t serve the routes to the Ice Islands.'})
keywordHandler:addKeyword({'folda'}, StdModule.say, {npcHandler = npcHandler, text = 'I\'m sorry, but we don\'t serve the routes to the Ice Islands.'})
keywordHandler:addKeyword({'vega'}, StdModule.say, {npcHandler = npcHandler, text = 'I\'m sorry, but we don\'t serve the routes to the Ice Islands.'})
keywordHandler:addKeyword({'darashia'}, StdModule.say, {npcHandler = npcHandler, text = 'I\'m not sailing there. This route is afflicted by a ghostship! However I\'ve heard that Captain Fearless from Venore sails there.'})
keywordHandler:addKeyword({'darama'}, StdModule.say, {npcHandler = npcHandler, text = 'I\'m not sailing there. This route is afflicted by a ghostship! However I\'ve heard that Captain Fearless from Venore sails there.'})
keywordHandler:addKeyword({'ghost'}, StdModule.say, {npcHandler = npcHandler, text = 'Many people who sailed to Darashia never returned because they were attacked by a ghostship! I\'ll never sail there!'})
keywordHandler:addKeyword({'thais'}, StdModule.say, {npcHandler = npcHandler, text = 'This is Thais. Where do you want to go?'})
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())
I mean a global change, not a single NPC, is it possible?
If not, then I attach the script.
Lua: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 Carlin, Ab\'Dendriel, Edron, Venore, Port Hope, Liberty Bay, Yalahar, Roshamuul and Svargrond.'} } npcHandler:addModule(VoiceModule:new(voices)) -- Travel local function addTravelKeyword(keyword, cost, destination, action) 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}, nil, action) travelKeyword:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, text = 'We would like to serve you some time.', reset = true}) end addTravelKeyword('carlin', 110, Position(32387, 31820, 6), function(player) if player:getStorageValue(Storage.postman.Mission01) == 1 then player:setStorageValue(Storage.postman.Mission01, 2) end end) addTravelKeyword('ab\'dendriel', 130, Position(32734, 31668, 6)) addTravelKeyword('edron', 160, Position(33175, 31764, 6)) addTravelKeyword('venore', 170, Position(32954, 32022, 6)) addTravelKeyword('port hope', 160, Position(32527, 32784, 6)) addTravelKeyword('roshamuul', 210, Position(33494, 32567, 7)) addTravelKeyword('svargrond', 180, Position(32341, 31108, 6)) addTravelKeyword('liberty bay', 180, Position(32285, 32892, 6)) addTravelKeyword('yalahar', 200, Position(32816, 31272, 6)) -- Kick keywordHandler:addKeyword({'kick'}, StdModule.kick, {npcHandler = npcHandler, destination = {Position(32320, 32219, 6), Position(32321, 32210, 6)}}) -- Basic keywordHandler:addKeyword({'name'}, StdModule.say, {npcHandler = npcHandler, text = 'My name is Captain Bluebear from the Royal Tibia Line.'}) keywordHandler:addKeyword({'job'}, StdModule.say, {npcHandler = npcHandler, text = 'I am the captain of this sailing-ship.'}) keywordHandler:addKeyword({'captain'}, StdModule.say, {npcHandler = npcHandler, text = 'I am the captain of this sailing-ship.'}) keywordHandler:addKeyword({'ship'}, StdModule.say, {npcHandler = npcHandler, text = 'The Royal Tibia Line connects all seaside towns of Tibia.'}) keywordHandler:addKeyword({'line'}, StdModule.say, {npcHandler = npcHandler, text = 'The Royal Tibia Line connects all seaside towns of Tibia.'}) keywordHandler:addKeyword({'company'}, StdModule.say, {npcHandler = npcHandler, text = 'The Royal Tibia Line connects all seaside towns of Tibia.'}) keywordHandler:addKeyword({'route'}, StdModule.say, {npcHandler = npcHandler, text = 'The Royal Tibia Line connects all seaside towns of Tibia.'}) keywordHandler:addKeyword({'tibia'}, StdModule.say, {npcHandler = npcHandler, text = 'The Royal Tibia Line connects all seaside towns of Tibia.'}) keywordHandler:addKeyword({'good'}, StdModule.say, {npcHandler = npcHandler, text = 'We can transport everything you want.'}) keywordHandler:addKeyword({'passenger'}, StdModule.say, {npcHandler = npcHandler, text = 'We would like to welcome you on board.'}) keywordHandler:addKeyword({'trip'}, StdModule.say, {npcHandler = npcHandler, text = 'Where do you want to go? To {Carlin}, {Ab\'Dendriel}, {Edron}, {Venore}, {Port Hope}, {Liberty Bay}, {Yalahar}, {Roshamuul} or {Svargrond}?'}) keywordHandler:addKeyword({'passage'}, StdModule.say, {npcHandler = npcHandler, text = 'Where do you want to go? To {Carlin}, {Ab\'Dendriel}, {Edron}, {Venore}, {Port Hope}, {Liberty Bay}, {Yalahar}, {Roshamuul} or {Svargrond}?'}) keywordHandler:addKeyword({'town'}, StdModule.say, {npcHandler = npcHandler, text = 'Where do you want to go? To {Carlin}, {Ab\'Dendriel}, {Edron}, {Venore}, {Port Hope}, {Liberty Bay}, {Yalahar}, {Roshamuul} or {Svargrond}?'}) keywordHandler:addKeyword({'destination'}, StdModule.say, {npcHandler = npcHandler, text = 'Where do you want to go? To {Carlin}, {Ab\'Dendriel}, {Edron}, {Venore}, {Port Hope}, {Liberty Bay}, {Yalahar}, {Roshamuul} or {Svargrond}?'}) keywordHandler:addKeyword({'sail'}, StdModule.say, {npcHandler = npcHandler, text = 'Where do you want to go? To {Carlin}, {Ab\'Dendriel}, {Edron}, {Venore}, {Port Hope}, {Liberty Bay}, {Yalahar}, {Roshamuul} or {Svargrond}?'}) keywordHandler:addKeyword({'go'}, StdModule.say, {npcHandler = npcHandler, text = 'Where do you want to go? To {Carlin}, {Ab\'Dendriel}, {Edron}, {Venore}, {Port Hope}, {Liberty Bay}, {Yalahar}, {Roshamuul} or {Svargrond}?'}) keywordHandler:addKeyword({'ice'}, StdModule.say, {npcHandler = npcHandler, text = 'I\'m sorry, but we don\'t serve the routes to the Ice Islands.'}) keywordHandler:addKeyword({'senja'}, StdModule.say, {npcHandler = npcHandler, text = 'I\'m sorry, but we don\'t serve the routes to the Ice Islands.'}) keywordHandler:addKeyword({'folda'}, StdModule.say, {npcHandler = npcHandler, text = 'I\'m sorry, but we don\'t serve the routes to the Ice Islands.'}) keywordHandler:addKeyword({'vega'}, StdModule.say, {npcHandler = npcHandler, text = 'I\'m sorry, but we don\'t serve the routes to the Ice Islands.'}) keywordHandler:addKeyword({'darashia'}, StdModule.say, {npcHandler = npcHandler, text = 'I\'m not sailing there. This route is afflicted by a ghostship! However I\'ve heard that Captain Fearless from Venore sails there.'}) keywordHandler:addKeyword({'darama'}, StdModule.say, {npcHandler = npcHandler, text = 'I\'m not sailing there. This route is afflicted by a ghostship! However I\'ve heard that Captain Fearless from Venore sails there.'}) keywordHandler:addKeyword({'ghost'}, StdModule.say, {npcHandler = npcHandler, text = 'Many people who sailed to Darashia never returned because they were attacked by a ghostship! I\'ll never sail there!'}) keywordHandler:addKeyword({'thais'}, StdModule.say, {npcHandler = npcHandler, text = 'This is Thais. Where do you want to go?'}) 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())
travelKeyword:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = true, cost = cost, discount = 'postman', destination = destination}, nil, action)
Yes, refresh the thread and look at my first post. I edited with the global change if you want to remove the premium check altogether for travelling.
function StdModule.travel(cid, message, keywords, parameters, node)
local npcHandler = parameters.npcHandler
if npcHandler == nil then
error("StdModule.travel called without any npcHandler instance.")
end
if not npcHandler:isFocused(cid) then
return false
end
local player = Player(cid)
local cost = parameters.cost
if cost and cost > 0 then
if parameters.discount then
cost = cost - StdModule.travelDiscount(player, parameters.discount)
if cost < 0 then
cost = 0
end
end
else
cost = 0
end
if parameters.premium and not player:isPremium() then
npcHandler:say("I'm sorry, but you need a premium account in order to travel onboard our ships.", cid)
elseif parameters.level and player:getLevel() < parameters.level then
npcHandler:say("You must reach level " .. parameters.level .. " before I can let you go there.", cid)
elseif player:isPzLocked() then
npcHandler:say("First get rid of those blood stains! You are not going to ruin my vehicle!", cid)
elseif not player:removeMoney(cost) then
npcHandler:say("You don't have enough money.", cid)
else
npcHandler:releaseFocus(cid)
npcHandler:say(parameters.text or "Set the sails!", cid)
player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
local destination = parameters.destination
if type(destination) == 'function' then
destination = destination(player)
end
player:teleportTo(destination)
destination:sendMagicEffect(CONST_ME_TELEPORT)
-- What a foolish Quest - Mission 3
if player:getStorageValue(Storage.WhatAFoolishQuest.PieBoxTimer) > os.time() then
if destination ~= Position(32660, 31957, 15) then -- kazordoon steamboat
player:setStorageValue(Storage.WhatAFoolishQuest.PieBoxTimer, 1)
end
end
end
npcHandler:resetNpc(cid)
return true
end
if parameters.premium and not player:isPremium() then
npcHandler:say("I'm sorry, but you need a premium account in order to travel onboard our ships.", cid)
elseif parameters.level and player:getLevel() < parameters.level then
npcHandler:say("You must reach level " .. parameters.level .. " before I can let you go there.", cid)
if parameters.level and player:getLevel() < parameters.level then
npcHandler:say("You must reach level " .. parameters.level .. " before I can let you go there.", cid)
Your modules.lua: (Around line 183+)
Lua:function StdModule.travel(cid, message, keywords, parameters, node) local npcHandler = parameters.npcHandler if npcHandler == nil then error("StdModule.travel called without any npcHandler instance.") end if not npcHandler:isFocused(cid) then return false end local player = Player(cid) local cost = parameters.cost if cost and cost > 0 then if parameters.discount then cost = cost - StdModule.travelDiscount(player, parameters.discount) if cost < 0 then cost = 0 end end else cost = 0 end if parameters.premium and not player:isPremium() then npcHandler:say("I'm sorry, but you need a premium account in order to travel onboard our ships.", cid) elseif parameters.level and player:getLevel() < parameters.level then npcHandler:say("You must reach level " .. parameters.level .. " before I can let you go there.", cid) elseif player:isPzLocked() then npcHandler:say("First get rid of those blood stains! You are not going to ruin my vehicle!", cid) elseif not player:removeMoney(cost) then npcHandler:say("You don't have enough money.", cid) else npcHandler:releaseFocus(cid) npcHandler:say(parameters.text or "Set the sails!", cid) player:getPosition():sendMagicEffect(CONST_ME_TELEPORT) local destination = parameters.destination if type(destination) == 'function' then destination = destination(player) end player:teleportTo(destination) destination:sendMagicEffect(CONST_ME_TELEPORT) -- What a foolish Quest - Mission 3 if player:getStorageValue(Storage.WhatAFoolishQuest.PieBoxTimer) > os.time() then if destination ~= Position(32660, 31957, 15) then -- kazordoon steamboat player:setStorageValue(Storage.WhatAFoolishQuest.PieBoxTimer, 1) end end end npcHandler:resetNpc(cid) return true end
Change this:
Lua:if parameters.premium and not player:isPremium() then npcHandler:say("I'm sorry, but you need a premium account in order to travel onboard our ships.", cid) elseif parameters.level and player:getLevel() < parameters.level then npcHandler:say("You must reach level " .. parameters.level .. " before I can let you go there.", cid)
Into this:
(I removed the two first lines, and changed line 3 from "elseif" into just an "if", making it the new start condition.Lua:if parameters.level and player:getLevel() < parameters.level then npcHandler:say("You must reach level " .. parameters.level .. " before I can let you go there.", cid)