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

A script about Travel NPC [Help Please]

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 travelNode = keywordHandler:addKeyword({'city'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you wish to travel to City for 50 gold coins?'})
travelNode:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = true, level = 1, cost = 50, destination = {x=993, y=1106, z=7} })
travelNode:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'I wouldn\'t go there either.'})

keywordHandler:addKeyword({'help'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I can take you to City.'})


npcHandler:addModule(FocusModule:new())

Add this to npc/scripts/NAME.lua
Later, you create your npc and reload it.
 
Last edited:
Thanks but...
I need this script but with required level:

<?xml version="1.0" encoding="UTF-8"?>
<npc name="Captain Millar" script="data/npc/scripts/default.lua" walkinterval="1" floorchange="0" access="5" level="1" maglevel="1">
<health now="150" max="150"/>
<look type="129" head="60" body="113" legs="95" feet="115" addons="0"/>
<parameters>
<parameter key="message_greet" value="Welcome on board, |PLAYERNAME|. Passages to Yalahar city and Vengoth. Where can I sail you today?" />
<parameter key="module_travel" value="1" />
<parameter key="travel_destinations" value="yalahar,1969,907,7,50;vengoth,2229,1294,7,40" />

<parameter key="module_keywords" value="1" />
<parameter key="keywords" value="job" />
<parameter key="keyword_reply1" value="I'm the captain of this sailing ship." />
</parameters>
</npc>

You know make this?
 
Maybe you need create a file .lua

like this (untested)

Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
 
 
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end

function creatureSayCallback(cid, type, msg)

    if(npcHandler.focus ~= cid) then
        return false
    end
    
    if msgcontains(msg,'travel') then
        if getPlayerLevel(cid) > 0 then
            selfSay('I can travel you to {Yalahar} and {Vengoth}.')
        else
            selfSay('Sorry, you need level 1 or higher to travel with me.')
        end
    end
return 1    
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
 
 
local node1 = keywordHandler:addKeyword({'Yalahar'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you like travel to yalahar for 50 gold coins?'})
node1:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = true, price = 50, level = 10})
node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Then not.', reset = true})
 
 
local node2 = keywordHandler:addKeyword({'Vengoth'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you like travel to vengoth for 100 gold coins?'})
node2:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = true, price = 100, level = 10})
node2:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Then not.', reset = true})
 
npcHandler:addModule(FocusModule:new())
 
You guys didn't understand:p he want the densitations, city name etc be in the XML, Example.
PHP:
<parameter key="travel_destinations" value="yalahar,1969,907,7,50;vengoth,2229,1294,7,4 0" />

@Up!

We know it! but.. i don't know all parameters in the npcSystem :S!

I'm a sh*t in NPCs xD!
 
Back
Top