local config = {
["city1"] = {str = 12000, pos = {x = 1, y = 2, z = 3}},
["city2"] = {str = 12001, pos = {x = 1, y = 2, z = 3}},
["city3"] = {str = 12002, pos = {x = 1, y = 2, z = 3}}
}
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 creatureSayCallback(cid, type, msg)
if not npcHandler:isFocused(cid) then
return false
end
msg = string.lower(msg)
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if msgcontains(msg, 'city1') or msgcontains(msg, 'city2') or msgcontains(msg, 'city3') then
local city = config[msg]
if getPlayerStorageValue(cid, city.str) > 0 then
doTeleportThing(cid, city.pos)
doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
talkState[talkUser] = 0
selfSay("Chegamos!", cid)
else
selfSay("Voce nao tem permissao para esta viagem.", cid)
talkState[talkUser] = 0
end
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())