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

Tfs 1.3 need working travel npc. Example or working thais ship 8.6

Svira

Active Member
Joined
Jan 27, 2008
Messages
267
Solutions
11
Reaction score
36
Hello,
Looking for working example npc for travel.
Tfs 1.3


I chck all npc from 0.3.6-1.2 + otx
 
Try this one

Captain Bluebear.lua

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, Oramond 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 = false, 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))
addTravelKeyword('oramond', 140, Position(33479, 31985, 7))
addTravelKeyword('krailos', 0, Position(33491, 31711, 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({'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}, {Venore}, {Port Hope}, {Liberty Bay}, {Svargrond}, {Yalahar}, {Roshamuul}, {Oramond} or {Edron}?'})
keywordHandler:addKeyword({'route'}, StdModule.say, {npcHandler = npcHandler, text = 'Where do you want to go? To {Carlin}, {Ab\'Dendriel}, {Venore}, {Port Hope}, {Liberty Bay}, {Svargrond}, {Yalahar}, {Roshamuul}, {Oramond} or {Edron}?'})
keywordHandler:addKeyword({'passage'}, StdModule.say, {npcHandler = npcHandler, text = 'Where do you want to go? To {Carlin}, {Ab\'Dendriel}, {Venore}, {Port Hope}, {Liberty Bay}, {Svargrond}, {Yalahar}, {Roshamuul}, {Oramond} or {Edron}?'})
keywordHandler:addKeyword({'town'}, StdModule.say, {npcHandler = npcHandler, text = 'Where do you want to go? To {Carlin}, {Ab\'Dendriel}, {Venore}, {Port Hope}, {Liberty Bay}, {Svargrond}, {Yalahar}, {Roshamuul}, {Oramond} or {Edron}?'})
keywordHandler:addKeyword({'destination'}, StdModule.say, {npcHandler = npcHandler, text = 'Where do you want to go? To {Carlin}, {Ab\'Dendriel}, {Venore}, {Port Hope}, {Liberty Bay}, {Svargrond}, {Yalahar}, {Roshamuul}, {Oramond} or {Edron}?'})
keywordHandler:addKeyword({'sail'}, StdModule.say, {npcHandler = npcHandler, text = 'Where do you want to go? To {Carlin}, {Ab\'Dendriel}, {Venore}, {Port Hope}, {Liberty Bay}, {Svargrond}, {Yalahar}, {Roshamuul}, {Oramond} or {Edron}?'})
keywordHandler:addKeyword({'go'}, StdModule.say, {npcHandler = npcHandler, text = 'Where do you want to go? To {Carlin}, {Ab\'Dendriel}, {Venore}, {Port Hope}, {Liberty Bay}, {Svargrond}, {Yalahar}, {Roshamuul}, {Oramond} or {Edron}?'})
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())
 
Code:
Lua Script Error: [Npc interface]
data/npc/scripts/Captain Bluebear.lua:onCreatureSay
data/npc/lib/npcsystem/modules.lua:61: table index is nil
stack traceback:
        [C]: in function '__newindex'
        data/npc/lib/npcsystem/modules.lua:61: in function 'callback'
        data/npc/lib/npcsystem/keywordhandler.lua:31: in function 'processMessage'
        data/npc/lib/npcsystem/keywordhandler.lua:186: in function 'processNodeMessage'
        data/npc/lib/npcsystem/keywordhandler.lua:161: in function 'processMessage'
        data/npc/lib/npcsystem/npchandler.lua:398: in function 'onCreatureSay'
        data/npc/scripts/Captain Bluebear.lua:7: in function <data/npc/scripts/Captain Bluebear.lua:7>
working all NPC but not for travel...

ITS TFS 1.3 BUT FOR T8.6
 

Attachments

try including this

npc/lib/npcsystem/customModules.lua

Lua:
-- Custom Modules, created to help us in this datapack
local travelDiscounts = {
    ['postman'] = {price = 10, storage = Storage.postman.Rank, value = 3},
    ['new frontier'] = {price = 50, storage = Storage.TheNewFrontier.Mission03, value = 1}
}

function StdModule.travelDiscount(player, discounts)
    local discountPrice, discount = 0
    if type(discounts) == 'string' then
        discount = travelDiscounts[discounts]
        if discount and player:getStorageValue(discount.storage) >= discount.value then
            return discount.price
        end
    else
        for i = 1, #discounts do
            discount = travelDiscounts[discounts[i]]
            if discount and player:getStorageValue(discount.storage) >= discount.value then
                discountPrice = discountPrice + discount.price
            end
        end
    end

    return discountPrice
end

function StdModule.kick(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

    npcHandler:releaseFocus(cid)
    npcHandler:say(parameters.text or "Off with you!", cid)

    local destination = parameters.destination
    if type(destination) == 'table' then
        destination = destination[math.random(#destination)]
    end

    Player(cid):teleportTo(destination, true)

    npcHandler:resetNpc(cid)
    return true
end

local GreetModule = {}
function GreetModule.greet(cid, message, keywords, parameters)
    if not parameters.npcHandler:isInRange(cid) then
        return true
    end

    if parameters.npcHandler:isFocused(cid) then
        return true
    end

    local parseInfo = { [TAG_PLAYERNAME] = Player(cid):getName() }
    parameters.npcHandler:say(parameters.npcHandler:parseMessage(parameters.text, parseInfo), cid, true)
    parameters.npcHandler:addFocus(cid)
    return true
end

function GreetModule.farewell(cid, message, keywords, parameters)
    if not parameters.npcHandler:isFocused(cid) then
        return false
    end

    local parseInfo = { [TAG_PLAYERNAME] = Player(cid):getName() }
    parameters.npcHandler:say(parameters.npcHandler:parseMessage(parameters.text, parseInfo), cid, true)
    parameters.npcHandler:resetNpc(cid)
    parameters.npcHandler:releaseFocus(cid)
    return true
end

-- Adds a keyword which acts as a greeting word
function KeywordHandler:addGreetKeyword(keys, parameters, condition, action)
    local keys = keys
    keys.callback = FocusModule.messageMatcherDefault
    return self:addKeyword(keys, GreetModule.greet, parameters, condition, action)
end

-- Adds a keyword which acts as a farewell word
function KeywordHandler:addFarewellKeyword(keys, parameters, condition, action)
    local keys = keys
    keys.callback = FocusModule.messageMatcherDefault
    return self:addKeyword(keys, GreetModule.farewell, parameters, condition, action)
end

-- Adds a keyword which acts as a spell word
function KeywordHandler:addSpellKeyword(keys, parameters)
    local keys = keys
    keys.callback = FocusModule.messageMatcherDefault

    local npcHandler, spellName, price, vocationId = parameters.npcHandler, parameters.spellName, parameters.price, parameters.vocation
    local spellKeyword = self:addKeyword(keys, StdModule.say, {npcHandler = npcHandler, text = string.format("Do you want to learn the spell '%s' for %s?", spellName, price > 0 and price .. ' gold' or 'free')},
        function(player)
            local baseVocationId = player:getVocation():getBase():getId()
            if type(vocationId) == 'table' then
                return isInArray(vocationId, baseVocationId)
            else
                return vocationId == baseVocationId
            end
        end
    )

    spellKeyword:addChildKeyword({'yes'}, StdModule.learnSpell, {npcHandler = npcHandler, spellName = spellName, level = parameters.level, price = price})
    spellKeyword:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, text = 'Maybe next time.', reset = true})
end

local hints = {
    [-1] = 'If you don\'t know the meaning of an icon on the right side, move the mouse cursor on it and wait a moment.',
    [0] = 'Send private messages to other players by right-clicking on the player or the player\'s name and select \'Message to ....\'. You can also open a \'private message channel\' and type in the name of the player.',
    [1] = 'Use the shortcuts \'SHIFT\' to look, \'CTRL\' for use and \'ALT\' for attack when clicking on an object or player.',
    [2] = 'If you already know where you want to go, click on the automap and your character will walk there automatically if the location is reachable and not too far away.',
    [3] = 'To open or close skills, battle or VIP list, click on the corresponding button to the right.',
    [4] = '\'Capacity\' restricts the amount of things you can carry with you. It raises with each level.',
    [5] = 'Always have a look on your health bar. If you see that you do not regenerate health points anymore, eat something.',
    [6] = 'Always eat as much food as possible. This way, you\'ll regenerate health points for a longer period of time.',
    [7] = 'After you have killed a monster, you have 10 seconds in which the corpse is not moveable and no one else but you can loot it.',
    [8] = 'Be careful when you approach three or more monsters because you only can block the attacks of two. In such a situation even a few rats can do severe damage or even kill you.',
    [9] = 'There are many ways to gather food. Many creatures drop food but you can also pick blueberries or bake your own bread. If you have a fishing rod and worms in your inventory, you can also try to catch a fish.',
    [10] = {'Baking bread is rather complex. First of all you need a scythe to harvest wheat. Then you use the wheat with a millstone to get flour. ...', 'This can be be used on water to get dough, which can be used on an oven to bake bread. Use milk instead of water to get cake dough.'},
    [11] = 'Dying hurts! Better run away than risk your life. You are going to lose experience and skill points when you die.',
    [12] = 'When you switch to \'Offensive Fighting\', you deal out more damage but you also get hurt more easily.',
    [13] = 'When you are on low health and need to run away from a monster, switch to \'Defensive Fighting\' and the monster will hit you less severely.',
    [14] = 'Many creatures try to run away from you. Select \'Chase Opponent\' to follow them.',
    [15] = 'The deeper you enter a dungeon, the more dangerous it will be. Approach every dungeon with utmost care or an unexpected creature might kill you. This will result in losing experience and skill points.',
    [16] = 'Due to the perspective, some objects in Tibia are not located at the spot they seem to appear (ladders, windows, lamps). Try clicking on the floor tile the object would lie on.',
    [17] = 'If you want to trade an item with another player, right-click on the item and select \'Trade with ...\', then click on the player with whom you want to trade.',
    [18] = 'Stairs, ladders and dungeon entrances are marked as yellow dots on the automap.',
    [19] = 'You can get food by killing animals or monsters. You can also pick blueberries or bake your own bread. If you are too lazy or own too much money, you can also buy food.',
    [20] = 'Quest containers can be recognised easily. They don\'t open up regularly but display a message \'You have found ....\'. They can only be opened once.',
    [21] = 'Better run away than risk to die. You\'ll lose experience and skill points each time you die.',
    [22] = 'You can form a party by right-clicking on a player and selecting \'Invite to Party\'. The party leader can also enable \'Shared Experience\' by right-clicking on him- or herself.',
    [23] = 'You can assign spells, the use of items, or random text to \'hotkeys\'. You find them under \'Options\'.',
    [24] = 'You can also follow other players. Just right-click on the player and select \'Follow\'.',
    [25] = 'You can found a party with your friends by right-clicking on a player and selecting \'Invite to Party\'. If you are invited to a party, right-click on yourself and select \'Join Party\'.',
    [26] = 'Only found parties with people you trust. You can attack people in your party without getting a skull. This is helpful for training your skills, but can be abused to kill people without having to fear negative consequences.',
    [27] = 'The leader of a party has the option to distribute gathered experience among all players in the party. If you are the leader, right-click on yourself and select \'Enable Shared Experience\'.',
    [28] = 'There is nothing more I can tell you. If you are still in need of some {hints}, I can repeat them for you.'
}

function StdModule.rookgaardHints(cid, message, keywords, parameters, node)
    local npcHandler = parameters.npcHandler
    if npcHandler == nil then
        error("StdModule.say called without any npcHandler instance.")
    end

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

    local player = Player(cid)
    local hintId = player:getStorageValue(Storage.RookgaardHints)
    npcHandler:say(hints[hintId], cid)
    if hintId >= #hints then
        player:setStorageValue(Storage.RookgaardHints, -1)
    else
        player:setStorageValue(Storage.RookgaardHints, hintId + 1)
    end
    return true
end

-- VoiceModule
VoiceModule = {
    voices = nil,
    voiceCount = 0,
    lastVoice = 0,
    timeout = nil,
    chance = nil,
    npcHandler = nil
}

-- Creates a new instance of VoiceModule
function VoiceModule:new(voices, timeout, chance)
    local obj = {}
    setmetatable(obj, self)
    self.__index = self

    obj.voices = voices
    for i = 1, #obj.voices do
        local voice = obj.voices[i]
        if voice.yell then
            voice.yell = nil
            voice.talktype = TALKTYPE_YELL
        else
            voice.talktype = TALKTYPE_SAY
        end
    end

    obj.voiceCount = #voices
    obj.timeout = timeout or 10
    obj.chance = chance or 25
    return obj
end

function VoiceModule:init(handler)
    return true
end

function VoiceModule:callbackOnThink()
    if self.lastVoice < os.time() then
        self.lastVoice = os.time() + self.timeout
        if math.random(100) < self.chance  then
            local voice = self.voices[math.random(self.voiceCount)]
            Npc():say(voice.text, voice.talktype)
        end
    end
    return true
end

lib/core/string.lua

Lua:
string.split = function(str, sep)
    local res = {}
    for v in str:gmatch("([^" .. sep .. "]+)") do
        res[#res + 1] = v
    end
    return res
end

string.trim = function(str)
    return str:match'^()%s*$' and '' or str:match'^%s*(.*%S)'
end

string.starts = function(str, substr)
    return string.sub(str, 1, #substr) == substr
end

string.titleCase = function(str)
    return str:gsub("(%a)([%w_']*)", function(first, rest) return first:upper() .. rest:lower() end)
end
 

Attachments

now i have problem with all NPC...
Code:
Lua Script Error: [Npc interface]
data/npc/scripts/Kasmir.lua
data/npc/scripts/Kasmir.lua:78: attempt to call method 'addAliasKeyword' (a nil value)
stack traceback:
        [C]: in function 'addAliasKeyword'
        data/npc/scripts/Kasmir.lua:78: in main chunk
[Warning - NpcScript::NpcScript] Can not load script: Kasmir.lua


Lua Script Error: [Npc interface]
data/npc/scripts/Gabel.lua
data/npc/scripts/Gabel.lua:87: attempt to call method 'addGreetMessage' (a nil value)
stack traceback:
        [C]: in function 'addGreetMessage'
        data/npc/scripts/Gabel.lua:87: in main chunk
[Warning - NpcScript::NpcScript] Can not load script: Gabel.lua


Lua Script Error: [Npc interface]
data/npc/scripts/Malor.lua
data/npc/scripts/Malor.lua:99: attempt to call method 'addGreetMessage' (a nil value)
stack traceback:
        [C]: in function 'addGreetMessage'
        data/npc/scripts/Malor.lua:99: in main chunk
[Warning - NpcScript::NpcScript] Can not load script: Malor.lua


Lua Script Error: [Npc interface]
data/npc/scripts/Edala.lua
data/npc/scripts/Edala.lua:44: attempt to call method 'addAliasKeyword' (a nil value)
stack traceback:
        [C]: in function 'addAliasKeyword'
        data/npc/scripts/Edala.lua:44: in main chunk
[Warning - NpcScript::NpcScript] Can not load script: Edala.lua


Lua Script Error: [Npc interface]
data/npc/scripts/Yaman.lua
data/npc/scripts/Yaman.lua:101: attempt to call method 'addGreetMessage' (a nil value)
stack traceback:
        [C]: in function 'addGreetMessage'
        data/npc/scripts/Yaman.lua:101: in main chunk
[Warning - NpcScript::NpcScript] Can not load script: Yaman.lua

[Error - Npc::loadFromXml] Failed to load data/npc/Baa'Leal.xml: File was not found

Lua Script Error: [Npc interface]
data/npc/scripts/Dario.lua
data/npc/scripts/Dario.lua:22: attempt to call method 'addGreetMessage' (a nil value)
stack traceback:
        [C]: in function 'addGreetMessage'
        data/npc/scripts/Dario.lua:22: in main chunk
[Warning - NpcScript::NpcScript] Can not load script: Dario.lua

[Error - Npc::loadFromXml] Failed to load data/npc/Miles, the guard.xml: File was not found

Lua Script Error: [Npc interface]
data/npc/scripts/Bo'Ques.lua
data/npc/scripts/Bo'Ques.lua:95: attempt to call method 'addGreetMessage' (a nil value)
stack traceback:
        [C]: in function 'addGreetMessage'
        data/npc/scripts/Bo'Ques.lua:95: in main chunk
[Warning - NpcScript::NpcScript] Can not load script: Bo'Ques.lua


Lua Script Error: [Npc interface]
data/npc/scripts/Fa'Hradin.lua
data/npc/scripts/Fa'Hradin.lua:73: attempt to call method 'addGreetMessage' (a nil value)
stack traceback:
        [C]: in function 'addGreetMessage'
        data/npc/scripts/Fa'Hradin.lua:73: in main chunk
[Warning - NpcScript::NpcScript] Can not load script: Fa'Hradin.lua


Lua Script Error: [Npc interface]
data/npc/scripts/Alesar.lua
data/npc/scripts/Alesar.lua:99: attempt to call method 'addGreetMessage' (a nil value)
stack traceback:
        [C]: in function 'addGreetMessage'
        data/npc/scripts/Alesar.lua:99: in main chunk
[Warning - NpcScript::NpcScript] Can not load script: Alesar.lua


Lua Script Error: [Npc interface]
data/npc/scripts/Shiriel.lua
data/npc/scripts/Shiriel.lua:11: attempt to call method 'addGreetMessage' (a nil value)
stack traceback:
        [C]: in function 'addGreetMessage'
        data/npc/scripts/Shiriel.lua:11: in main chunk
[Warning - NpcScript::NpcScript] Can not load script: Shiriel.lua


Lua Script Error: [Npc interface]
data/npc/scripts/Ukea.lua
data/npc/scripts/Ukea.lua:11: attempt to call method 'addGreetMessage' (a nil value)
stack traceback:
        [C]: in function 'addGreetMessage'
        data/npc/scripts/Ukea.lua:11: in main chunk
[Warning - NpcScript::NpcScript] Can not load script: Ukea.lua


Lua Script Error: [Npc interface]
data/npc/scripts/Eroth.lua
data/npc/scripts/Eroth.lua:23: attempt to call method 'addGreetMessage' (a nil value)
stack traceback:
        [C]: in function 'addGreetMessage'
        data/npc/scripts/Eroth.lua:23: in main chunk
[Warning - NpcScript::NpcScript] Can not load script: Eroth.lua


Lua Script Error: [Npc interface]
data/npc/scripts/Humphrey.lua
data/npc/scripts/Humphrey.lua:44: attempt to call method 'addAliasKeyword' (a nil value)
stack traceback:
        [C]: in function 'addAliasKeyword'
        data/npc/scripts/Humphrey.lua:44: in main chunk
[Warning - NpcScript::NpcScript] Can not load script: Humphrey.lua


Lua Script Error: [Npc interface]
data/npc/scripts/Elf Guard.lua
data/npc/scripts/Elf Guard.lua:24: attempt to call method 'addGreetMessage' (a nil value)
stack traceback:
        [C]: in function 'addGreetMessage'
        data/npc/scripts/Elf Guard.lua:24: in main chunk
[Warning - NpcScript::NpcScript] Can not load script: Elf Guard.lua


Lua Script Error: [Npc interface]
data/npc/scripts/Stutch.lua
data/npc/scripts/Stutch.lua:40: attempt to call method 'addGreetMessage' (a nil value)
stack traceback:
        [C]: in function 'addGreetMessage'
        data/npc/scripts/Stutch.lua:40: in main chunk
[Warning - NpcScript::NpcScript] Can not load script: Stutch.lua


Lua Script Error: [Npc interface]
data/npc/scripts/Harsky.lua
data/npc/scripts/Harsky.lua:40: attempt to call method 'addGreetMessage' (a nil value)
stack traceback:
        [C]: in function 'addGreetMessage'
        data/npc/scripts/Harsky.lua:40: in main chunk
[Warning - NpcScript::NpcScript] Can not load script: Harsky.lua


Lua Script Error: [Npc interface]
data/npc/scripts/King Tibianus.lua
data/npc/scripts/King Tibianus.lua:64: attempt to call method 'addAliasKeyword' (a nil value)
stack traceback:
        [C]: in function 'addAliasKeyword'
        data/npc/scripts/King Tibianus.lua:64: in main chunk
[Warning - NpcScript::NpcScript] Can not load script: King Tibianus.lua

[Error - Npc::loadFromXml] Failed to load data/npc/Oldrak.xml: File was not found

Lua Script Error: [Npc interface]
data/npc/scripts/Norf.lua
data/npc/scripts/Norf.lua:14: attempt to call method 'addAliasKeyword' (a nil value)
stack traceback:
        [C]: in function 'addAliasKeyword'
        data/npc/scripts/Norf.lua:14: in main chunk
[Warning - NpcScript::NpcScript] Can not load script: Norf.lua


Lua Script Error: [Npc interface]
data/npc/scripts/Umar.lua
data/npc/scripts/Umar.lua:93: attempt to call method 'addGreetMessage' (a nil value)
stack traceback:
        [C]: in function 'addGreetMessage'
        data/npc/scripts/Umar.lua:93: in main chunk
[Warning - NpcScript::NpcScript] Can not load script: Umar.lua


Lua Script Error: [Npc interface]
data/npc/scripts/Ubaid.lua
data/npc/scripts/Ubaid.lua:111: attempt to call method 'addGreetMessage' (a nil value)
stack traceback:
        [C]: in function 'addGreetMessage'
        data/npc/scripts/Ubaid.lua:111: in main chunk
[Warning - NpcScript::NpcScript] Can not load script: Ubaid.lua


Lua Script Error: [Npc interface]
data/npc/scripts/Myra.lua
data/npc/scripts/Myra.lua:29: attempt to call method 'addAliasKeyword' (a nil value)
stack traceback:
        [C]: in function 'addAliasKeyword'
        data/npc/scripts/Myra.lua:29: in main chunk
[Warning - NpcScript::NpcScript] Can not load script: Myra.lua


Lua Script Error: [Npc interface]
data/npc/scripts/Frodo.lua
data/npc/scripts/Frodo.lua:16: attempt to call method 'addAliasKeyword' (a nil value)
stack traceback:
        [C]: in function 'addAliasKeyword'
        data/npc/scripts/Frodo.lua:16: in main chunk
[Warning - NpcScript::NpcScript] Can not load script: Frodo.lua


Lua Script Error: [Npc interface]
data/npc/scripts/Kjesse.lua
data/npc/scripts/Kjesse.lua:65: attempt to call method 'addAliasKeyword' (a nil value)
stack traceback:
        [C]: in function 'addAliasKeyword'
        data/npc/scripts/Kjesse.lua:65: in main chunk
[Warning - NpcScript::NpcScript] Can not load script: Kjesse.lua


Lua Script Error: [Npc interface]
data/npc/scripts/Elvith.lua
data/npc/scripts/Elvith.lua:62: attempt to call method 'addGreetMessage' (a nil value)
stack traceback:
        [C]: in function 'addGreetMessage'
        data/npc/scripts/Elvith.lua:62: in main chunk
[Warning - NpcScript::NpcScript] Can not load script: Elvith.lua


Lua Script Error: [Npc interface]
data/npc/scripts/Irea.lua
data/npc/scripts/Irea.lua:11: attempt to call method 'addGreetMessage' (a nil value)
stack traceback:
        [C]: in function 'addGreetMessage'
        data/npc/scripts/Irea.lua:11: in main chunk
[Warning - NpcScript::NpcScript] Can not load script: Irea.lua


Lua Script Error: [Npc interface]
data/npc/scripts/Maealil.lua
data/npc/scripts/Maealil.lua:78: attempt to call method 'addAliasKeyword' (a nil value)
stack traceback:
        [C]: in function 'addAliasKeyword'
        data/npc/scripts/Maealil.lua:78: in main chunk
[Warning - NpcScript::NpcScript] Can not load script: Maealil.lua


Lua Script Error: [Npc interface]
data/npc/scripts/Anerui.lua
data/npc/scripts/Anerui.lua:33: attempt to call method 'addGreetMessage' (a nil value)
stack traceback:
        [C]: in function 'addGreetMessage'
        data/npc/scripts/Anerui.lua:33: in main chunk
[Warning - NpcScript::NpcScript] Can not load script: Anerui.lua


Lua Script Error: [Npc interface]
data/npc/scripts/Faluae.lua
data/npc/scripts/Faluae.lua:11: attempt to call method 'addGreetMessage' (a nil value)
stack traceback:
        [C]: in function 'addGreetMessage'
        data/npc/scripts/Faluae.lua:11: in main chunk
[Warning - NpcScript::NpcScript] Can not load script: Faluae.lua


Lua Script Error: [Npc interface]
data/npc/scripts/Barbara.lua
data/npc/scripts/Barbara.lua:40: attempt to call method 'addGreetMessage' (a nil value)
stack traceback:
        [C]: in function 'addGreetMessage'
        data/npc/scripts/Barbara.lua:40: in main chunk
[Warning - NpcScript::NpcScript] Can not load script: Barbara.lua


Lua Script Error: [Npc interface]
data/npc/scripts/Queen Eloise.lua
data/npc/scripts/Queen Eloise.lua:25: attempt to call method 'addAliasKeyword' (a nil value)
stack traceback:
        [C]: in function 'addAliasKeyword'
        data/npc/scripts/Queen Eloise.lua:25: in main chunk
[Warning - NpcScript::NpcScript] Can not load script: Queen Eloise.lua


Lua Script Error: [Npc interface]
data/npc/scripts/Fenbala.lua
data/npc/scripts/Fenbala.lua:40: attempt to call method 'addGreetMessage' (a nil value)
stack traceback:
        [C]: in function 'addGreetMessage'
        data/npc/scripts/Fenbala.lua:40: in main chunk
[Warning - NpcScript::NpcScript] Can not load script: Fenbala.lua


Lua Script Error: [Npc interface]
data/npc/scripts/Alia.lua
data/npc/scripts/Alia.lua:65: attempt to call method 'addAliasKeyword' (a nil value)
stack traceback:
        [C]: in function 'addAliasKeyword'
        data/npc/scripts/Alia.lua:65: in main chunk
[Warning - NpcScript::NpcScript] Can not load script: Alia.lua


Lua Script Error: [Npc interface]
data/npc/scripts/Eremo.lua
data/npc/scripts/Eremo.lua:14: attempt to call method 'addAliasKeyword' (a nil value)
stack traceback:
        [C]: in function 'addAliasKeyword'
        data/npc/scripts/Eremo.lua:14: in main chunk
[Warning - NpcScript::NpcScript] Can not load script: Eremo.lua


Lua Script Error: [Npc interface]
data/npc/scripts/Yberius.lua
data/npc/scripts/Yberius.lua:78: attempt to call method 'addAliasKeyword' (a nil value)
stack traceback:
        [C]: in function 'addAliasKeyword'
        data/npc/scripts/Yberius.lua:78: in main chunk
[Warning - NpcScript::NpcScript] Can not load script: Yberius.lua

[Error - Npc::loadFromXml] Failed to load data/npc/Loria.xml: File was not found

Lua Script Error: [Npc interface]
data/npc/scripts/Bozo.lua
data/npc/scripts/Bozo.lua:832: attempt to call method 'addAliasKeyword' (a nil value)
stack traceback:
        [C]: in function 'addAliasKeyword'
        data/npc/scripts/Bozo.lua:832: in main chunk
[Warning - NpcScript::NpcScript] Can not load script: Bozo.lua


Lua Script Error: [Npc interface]
data/npc/scripts/Gorn.lua
data/npc/scripts/Gorn.lua:39: attempt to call method 'addAliasKeyword' (a nil value)
stack traceback:
        [C]: in function 'addAliasKeyword'
        data/npc/scripts/Gorn.lua:39: in main chunk
[Warning - NpcScript::NpcScript] Can not load script: Gorn.lua


Lua Script Error: [Npc interface]
data/npc/scripts/Frodo.lua
data/npc/scripts/Frodo.lua:16: attempt to call method 'addAliasKeyword' (a nil value)
stack traceback:
        [C]: in function 'addAliasKeyword'
        data/npc/scripts/Frodo.lua:16: in main chunk
[Warning - NpcScript::NpcScript] Can not load script: Frodo.lua


Lua Script Error: [Npc interface]
data/npc/scripts/Quentin.lua
data/npc/scripts/Quentin.lua:88: attempt to call method 'addAliasKeyword' (a nil value)
stack traceback:
        [C]: in function 'addAliasKeyword'
        data/npc/scripts/Quentin.lua:88: in main chunk
[Warning - NpcScript::NpcScript] Can not load script: Quentin.lua


Lua Script Error: [Npc interface]
data/npc/scripts/Chondur.lua
data/npc/scripts/Chondur.lua:71: attempt to call method 'addAliasKeyword' (a nil value)
stack traceback:
        [C]: in function 'addAliasKeyword'
        data/npc/scripts/Chondur.lua:71: in function 'addTaskKeyword'
        data/npc/scripts/Chondur.lua:76: in main chunk
[Warning - NpcScript::NpcScript] Can not load script: Chondur.lua


Lua Script Error: [Npc interface]
data/npc/scripts/Rata'Mari.lua
data/npc/scripts/Rata'Mari.lua:72: attempt to call method 'addGreetMessage' (a nil value)
stack traceback:
        [C]: in function 'addGreetMessage'
        data/npc/scripts/Rata'Mari.lua:72: in main chunk
[Warning - NpcScript::NpcScript] Can not load script: Rata'Mari.lua


Lua Script Error: [Npc interface]
data/npc/scripts/Brewster.lua
data/npc/scripts/Brewster.lua:78: attempt to call method 'addAliasKeyword' (a nil value)
stack traceback:
        [C]: in function 'addAliasKeyword'
        data/npc/scripts/Brewster.lua:78: in main chunk
[Warning - NpcScript::NpcScript] Can not load script: Brewster.lua


Lua Script Error: [Npc interface]
data/npc/scripts/Tyrias.lua
data/npc/scripts/Tyrias.lua:79: attempt to call method 'addAliasKeyword' (a nil value)
stack traceback:
        [C]: in function 'addAliasKeyword'
        data/npc/scripts/Tyrias.lua:79: in main chunk
[Warning - NpcScript::NpcScript] Can not load script: Tyrias.lua


Lua Script Error: [Npc interface]
data/npc/scripts/Rahkem.lua
data/npc/scripts/Rahkem.lua:81: attempt to call method 'addAliasKeyword' (a nil value)
stack traceback:
        [C]: in function 'addAliasKeyword'
        data/npc/scripts/Rahkem.lua:81: in main chunk
[Warning - NpcScript::NpcScript] Can not load script: Rahkem.lua


Lua Script Error: [Npc interface]
data/npc/scripts/Shanar.lua
data/npc/scripts/Shanar.lua:18: attempt to call method 'addGreetMessage' (a nil value)
stack traceback:
        [C]: in function 'addGreetMessage'
        data/npc/scripts/Shanar.lua:18: in main chunk
[Warning - NpcScript::NpcScript] Can not load script: Shanar.lua


Lua Script Error: [Npc interface]
data/npc/scripts/Bashira.lua
data/npc/scripts/Bashira.lua:19: attempt to call method 'addGreetMessage' (a nil value)
stack traceback:
        [C]: in function 'addGreetMessage'
        data/npc/scripts/Bashira.lua:19: in main chunk
[Warning - NpcScript::NpcScript] Can not load script: Bashira.lua


Lua Script Error: [Npc interface]
data/npc/scripts/Briasol.lua
data/npc/scripts/Briasol.lua:46: attempt to call method 'addGreetMessage' (a nil value)
stack traceback:
        [C]: in function 'addGreetMessage'
        data/npc/scripts/Briasol.lua:46: in main chunk
[Warning - NpcScript::NpcScript] Can not load script: Briasol.lua


Lua Script Error: [Npc interface]
data/npc/scripts/Amanda.lua
data/npc/scripts/Amanda.lua:105: attempt to call method 'addAliasKeyword' (a nil value)
stack traceback:
        [C]: in function 'addAliasKeyword'
        data/npc/scripts/Amanda.lua:105: in main chunk
[Warning - NpcScript::NpcScript] Can not load script: Amanda.lua


Lua Script Error: [Npc interface]
data/npc/scripts/Shirith.lua
data/npc/scripts/Shirith.lua:42: attempt to call method 'addGreetMessage' (a nil value)
stack traceback:
        [C]: in function 'addGreetMessage'
        data/npc/scripts/Shirith.lua:42: in main chunk
[Warning - NpcScript::NpcScript] Can not load script: Shirith.lua


Lua Script Error: [Npc interface]
data/npc/scripts/Elathriel.lua
data/npc/scripts/Elathriel.lua:80: attempt to call method 'addGreetMessage' (a nil value)
stack traceback:
        [C]: in function 'addGreetMessage'
        data/npc/scripts/Elathriel.lua:80: in main chunk
[Warning - NpcScript::NpcScript] Can not load script: Elathriel.lua


Lua Script Error: [Npc interface]
data/npc/scripts/Maryza.lua
data/npc/scripts/Maryza.lua:46: attempt to call method 'addGreetMessage' (a nil value)
stack traceback:
        [C]: in function 'addGreetMessage'
        data/npc/scripts/Maryza.lua:46: in main chunk
[Warning - NpcScript::NpcScript] Can not load script: Maryza.lua

[Spawn::addMonster] Can not find a carved stone tile
[Spawn::addMonster] Can not find a carved stone tile
[Spawn::addMonster] Can not find a carved stone tile

Lua Script Error: [Npc interface]
data/npc/scripts/Pydar.lua
data/npc/scripts/Pydar.lua:14: attempt to call method 'addAliasKeyword' (a nil value)
stack traceback:
        [C]: in function 'addAliasKeyword'
        data/npc/scripts/Pydar.lua:14: in main chunk
[Warning - NpcScript::NpcScript] Can not load script: Pydar.lua


Lua Script Error: [Npc interface]
data/npc/scripts/Isimov.lua
data/npc/scripts/Isimov.lua:79: attempt to call method 'addAliasKeyword' (a nil value)
stack traceback:
        [C]: in function 'addAliasKeyword'
        data/npc/scripts/Isimov.lua:79: in main chunk
[Warning - NpcScript::NpcScript] Can not load script: Isimov.lua




SOLVED! 2 same function in modules
 
Last edited:
try including this

npc/lib/npcsystem/customModules.lua

Lua:
-- Custom Modules, created to help us in this datapack
local travelDiscounts = {
    ['postman'] = {price = 10, storage = Storage.postman.Rank, value = 3},
    ['new frontier'] = {price = 50, storage = Storage.TheNewFrontier.Mission03, value = 1}
}

function StdModule.travelDiscount(player, discounts)
    local discountPrice, discount = 0
    if type(discounts) == 'string' then
        discount = travelDiscounts[discounts]
        if discount and player:getStorageValue(discount.storage) >= discount.value then
            return discount.price
        end
    else
        for i = 1, #discounts do
            discount = travelDiscounts[discounts[i]]
            if discount and player:getStorageValue(discount.storage) >= discount.value then
                discountPrice = discountPrice + discount.price
            end
        end
    end

    return discountPrice
end

function StdModule.kick(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

    npcHandler:releaseFocus(cid)
    npcHandler:say(parameters.text or "Off with you!", cid)

    local destination = parameters.destination
    if type(destination) == 'table' then
        destination = destination[math.random(#destination)]
    end

    Player(cid):teleportTo(destination, true)

    npcHandler:resetNpc(cid)
    return true
end

local GreetModule = {}
function GreetModule.greet(cid, message, keywords, parameters)
    if not parameters.npcHandler:isInRange(cid) then
        return true
    end

    if parameters.npcHandler:isFocused(cid) then
        return true
    end

    local parseInfo = { [TAG_PLAYERNAME] = Player(cid):getName() }
    parameters.npcHandler:say(parameters.npcHandler:parseMessage(parameters.text, parseInfo), cid, true)
    parameters.npcHandler:addFocus(cid)
    return true
end

function GreetModule.farewell(cid, message, keywords, parameters)
    if not parameters.npcHandler:isFocused(cid) then
        return false
    end

    local parseInfo = { [TAG_PLAYERNAME] = Player(cid):getName() }
    parameters.npcHandler:say(parameters.npcHandler:parseMessage(parameters.text, parseInfo), cid, true)
    parameters.npcHandler:resetNpc(cid)
    parameters.npcHandler:releaseFocus(cid)
    return true
end

-- Adds a keyword which acts as a greeting word
function KeywordHandler:addGreetKeyword(keys, parameters, condition, action)
    local keys = keys
    keys.callback = FocusModule.messageMatcherDefault
    return self:addKeyword(keys, GreetModule.greet, parameters, condition, action)
end

-- Adds a keyword which acts as a farewell word
function KeywordHandler:addFarewellKeyword(keys, parameters, condition, action)
    local keys = keys
    keys.callback = FocusModule.messageMatcherDefault
    return self:addKeyword(keys, GreetModule.farewell, parameters, condition, action)
end

-- Adds a keyword which acts as a spell word
function KeywordHandler:addSpellKeyword(keys, parameters)
    local keys = keys
    keys.callback = FocusModule.messageMatcherDefault

    local npcHandler, spellName, price, vocationId = parameters.npcHandler, parameters.spellName, parameters.price, parameters.vocation
    local spellKeyword = self:addKeyword(keys, StdModule.say, {npcHandler = npcHandler, text = string.format("Do you want to learn the spell '%s' for %s?", spellName, price > 0 and price .. ' gold' or 'free')},
        function(player)
            local baseVocationId = player:getVocation():getBase():getId()
            if type(vocationId) == 'table' then
                return isInArray(vocationId, baseVocationId)
            else
                return vocationId == baseVocationId
            end
        end
    )

    spellKeyword:addChildKeyword({'yes'}, StdModule.learnSpell, {npcHandler = npcHandler, spellName = spellName, level = parameters.level, price = price})
    spellKeyword:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, text = 'Maybe next time.', reset = true})
end

local hints = {
    [-1] = 'If you don\'t know the meaning of an icon on the right side, move the mouse cursor on it and wait a moment.',
    [0] = 'Send private messages to other players by right-clicking on the player or the player\'s name and select \'Message to ....\'. You can also open a \'private message channel\' and type in the name of the player.',
    [1] = 'Use the shortcuts \'SHIFT\' to look, \'CTRL\' for use and \'ALT\' for attack when clicking on an object or player.',
    [2] = 'If you already know where you want to go, click on the automap and your character will walk there automatically if the location is reachable and not too far away.',
    [3] = 'To open or close skills, battle or VIP list, click on the corresponding button to the right.',
    [4] = '\'Capacity\' restricts the amount of things you can carry with you. It raises with each level.',
    [5] = 'Always have a look on your health bar. If you see that you do not regenerate health points anymore, eat something.',
    [6] = 'Always eat as much food as possible. This way, you\'ll regenerate health points for a longer period of time.',
    [7] = 'After you have killed a monster, you have 10 seconds in which the corpse is not moveable and no one else but you can loot it.',
    [8] = 'Be careful when you approach three or more monsters because you only can block the attacks of two. In such a situation even a few rats can do severe damage or even kill you.',
    [9] = 'There are many ways to gather food. Many creatures drop food but you can also pick blueberries or bake your own bread. If you have a fishing rod and worms in your inventory, you can also try to catch a fish.',
    [10] = {'Baking bread is rather complex. First of all you need a scythe to harvest wheat. Then you use the wheat with a millstone to get flour. ...', 'This can be be used on water to get dough, which can be used on an oven to bake bread. Use milk instead of water to get cake dough.'},
    [11] = 'Dying hurts! Better run away than risk your life. You are going to lose experience and skill points when you die.',
    [12] = 'When you switch to \'Offensive Fighting\', you deal out more damage but you also get hurt more easily.',
    [13] = 'When you are on low health and need to run away from a monster, switch to \'Defensive Fighting\' and the monster will hit you less severely.',
    [14] = 'Many creatures try to run away from you. Select \'Chase Opponent\' to follow them.',
    [15] = 'The deeper you enter a dungeon, the more dangerous it will be. Approach every dungeon with utmost care or an unexpected creature might kill you. This will result in losing experience and skill points.',
    [16] = 'Due to the perspective, some objects in Tibia are not located at the spot they seem to appear (ladders, windows, lamps). Try clicking on the floor tile the object would lie on.',
    [17] = 'If you want to trade an item with another player, right-click on the item and select \'Trade with ...\', then click on the player with whom you want to trade.',
    [18] = 'Stairs, ladders and dungeon entrances are marked as yellow dots on the automap.',
    [19] = 'You can get food by killing animals or monsters. You can also pick blueberries or bake your own bread. If you are too lazy or own too much money, you can also buy food.',
    [20] = 'Quest containers can be recognised easily. They don\'t open up regularly but display a message \'You have found ....\'. They can only be opened once.',
    [21] = 'Better run away than risk to die. You\'ll lose experience and skill points each time you die.',
    [22] = 'You can form a party by right-clicking on a player and selecting \'Invite to Party\'. The party leader can also enable \'Shared Experience\' by right-clicking on him- or herself.',
    [23] = 'You can assign spells, the use of items, or random text to \'hotkeys\'. You find them under \'Options\'.',
    [24] = 'You can also follow other players. Just right-click on the player and select \'Follow\'.',
    [25] = 'You can found a party with your friends by right-clicking on a player and selecting \'Invite to Party\'. If you are invited to a party, right-click on yourself and select \'Join Party\'.',
    [26] = 'Only found parties with people you trust. You can attack people in your party without getting a skull. This is helpful for training your skills, but can be abused to kill people without having to fear negative consequences.',
    [27] = 'The leader of a party has the option to distribute gathered experience among all players in the party. If you are the leader, right-click on yourself and select \'Enable Shared Experience\'.',
    [28] = 'There is nothing more I can tell you. If you are still in need of some {hints}, I can repeat them for you.'
}

function StdModule.rookgaardHints(cid, message, keywords, parameters, node)
    local npcHandler = parameters.npcHandler
    if npcHandler == nil then
        error("StdModule.say called without any npcHandler instance.")
    end

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

    local player = Player(cid)
    local hintId = player:getStorageValue(Storage.RookgaardHints)
    npcHandler:say(hints[hintId], cid)
    if hintId >= #hints then
        player:setStorageValue(Storage.RookgaardHints, -1)
    else
        player:setStorageValue(Storage.RookgaardHints, hintId + 1)
    end
    return true
end

-- VoiceModule
VoiceModule = {
    voices = nil,
    voiceCount = 0,
    lastVoice = 0,
    timeout = nil,
    chance = nil,
    npcHandler = nil
}

-- Creates a new instance of VoiceModule
function VoiceModule:new(voices, timeout, chance)
    local obj = {}
    setmetatable(obj, self)
    self.__index = self

    obj.voices = voices
    for i = 1, #obj.voices do
        local voice = obj.voices[i]
        if voice.yell then
            voice.yell = nil
            voice.talktype = TALKTYPE_YELL
        else
            voice.talktype = TALKTYPE_SAY
        end
    end

    obj.voiceCount = #voices
    obj.timeout = timeout or 10
    obj.chance = chance or 25
    return obj
end

function VoiceModule:init(handler)
    return true
end

function VoiceModule:callbackOnThink()
    if self.lastVoice < os.time() then
        self.lastVoice = os.time() + self.timeout
        if math.random(100) < self.chance  then
            local voice = self.voices[math.random(self.voiceCount)]
            Npc():say(voice.text, voice.talktype)
        end
    end
    return true
end

lib/core/string.lua

Lua:
string.split = function(str, sep)
    local res = {}
    for v in str:gmatch("([^" .. sep .. "]+)") do
        res[#res + 1] = v
    end
    return res
end

string.trim = function(str)
    return str:match'^()%s*$' and '' or str:match'^%s*(.*%S)'
end

string.starts = function(str, substr)
    return string.sub(str, 1, #substr) == substr
end

string.titleCase = function(str)
    return str:gsub("(%a)([%w_']*)", function(first, rest) return first:upper() .. rest:lower() end)
end
Thanks a lot. it worked for me. but i got one last problem, the npcs are not charging the designed cost, do you know why?
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 and Port Hope.'} }
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})


addTravelKeyword('carlin', 110, Position(32387, 31821, 7), function(player) if player:getStorageValue(2005) == 1 then player:setStorageValue(2005, 2) end end)
addTravelKeyword('ab\'dendriel', 130, Position(32733, 31667, 7))
addTravelKeyword('edron', 160, Position(33178, 31768, 7))
addTravelKeyword('venore', 170, Position(32958, 32024, 7))
addTravelKeyword('port hope', 160, Position(32532, 32784, 6))
addTravelKeyword('svargrond', 180, Position(32341, 31108, 6))
addTravelKeyword('liberty bay', 180, Position(32285, 32892, 6))

-- Kick
keywordHandler:addKeyword({'kick'}, StdModule.kick, {npcHandler = npcHandler, destination = {Position(32320, 32219, 6), Position(32321, 32210, 6)}})
   
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 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 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 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 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 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 or Svargrond?'})
keywordHandler:addKeyword({'travel'}, StdModule.say, {npcHandler = npcHandler, text = 'Where do you want to go? To Carlin, Ab\'Dendriel, Edron, Venore, Port Hope, Liberty Bay 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())
Code:
21:13 Captain Bluebear: Do you seek a passage to Venore for free?
i got no error in console
 
Last edited:
Thanks a lot. it worked for me. but i got one last problem, the npcs are not charging the designed cost, do you know why?
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 and Port Hope.'} }
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})


addTravelKeyword('carlin', 110, Position(32387, 31821, 7), function(player) if player:getStorageValue(2005) == 1 then player:setStorageValue(2005, 2) end end)
addTravelKeyword('ab\'dendriel', 130, Position(32733, 31667, 7))
addTravelKeyword('edron', 160, Position(33178, 31768, 7))
addTravelKeyword('venore', 170, Position(32958, 32024, 7))
addTravelKeyword('port hope', 160, Position(32532, 32784, 6))
addTravelKeyword('svargrond', 180, Position(32341, 31108, 6))
addTravelKeyword('liberty bay', 180, Position(32285, 32892, 6))

-- Kick
keywordHandler:addKeyword({'kick'}, StdModule.kick, {npcHandler = npcHandler, destination = {Position(32320, 32219, 6), Position(32321, 32210, 6)}})
 
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 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 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 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 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 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 or Svargrond?'})
keywordHandler:addKeyword({'travel'}, StdModule.say, {npcHandler = npcHandler, text = 'Where do you want to go? To Carlin, Ab\'Dendriel, Edron, Venore, Port Hope, Liberty Bay 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())
Code:
21:13 Captain Bluebear: Do you seek a passage to Venore for free?
i got no error in console

Hmm you should review |TRAVELCOST!, can't review the npc right now but use this one, it is much more clean.
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

-- Travel
local function addTravelKeyword(keyword, cost, destination)
    local travelKeyword = keywordHandler:addKeyword({keyword}, StdModule.say, {npcHandler = npcHandler, text = 'Do you want to sail to Mi\'hen for 20 gold coins?', cost = cost})
        travelKeyword:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = false, cost = cost, destination = destination})
        travelKeyword:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, text = 'We would like to serve you some time.', reset = true})
end

addTravelKeyword('mi\'hen', 20, Position(1343, 982, 6))
addTravelKeyword('mihen', 20, Position(1343, 982, 6))

-- Basic
keywordHandler:addKeyword({'passage'}, StdModule.say, {npcHandler = npcHandler, text = 'Where do you want to go? To {Mi\'hen}?'})
keywordHandler:addKeyword({'travel'}, StdModule.say, {npcHandler = npcHandler, text = 'I can travel to {Mi\'hen}.'})
keywordHandler:addKeyword({'job'}, StdModule.say, {npcHandler = npcHandler, text = 'I am the captain of this ship.'})
keywordHandler:addKeyword({'kilika'}, StdModule.say, {npcHandler = npcHandler, text = 'This is Kilika.'})


npcHandler:addModule(FocusModule:new())
 
Hmm you should review |TRAVELCOST!, can't review the npc right now but use this one, it is much more clean.
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

-- Travel
local function addTravelKeyword(keyword, cost, destination)
    local travelKeyword = keywordHandler:addKeyword({keyword}, StdModule.say, {npcHandler = npcHandler, text = 'Do you want to sail to Mi\'hen for 20 gold coins?', cost = cost})
        travelKeyword:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = false, cost = cost, destination = destination})
        travelKeyword:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, text = 'We would like to serve you some time.', reset = true})
end

addTravelKeyword('mi\'hen', 20, Position(1343, 982, 6))
addTravelKeyword('mihen', 20, Position(1343, 982, 6))

-- Basic
keywordHandler:addKeyword({'passage'}, StdModule.say, {npcHandler = npcHandler, text = 'Where do you want to go? To {Mi\'hen}?'})
keywordHandler:addKeyword({'travel'}, StdModule.say, {npcHandler = npcHandler, text = 'I can travel to {Mi\'hen}.'})
keywordHandler:addKeyword({'job'}, StdModule.say, {npcHandler = npcHandler, text = 'I am the captain of this ship.'})
keywordHandler:addKeyword({'kilika'}, StdModule.say, {npcHandler = npcHandler, text = 'This is Kilika.'})


npcHandler:addModule(FocusModule:new())
the thing is that every npc boat that i use, doesn't charge players money,
every npc that i have tested offers players free travel. including your script i tested it too
something must be wrong in libraries or don't know
 
the thing is that every npc boat that i use, doesn't charge players money,
every npc that i have tested offers players free travel. including your script i tested it too
something must be wrong in libraries or don't know
Which distribution are you using?
Here is my npc/lib folder
 

Attachments

Back
Top