• 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.X+ |playername|, |travelcost| etc dont work tfs 1.3

Thorn

Spriting since 2013
Joined
Sep 24, 2012
Messages
2,203
Solutions
1
Reaction score
921
Location
Chile
Hello guys! i have tfs 1.3 and aparently a good npc lib, but this still doesn't work, in game it looks like: "the cost for your journey is |travelcost|" :/
this is what i have in npcsystem.lua, this is all i know it's related, plz help me out with this, is very annoying, if i need to post something else plz tellme

Lua:
-- Advanced NPC System by Jiddo

shop_amount = {}
shop_cost = {}
shop_rlname = {}
shop_itemid = {}
shop_container = {}
shop_npcuid = {}
shop_eventtype = {}
shop_subtype = {}
shop_destination = {}
shop_premium = {}

npcs_loaded_shop = {}
npcs_loaded_travel = {}

if NpcSystem == nil then
    -- Loads the underlying classes of the npcsystem.
    dofile('data/npc/lib/npcsystem/keywordhandler.lua')
    dofile('data/npc/lib/npcsystem/npchandler.lua')
    dofile('data/npc/lib/npcsystem/modules.lua')

    -- Global npc constants:

    -- Greeting and unGreeting keywords. For more information look at the top of modules.lua
    FOCUS_GREETWORDS = {'hi', 'hello'}
    FOCUS_FAREWELLWORDS = {'bye', 'farewell'}

    -- The word for requesting trade window. For more information look at the top of modules.lua
    SHOP_TRADEREQUEST = {'trade'}

    -- The word for accepting/declining an offer. CAN ONLY CONTAIN ONE FIELD! For more information look at the top of modules.lua
    SHOP_YESWORD = {'yes'}
    SHOP_NOWORD = {'no'}

    -- Pattern used to get the amount of an item a player wants to buy/sell.
    PATTERN_COUNT = '%d+'

    -- Talkdelay behavior. For more information, look at the top of npchandler.lua.
    NPCHANDLER_TALKDELAY = TALKDELAY_ONTHINK

    -- Constant strings defining the keywords to replace in the default messages.
    --    For more information, look at the top of npchandler.lua...
    TAG_PLAYERNAME = '|PLAYERNAME|'
    TAG_ITEMCOUNT = '|ITEMCOUNT|'
    TAG_TOTALCOST = '|TOTALCOST|'
    TAG_ITEMNAME = '|ITEMNAME|'
    TAG_TIME = '|TIME|'
    TAG_BLESSCOST = '|BLESSCOST|'
    TAG_PVPBLESSCOST = '|PVPBLESSCOST|'
    TAG_TRAVELCOST = '|TRAVELCOST|'

    NpcSystem = {}

    -- Gets an npcparameter with the specified key. Returns nil if no such parameter is found.
    function NpcSystem.getParameter(key)
        local ret = getNpcParameter(tostring(key))
        if (type(ret) == 'number' and ret == 0) or ret == nil then
            return nil
        else
            return ret
        end
    end

    -- Parses all known parameters for the npc. Also parses parseable modules.
    function NpcSystem.parseParameters(npcHandler)
        local ret = NpcSystem.getParameter('idletime')
        if ret ~= nil then
            npcHandler.idleTime = tonumber(ret)
        end
        local ret = NpcSystem.getParameter('talkradius')
        if ret ~= nil then
            npcHandler.talkRadius = tonumber(ret)
        end
        local ret = NpcSystem.getParameter('message_greet')
        if ret ~= nil then
            npcHandler:setMessage(MESSAGE_GREET, ret)
        end
        local ret = NpcSystem.getParameter('message_farewell')
        if ret ~= nil then
            npcHandler:setMessage(MESSAGE_FAREWELL, ret)
        end
        local ret = NpcSystem.getParameter('message_decline')
        if ret ~= nil then
            npcHandler:setMessage(MESSAGE_DECLINE, ret)
        end
        local ret = NpcSystem.getParameter('message_needmorespace')
        if ret ~= nil then
            npcHandler:setMessage(MESSAGE_NEEDMORESPACE, ret)
        end
        local ret = NpcSystem.getParameter('message_needspace')
        if ret ~= nil then
            npcHandler:setMessage(MESSAGE_NEEDSPACE, ret)
        end
        local ret = NpcSystem.getParameter('message_sendtrade')
        if ret ~= nil then
            npcHandler:setMessage(MESSAGE_SENDTRADE, ret)
        end
        local ret = NpcSystem.getParameter('message_noshop')
        if ret ~= nil then
            npcHandler:setMessage(MESSAGE_NOSHOP, ret)
        end
        local ret = NpcSystem.getParameter('message_oncloseshop')
        if ret ~= nil then
            npcHandler:setMessage(MESSAGE_ONCLOSESHOP, ret)
        end
        local ret = NpcSystem.getParameter('message_onbuy')
        if ret ~= nil then
            npcHandler:setMessage(MESSAGE_ONBUY, ret)
        end
        local ret = NpcSystem.getParameter('message_onsell')
        if ret ~= nil then
            npcHandler:setMessage(MESSAGE_ONSELL, ret)
        end
        local ret = NpcSystem.getParameter('message_missingmoney')
        if ret ~= nil then
            npcHandler:setMessage(MESSAGE_MISSINGMONEY, ret)
        end
        local ret = NpcSystem.getParameter('message_needmoney')
        if ret ~= nil then
            npcHandler:setMessage(MESSAGE_NEEDMONEY, ret)
        end
        local ret = NpcSystem.getParameter('message_missingitem')
        if ret ~= nil then
            npcHandler:setMessage(MESSAGE_MISSINGITEM, ret)
        end
        local ret = NpcSystem.getParameter('message_needitem')
        if ret ~= nil then
            npcHandler:setMessage(MESSAGE_NEEDITEM, ret)
        end
        local ret = NpcSystem.getParameter('message_idletimeout')
        if ret ~= nil then
            npcHandler:setMessage(MESSAGE_IDLETIMEOUT, ret)
        end
        local ret = NpcSystem.getParameter('message_walkaway')
        if ret ~= nil then
            npcHandler:setMessage(MESSAGE_WALKAWAY, ret)
        end
        local ret = NpcSystem.getParameter('message_alreadyfocused')
        if ret ~= nil then
            npcHandler:setMessage(MESSAGE_ALREADYFOCUSED, ret)
        end
        local ret = NpcSystem.getParameter('message_buy')
        if ret ~= nil then
            npcHandler:setMessage(MESSAGE_BUY, ret)
        end
        local ret = NpcSystem.getParameter('message_sell')
        if ret ~= nil then
            npcHandler:setMessage(MESSAGE_SELL, ret)
        end
        local ret = NpcSystem.getParameter('message_bought')
        if ret ~= nil then
            npcHandler:setMessage(MESSAGE_BOUGHT, ret)
        end
        local ret = NpcSystem.getParameter('message_sold')
        if ret ~= nil then
            npcHandler:setMessage(MESSAGE_SOLD, ret)
        end
        local ret = NpcSystem.getParameter('message_walkaway_male')
        if ret ~= nil then
            npcHandler:setMessage(MESSAGE_WALKAWAY_MALE, ret)
        end
        local ret = NpcSystem.getParameter('message_walkaway_female')
        if ret ~= nil then
            npcHandler:setMessage(MESSAGE_WALKAWAY_FEMALE, ret)
        end

        -- Parse modules.
        for parameter, module in pairs(Modules.parseableModules) do
            local ret = NpcSystem.getParameter(parameter)
            if ret ~= nil then
                local number = tonumber(ret)
                if number ~= 0 and module.parseParameters ~= nil then
                    local instance = module:new()
                    npcHandler:addModule(instance)
                    instance:parseParameters()
                end
            end
        end
    end
end
 
Bump! This is a sample npc that has this travelcost thingy
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 = 'Pasajes a Garuda, Edring, Liberty bay, Infernum, Pofulthorn, Liberty Bay y Azurthis.'} }

-- Travel
local function addTravelKeyword(keyword, cost, destination, action)
    local travelKeyword = keywordHandler:addKeyword({keyword}, StdModule.say, {npcHandler = npcHandler, text = 'Buscas pasaje a ' .. keyword:titleCase() .. ' por |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 = 'Feliz de ayudarte comarada.', reset = true})
end

addTravelKeyword('garuda', 500, Position(944, 981, 6), function(player) if player:getStorageValue(Storage.postman.Mission01) == 1 then player:setStorageValue(Storage.postman.Mission01, 2) end end)
addTravelKeyword('edring', 500, Position(2154, 472, 6))
addTravelKeyword('liberty bay', 500, Position(1571, 508, 6))
addTravelKeyword('infernum', 500, Position(799, 979, 6))
addTravelKeyword('pofulthorn', 500, Position(3086, 597, 6))
addTravelKeyword('azurthis', 500, Position(694, 1270, 6))

-- Kick
keywordHandler:addKeyword({'kick'}, StdModule.kick, {npcHandler = npcHandler, destination = {Position(32320, 32219, 6), Position(32321, 32210, 6)}})

-- Basic
keywordHandler:addKeyword({'fenix'}, StdModule.say, {npcHandler = npcHandler, text = 'Quieres saber sobre el fenix Garuda? HAHAHA ¿Quieres enfrentarte a el? Olvidalo! No tienes {oportunidad}...'})
keywordHandler:addKeyword({'phoenix'}, StdModule.say, {npcHandler = npcHandler, text = 'Quieres saber sobre el fenix Garuda? HAHAHA ¿Quieres enfrentarte a el? Olvidalo! No tienes oportunidad...'})
keywordHandler:addKeyword({'oportunidad'}, StdModule.say, {npcHandler = npcHandler, text = 'Ok mira, nadie sabe donde se encuentra con exactitud, pero dicen que tienes que hacer el rebirth muchas veces, es todo lo que se, ahora dejame en paz.'})
keywordHandler:addKeyword({'ruta'}, StdModule.say, {npcHandler = npcHandler, text = 'Solo viajo a ciertas ciudades, hay otras donde no me dejan entrar, pero si eres vip puedes ir.'})
keywordHandler:addKeyword({'trip'}, StdModule.say, {npcHandler = npcHandler, text = 'A donde quieres ir? a {garuda}, {edring}, {liberty bay}, {infernum}, {pofulthorn} o {azurthis}?'})
keywordHandler:addKeyword({'pasaje'}, StdModule.say, {npcHandler = npcHandler, text = 'A donde quieres ir? a {garuda}, {edring}, {liberty bay}, {infernum}, {pofulthorn} o {azurthis}?'})
keywordHandler:addKeyword({'sail'}, StdModule.say, {npcHandler = npcHandler, text = 'A donde quieres ir? a {garuda}, {edring}, {liberty bay}, {infernum} o {azurthis}?'})
npcHandler:setMessage(MESSAGE_GREET, 'Bienvenido a bordo, |PLAYERNAME|. quieres un {pasaje} para hoy?')
npcHandler:setMessage(MESSAGE_FAREWELL, 'Adios. Recomiendame a tus amigos.')
npcHandler:setMessage(MESSAGE_WALKAWAY, 'Adios entonces.')

npcHandler:addModule(FocusModule:new())
 
Bump! This is a sample npc that has this travelcost thingy
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 = 'Pasajes a Garuda, Edring, Liberty bay, Infernum, Pofulthorn, Liberty Bay y Azurthis.'} }

-- Travel
local function addTravelKeyword(keyword, cost, destination, action)
    local travelKeyword = keywordHandler:addKeyword({keyword}, StdModule.say, {npcHandler = npcHandler, text = 'Buscas pasaje a ' .. keyword:titleCase() .. ' por |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 = 'Feliz de ayudarte comarada.', reset = true})
end

addTravelKeyword('garuda', 500, Position(944, 981, 6), function(player) if player:getStorageValue(Storage.postman.Mission01) == 1 then player:setStorageValue(Storage.postman.Mission01, 2) end end)
addTravelKeyword('edring', 500, Position(2154, 472, 6))
addTravelKeyword('liberty bay', 500, Position(1571, 508, 6))
addTravelKeyword('infernum', 500, Position(799, 979, 6))
addTravelKeyword('pofulthorn', 500, Position(3086, 597, 6))
addTravelKeyword('azurthis', 500, Position(694, 1270, 6))

-- Kick
keywordHandler:addKeyword({'kick'}, StdModule.kick, {npcHandler = npcHandler, destination = {Position(32320, 32219, 6), Position(32321, 32210, 6)}})

-- Basic
keywordHandler:addKeyword({'fenix'}, StdModule.say, {npcHandler = npcHandler, text = 'Quieres saber sobre el fenix Garuda? HAHAHA ¿Quieres enfrentarte a el? Olvidalo! No tienes {oportunidad}...'})
keywordHandler:addKeyword({'phoenix'}, StdModule.say, {npcHandler = npcHandler, text = 'Quieres saber sobre el fenix Garuda? HAHAHA ¿Quieres enfrentarte a el? Olvidalo! No tienes oportunidad...'})
keywordHandler:addKeyword({'oportunidad'}, StdModule.say, {npcHandler = npcHandler, text = 'Ok mira, nadie sabe donde se encuentra con exactitud, pero dicen que tienes que hacer el rebirth muchas veces, es todo lo que se, ahora dejame en paz.'})
keywordHandler:addKeyword({'ruta'}, StdModule.say, {npcHandler = npcHandler, text = 'Solo viajo a ciertas ciudades, hay otras donde no me dejan entrar, pero si eres vip puedes ir.'})
keywordHandler:addKeyword({'trip'}, StdModule.say, {npcHandler = npcHandler, text = 'A donde quieres ir? a {garuda}, {edring}, {liberty bay}, {infernum}, {pofulthorn} o {azurthis}?'})
keywordHandler:addKeyword({'pasaje'}, StdModule.say, {npcHandler = npcHandler, text = 'A donde quieres ir? a {garuda}, {edring}, {liberty bay}, {infernum}, {pofulthorn} o {azurthis}?'})
keywordHandler:addKeyword({'sail'}, StdModule.say, {npcHandler = npcHandler, text = 'A donde quieres ir? a {garuda}, {edring}, {liberty bay}, {infernum} o {azurthis}?'})
npcHandler:setMessage(MESSAGE_GREET, 'Bienvenido a bordo, |PLAYERNAME|. quieres un {pasaje} para hoy?')
npcHandler:setMessage(MESSAGE_FAREWELL, 'Adios. Recomiendame a tus amigos.')
npcHandler:setMessage(MESSAGE_WALKAWAY, 'Adios entonces.')

npcHandler:addModule(FocusModule:new())
Line 14
Lua:
local travelKeyword = keywordHandler:addKeyword({keyword}, StdModule.say, {npcHandler = npcHandler, text = 'Buscas pasaje a ' .. keyword:titleCase() .. ' por |TRAVELCOST|?', cost = cost, discount = 'postman'})
change to
Lua:
local travelKeyword = keywordHandler:addKeyword({keyword}, StdModule.say, {npcHandler = npcHandler, text = 'Buscas pasaje a ' .. keyword:titleCase() .. ' por ' .. |TRAVELCOST| .. '?', cost = cost, discount = 'postman'})
----------
Line 37
Lua:
npcHandler:setMessage(MESSAGE_GREET, 'Bienvenido a bordo, |PLAYERNAME|. quieres un {pasaje} para hoy?')
change to
Lua:
npcHandler:setMessage(MESSAGE_GREET, 'Bienvenido a bordo, ' .. |PLAYERNAME| .. '. quieres un {pasaje} para hoy?')
 
Line 14
Lua:
local travelKeyword = keywordHandler:addKeyword({keyword}, StdModule.say, {npcHandler = npcHandler, text = 'Buscas pasaje a ' .. keyword:titleCase() .. ' por |TRAVELCOST|?', cost = cost, discount = 'postman'})
change to
Lua:
local travelKeyword = keywordHandler:addKeyword({keyword}, StdModule.say, {npcHandler = npcHandler, text = 'Buscas pasaje a ' .. keyword:titleCase() .. ' por ' .. |TRAVELCOST| .. '?', cost = cost, discount = 'postman'})
----------
Line 37
Lua:
npcHandler:setMessage(MESSAGE_GREET, 'Bienvenido a bordo, |PLAYERNAME|. quieres un {pasaje} para hoy?')
change to
Lua:
npcHandler:setMessage(MESSAGE_GREET, 'Bienvenido a bordo, ' .. |PLAYERNAME| .. '. quieres un {pasaje} para hoy?')
Code:
[Warning - NpcScript::NpcScript] Can not load script: Captain Bluebear.lua
data/npc/scripts/Captain Bluebear.lua:14: unexpected symbol near '|'
 
Code:
[Warning - NpcScript::NpcScript] Can not load script: Captain Bluebear.lua
data/npc/scripts/Captain Bluebear.lua:14: unexpected symbol near '|'
hmmm, guess post
data/npc/lib/npcsystem/npchandler.lua
Since that's where it's all stored.
 
You are missing this line:
orts/server

In yours.
nice, should i just replace the whole thing? the weird thing is that |PLAYERNAME| is there, but doesn't work for me either

well...i just replaced the whole file and still im getting this:
15:03 Captain Bluebear: Buscas pasaje a Garuda por |TRAVELCOST|?

:(
 
Last edited:
This is the three places ,you need to define it:
orts/server
orts/server
orts/server
i have everything declarated in my libraries but travel cost still doesn't works. can somebody help me please?
also added code lines displayed in this thread
 
Last edited:
Change it back to include it into a string
Ye i know it. error will gone but ingame will still problem that NPC will not say price of travel(example: I can bring you to Thais for 160gp) but it will say (I can bring you to Thais for |TRAVELCOST| )
 
For anyone still needing a fix for this:

The npc file uses a custom local function, so you just need to replace "|TRAVELCOST|" with the cost variable as such:

change:
Lua:
local travelKeyword = keywordHandler:addKeyword({keyword}, StdModule.say, {npcHandler = npcHandler, text = 'Would you like to go to ' .. keyword:titleCase() .. ' for |TRAVELCOST|?', cost = cost, discount = 'postman'})

to:
Lua:
local travelKeyword = keywordHandler:addKeyword({keyword}, StdModule.say, {npcHandler = npcHandler, text = 'Would you like to go to ' .. keyword:titleCase() .. ' for '.. cost ..'gp?', cost = cost, discount = 'postman'})
 
how to fix this?
Lua:
 {'Would you like to receive that protection for a sacrifice of |PVPBLESSCOST| gold, child?'}})

Code:
23:16 Quentin: Would you like to receive that protection for a sacrifice of |PVPBLESSCOST| gold, child?

i've tried thigs like
Code:
'.. |PVPBLESSCOST| ..'
but i get errors in console


solved missing parse info at modules.lua
Lua:
        local parseInfo = {[TAG_PLAYERNAME] = player:getName(), [TAG_TIME] = getTibianTime(), [TAG_BLESSCOST] = getBlessingsCost(player:getLevel()), [TAG_PVPBLESSCOST] = getPvpBlessingCost(player:getLevel()), [TAG_TRAVELCOST] = costMessage}
 
Last edited:
Back
Top