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 treiner = {x=1,y=1,z=1} -- local dos treiner
if msgcontains(msg, "travel") or msgcontains(msg, "Travel") then
t1,t2,t3 = getPlayerStorageValue(cid, 3207),getPlayerStorageValue(cid, 3208),getPlayerStorageValue(cid, 3209)
if t1 == -1 then
selfSay("Posso te levar para {treiner}.", cid)
talkState[talkUser] = 1
else
selfSay("Se vc esta falando comigo eh pq deseja voltar para o mundo inferior?", cid)
talkState[talkUser] = 2
end
elseif talkState[talkUser] == 1 and msgcontains(msg, "treiner") then
pos = getPlayerPosition(cid)
savepos = {x=pos.x, y=pos.y, z=pos.z, stackpos=253}
w = {{3207,savepos.x}, {3208,savepos.y}, {3209,savepos.z}}
for i=1, #w do
setPlayerStorageValue(cid, w[i][1], w[i][2])
end
doTeleportThing(cid, treiner)
doSendMagicEffect(treiner, 10)
selfSay("Boa viagem.", cid)
talkState[talkUser] = 0
elseif talkState[talkUser] == 2 and msgcontains(msg, "yes") then
local spos = {x=t1, y=t2, z=t3}
doTeleportThing(cid, spos)
doSendMagicEffect(spos, 10)
for i=1, #w do
setPlayerStorageValue(cid, w[i][1], -1)
end
selfSay("Boa viagem.", cid)
talkState[talkUser] = 0
end
return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())