local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local list, t, cost = {
['north'] = {x=100, y=100, z=7},
['west'] = {x=100, y=100, z=7},
['east'] = {x=100, y=100, z=7}
}, {}, {}
local storage = 123
cost.normal = 20
cost.cheap = 10
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 greetCallback(cid)
if getCreatureStorage(cid, storage) == -1 then
npcHandler:setMessage(MESSAGE_GREET, 'Hello |PLAYERNAME|, what can I do for you ?')
else
npcHandler:setMessage(MESSAGE_GREET, 'Hello |PLAYERNAME|, what can I do for you? You have strong storage Xdd!?')
end
t[cid] = nil
return true
end
function creatureSayCallback(cid, type, msg)
if not npcHandler:isFocused(cid) then
return false
elseif t[cid] then
if msgcontains(msg, 'yes') then
if doPlayerRemoveMoney(cid, getCreatureStorage(cid, storage) == -1 and cost.normal or cost.cheap) then
npcHandler:say('Here we go!', cid)
npcHandler:releaseFocus(cid)
local p = getThingPos(cid)
doTeleportThing(cid, list[t[cid]])
doSendMagicEffect(p, CONST_ME_TELEPORT)
doSendMagicEffect(list[t[cid]], CONST_ME_TELEPORT)
else
npcHandler:say('You don\'t have enough money.', cid)
end
else
npcHandler:say('Perhaps next time.', cid)
end
elseif msgcontains(msg, 'travel') then
local s = {}
for k, v in pairs(list) do
table.insert(s, '{' .. k .. '}')
end
npcHandler:say('I can travel you to: ' .. table.concat(s, ', ') .. '.', cid)
else
for k, v in pairs(list) do
if msgcontains(msg, k) then
t[cid] = k
npcHandler:say('Do you want to travel to ' .. k .. ' for ' .. (getCreatureStorage(cid, storage) == -1 and cost.normal or cost.cheap) ..' gold?', cid)
break
end
end
end
return true
end
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())