Fiz aqui bem rápido, porque já estou de saída. Qualquer erro, só postar.
Arquivo .lua do npc [data/npc/scripts]
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 cfg = {
vip1 = {x = xxx, y = yyy, z = zzz}, --Posição que o player será teleportado (da cidade vip1).
vip2 = {x = xxx, y = yyy, z = zzz}, --Posição que o player será teleportado (da cidade vip2).
id_item = 5785,
}
if msgcontains(msg, 'viajem') or msgcontains(msg, 'viajar') then
selfSay("Então, você gostaria de viajar? Para isso, você deverá ter o item x em sua mochila!", cid)
doPlayerSendTextMessage(cid, 27, "Diga yes se quiser viajar, e não se não quiser. Lembre-se de ter o item x na bag!")
talkState[talkUser] = 1
return true
elseif msgcontains(msg, 'yes') and talkState[talkUser] == 1 then
if getPlayerItemCount(cid, cfg.id_item) >= 1 then
selfSay("Certo. Para onde você deseja viajar? A cidade vip1, ou a cidade vip2?", cid)
doPlayerSendTextMessage(cid, 27, "Diga vip1 se quiser ir para a cidade vip1, ou vip2 para ir para a cidade vip2.")
talkState[talkUser] = 2
return true
else
selfSay("Você não tem o item, vá embora!", cid)
talkState[talkUser] = 0
return true
end
elseif msgcontains(msg, 'no') and talkState[talkUser] == 1 then
selfSay("Tudo bem então...", cid)
talkState[talkUser] = 0
return true
elseif msgcontains(msg, 'vip1') and talkState[talkUser] == 2 then
selfSay("Boa viagem!", cid)
doTeleportThing(cid, cfg.vip1)
talkState[talkUser] = 0
return true
elseif msgcontains(msg, 'vip2') and talkState[talkUser] == 2 then
selfSay("Boa viagem!", cid)
doTeleportThing(cid, cfg.vip2)
talkState[talkUser] = 0
return true
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
XML do npc [data/npc]
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Nome do npc" script="arquivo do npc.lua" walkinterval="0" floorchange="0" access="5" level="1" maglevel="1">
<health now="150" max="150"/>
<look type="523" head="114" body="119" legs="114" feet="114" corpse="2212"/>
<parameters>
<parameter key="message_greet" value="Ola |PLAYERNAME|, gostaria de {viajar}?"/>
</parameters>
</npc>
Não se esqueça de editar essa parte
<look type="523" head="114" body="119" legs="114" feet="114" corpse="2212"/>
para deixar seu NPC à seu gosto.
Não respondo PMs solicitando suporte. Já existem seções no fórum para isto.