• 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+ tfs 1.5 storage in boat npc

bpm91

Intermediate OT User
Joined
May 23, 2019
Messages
926
Solutions
7
Reaction score
127
Location
Brazil
YouTube
caruniawikibr
hi guys, i need to make the npc make me travel only if i have the storage
player:setStorageValue(ORC_FACTION.FACTION_STORAGE, 2)
if I don't have the npc I would say that I don't have access



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 travelKeyword = keywordHandler:addKeyword({'liberty bay'}, StdModule.say, {npcHandler = npcHandler, text = 'I can bring you to our base in Liberty Bay for 400? Is that what you want?', cost = 400})
    travelKeyword:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = true, cost = 400, destination = Position(32285, 32892, 6)})
    travelKeyword:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, text = 'We would like to serve you some time.', reset = true})
keywordHandler:addAliasKeyword({'passage'})


npcHandler:setMessage(MESSAGE_GREET, "Greetings, daring adventurer. If you need a passage, let me know.")
npcHandler:setMessage(MESSAGE_FAREWELL, "Good bye.")
npcHandler:setMessage(MESSAGE_WALKAWAY, "Good bye.")
npcHandler:addModule(FocusModule:new())
 
Solution
Go in data/npc/lib/modules.lua

Search for:
Lua:
npcHandler:say("You must reach level " .. parameters.level .. " before I can let you go there.", cid)

After paste this:
Lua:
            elseif(parameters.storageId ~= nil and getPlayerStorageValue(cid, parameters.storageId) < parameters.storageValue) then
                npcHandler:say(parameters.storageInfo or 'You may not travel there yet!', cid)


In the npc, simply use this:
Lua:
local travelNode = keywordHandler:addKeyword({'passage'}, StdModule.say, {npcHandler = npcHandler, text = 'Do you seek a passage to the isle of the kings for 10 gold coins?'})
    travelNode:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = false, text = 'Have a nice...
I didn't test

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 travelKeyword = keywordHandler:addKeyword({'liberty bay'}, StdModule.say, {npcHandler = npcHandler, text = 'I can bring you to our base in Liberty Bay for 400? Is that what you want?', cost = 400})
    travelKeyword:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = true, cost = 400, destination = Position(32285, 32892, 6)})
    travelKeyword:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, text = 'We would like to serve you some time.', reset = true})
keywordHandler:addAliasKeyword({'passage'})

    if keyword == 'exemple city' then
        keywordHandler:addKeyword({keyword}, StdModule.say, {npcHandler = npcHandler, text = 'I\'m sorry but I don\'t sail there.'}, function(player) return player:getStorageValue(ORC_FACTION.FACTION_STORAGE, 2) < 1 end)
    end


npcHandler:setMessage(MESSAGE_GREET, "Greetings, daring adventurer. If you need a passage, let me know.")
npcHandler:setMessage(MESSAGE_FAREWELL, "Good bye.")
npcHandler:setMessage(MESSAGE_WALKAWAY, "Good bye.")
npcHandler:addModule(FocusModule:new())
 
I use it like this in TFS 1.5

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 Exemple and Exemple City.'} }
npcHandler:addModule(VoiceModule:new(voices))

-- Travel
local function addTravelKeyword(keyword, text, cost, destination)
    if keyword == 'exemple' then
        keywordHandler:addKeyword({keyword}, StdModule.say, {npcHandler = npcHandler, text = 'I\'m sorry but we don\'t serve this route.'}, function(player) return player:getStorageValue(Storage.ExplorerSociety.CalassaQuest) < 1 end)
    end

    if keyword == 'exemple city' then
        keywordHandler:addKeyword({keyword}, StdModule.say, {npcHandler = npcHandler, text = 'I\'m sorry but I don\'t sail there.'}, function(player) return player:getStorageValue(ORC_FACTION.FACTION_STORAGE) < 2 end)
    end

    local travelKeyword = keywordHandler:addKeyword({keyword}, StdModule.say, {npcHandler = npcHandler, text = text, cost = cost, discount = 'postman'})
        travelKeyword:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = false, text = 'Hold on!', cost = cost, discount = 'postman', destination = destination})
        travelKeyword:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, text = 'You shouldn\'t miss the experience.', reset = true})

end

addTravelKeyword('exemple', 'Should I bring you to Exemple for 100 gold?', 100, Position(31695, 31983, 5))
--addTravelKeyword('exemple city', 100, Position(31325, 32692, 3))
addTravelKeyword('exemple city', 'Should I bring you to Exemple City for 185 gold?', 185, Position(33513, 32345, 4))



-- Basic
keywordHandler:addKeyword({'sail'}, StdModule.say, {npcHandler = npcHandler, text = 'Where do you want to go? To {Exemple}, {Exemple City}?'})
keywordHandler:addKeyword({'passage'}, StdModule.say, {npcHandler = npcHandler, text = 'Where do you want to go? To {Exemple City}, {Exemple}?'})
keywordHandler:addKeyword({'job'}, StdModule.say, {npcHandler = npcHandler, text = 'I am the captain of this ship.'})
keywordHandler:addKeyword({'captain'}, StdModule.say, {npcHandler = npcHandler, text = 'I am the captain of this ship.'})
keywordHandler:addKeyword({'exemple city'}, StdModule.say, {npcHandler = npcHandler, text = 'This is Exemple City. Where do you want to go?'})
keywordHandler:addKeyword({'name'}, StdModule.say, {npcHandler = npcHandler, text = 'My name is Baally Mohamed from the Royal Tibia Line.'})

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 change to
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 Exemple and Exemple City.'} }
npcHandler:addModule(VoiceModule:new(voices))

-- Travel
local function addTravelKeyword(keyword, text, cost, destination)
    if keyword == 'exemple' then
        keywordHandler:addKeyword({keyword}, StdModule.say, {npcHandler = npcHandler, text = 'I\'m sorry but we don\'t serve this route.'}, function(player) return player:getStorageValue(550) < 1 end)
    end

    local travelKeyword = keywordHandler:addKeyword({keyword}, StdModule.say, {npcHandler = npcHandler, text = text, cost = cost})
        travelKeyword:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = false, text = 'Hold on!', cost = cost, destination = destination})
        travelKeyword:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, text = 'You shouldn\'t miss the experience.', reset = true})

end

addTravelKeyword('exemple', 'Should I bring you to Exemple for 100 gold?', 100, Position(31695, 31983, 5))


-- Basic
keywordHandler:addKeyword({'sail'}, StdModule.say, {npcHandler = npcHandler, text = 'Where do you want to go? To {Exemple}, {Exemple City}?'})
keywordHandler:addKeyword({'passage'}, StdModule.say, {npcHandler = npcHandler, text = 'Where do you want to go? To {Exemple City}, {Exemple}?'})
keywordHandler:addKeyword({'job'}, StdModule.say, {npcHandler = npcHandler, text = 'I am the captain of this ship.'})
keywordHandler:addKeyword({'captain'}, StdModule.say, {npcHandler = npcHandler, text = 'I am the captain of this ship.'})
keywordHandler:addKeyword({'exemple city'}, StdModule.say, {npcHandler = npcHandler, text = 'This is Exemple City. Where do you want to go?'})
keywordHandler:addKeyword({'name'}, StdModule.say, {npcHandler = npcHandler, text = 'My name is Baally Mohamed from the Royal Tibia Line.'})

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())
but no travel
npc only say 'I\'m sorry but we don\'t serve this route
 
Go in data/npc/lib/modules.lua

Search for:
Lua:
npcHandler:say("You must reach level " .. parameters.level .. " before I can let you go there.", cid)

After paste this:
Lua:
            elseif(parameters.storageId ~= nil and getPlayerStorageValue(cid, parameters.storageId) < parameters.storageValue) then
                npcHandler:say(parameters.storageInfo or 'You may not travel there yet!', cid)


In the npc, simply use this:
Lua:
local travelNode = keywordHandler:addKeyword({'passage'}, StdModule.say, {npcHandler = npcHandler, text = 'Do you seek a passage to the isle of the kings for 10 gold coins?'})
    travelNode:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = false, text = 'Have a nice trip!', cost = 10, destination = Position(32186, 31959, 7), storageId = Storage.Carlin.IsleofKings, storageValue = 1, storageInfo = "Sorry, I cant take you there."})
    travelNode:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, reset = true, text = 'Well, I\'ll be here if you change your mind.'})

Change where is text, destination, premium, cost, storageId, storageValue and storageInfo as you wish!

storageValue is the minimum you want the player to have, if you want only player with value 2 to travel, put 2
storageInfo is the phrase that the npc will say if the player doesn't have the quest, or if you leave it blank, deleting this parameter, the npc will always say "You may not travel there yet!"
 
Solution
ty so much, one friend made me the script

maybe more simple

Lua:
local topic = {}

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 function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    end

    local player = Player(cid)

    if msgcontains(msg, "travel") or msgcontains(msg, "passage") or msgcontains(msg, "venore") or msgcontains(msg, "back") then
        if player:getStorageValue(ORC_FACTION.FACTION_STORAGE) < 2 then
            npcHandler:say("You have no permission to travel with me.", cid)
            return true
        end

        npcHandler:say("Would you like to travel to Venore?", cid)
        topic[cid] = 1
        return true
    end

    if topic[cid] == 1 then
        if msgcontains(msg, "yes") then
            player:teleportTo({x = 32852, y = 31975, z = 7})
            player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
        else
            npcHandler:say("Maybe at another time then.", cid)
        end
        topic[cid] = 0
        return true
    end

    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Back
Top