script:
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 ID_DA_CIDADE = 1
if msgcontains(msg, 'help') then
selfSay('Se você deseja {morar} nessa cidade, o diga.', cid)
talk_state = 1
elseif talk_state == 1 and msgcontains(msg, 'morar') then
selfSay('Você quer mesmo morar nessa cidade? diga {yes} or {no}.', cid)
talk_state = 2
elseif talk_state == 2 and msgcontains(msg, 'no') then
selfSay('Ok.', cid)
talk_state = 0
elseif talk_state == 2 and msgcontains(msg, 'yes') then
selfSay('Bom, seja bem vindo !', cid)
doPlayerSetTown(cid, ID_DA_CIDADE)
talk_state = 0
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
local ID_DA_CIDADE = 1 -- aqui se vai coloca a ID da cidade (vai no map editor.. edit town.. cria a town e coloca a id)
XML:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Aslan" script="data/npc/scripts/nome do script.lua" walkinterval="0">
<health now="100" max="100"/>
<look type="194" head="78" body="68" legs="98" feet="76"/>
<parameters>
<parameter key="message_greet" value='Olá forasteiro. Diga {help}.'/>
</parameters>
</npc>
mude o que está em vermelho.
não testei (fiz na pressa) mais deve funcionar.




info
Grupo: Artesão
Registrado: 04/11/07
Posts: 137
Reputação: +2
Tipo do script: NPC
Protocolo (versão do Tibia): 8.54~8.60
Nível de experiência: Acho que fácil.
Como funciona:
O player chega e diz: Hi
Npc: Olá forasteiro.
Player: Help
NPC: Se você deseja morar nessa cidade, o diga.
Player: morar
NPC: Você quer mesmo morar nessa cidade ?
Player: Yes
NPC: Bom, seja bem vindo !
Resumindo, o player terá sua cidade natal trocada para xyz quando diz morar, yes.
Não acho que seja dificil esse script.
Espero que não tome muito tempo e desde já obrigado.