local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
-- OTServ event handling functions start
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
-- OTServ event handling functions end
local travelNode = keywordHandler:addKeyword({'gengia'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to travel to gengia?'})
travelNode:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = true, level = 0, cost = 0, destination = {x=34472, y=32697, z=6} })
travelNode:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Then stay here!'})
local travelNode = keywordHandler:addKeyword({'pyre'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to travel to pyre?'})
travelNode:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = true, level = 0, cost = 0, destination = {x=33623, y=4003, z=6} })
travelNode:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Then stay here!'})
local travelNode = keywordHandler:addKeyword({'oken'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to travel to oken?'})
travelNode:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = true, level = 0, cost = 0, destination = {x=19990, y=20008, z=6} })
travelNode:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Then stay here!'})
npcHandler:addModule(FocusModule:new())
Will be included in 0.3.5. Usage is simple like now 'level' - you'll need to set storage="YOUR_STORAGE"
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
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(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
local travels = {
["gengia"] = {talk=1, cost=0, level=0, stor=true, storId=34343, destination={x=34472, y=32697, z=6}},
["pyre"] = {talk=2, cost=0, level=0, stor=false, storId=43433, destination={x=33623, y=4003, z=6}}
}
for k, v in pairs(travels) do
if(msgcontains(msg, k)) then
if v.stor then
if getPlayerStorageValue(cid, v.storId) > 0 then
selfSay('Do you want to travel to '..k..' for '..v.cost..' gold coins?', cid)
talkState[talkUser] = v.talk
else
selfSay('You are not able to travel to this place?', cid)
talkState[talkUser] = 0
end
else
selfSay('Do you want to travel to '..k..' for '..v.cost..' gold coins?', cid)
talkState[talkUser] = v.talk
end
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == v.talk) then
if getPlayerLevel(cid) >= v.level then
if(doPlayerRemoveMoney(cid, v.cost) == TRUE) then
doTeleportThing(cid, v.destination, FALSE)
selfSay('Traveled to '..k..'.', cid)
else
selfSay('Sorry, you don\'t have enough gold coins.', cid)
end
else
selfSay('Sorry, you don\'t have enough level.', cid)
end
talkState[talkUser] = 0
elseif(msgcontains(msg, 'no') and isInArray({v.talk}, talkState[talkUser]) == TRUE) then
talkState[talkUser] = 0
selfSay('Ok then.', cid)
end
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
local travels = {
["gengia"] = {talk=1, cost=0, level=0, stor=true, storId=34343, destination={x=34472, y=32697, z=6}},
["pyre"] = {talk=2, cost=0, level=0, stor=false, storId=43433, destination={x=33623, y=4003, z=6}}
}
[] Brackets = The message you wll tell to the npc.
Talk = For each travel you add you most add +1
Level = Level to be able to travel
Stor = true/false
StorId = You only need to config this if "Stor" is equal true.
Destination = The destination to be traveled.