Nao é so criar dois npcs?
So que o segundo revertendo as posições,para da primeira ves?
Por Noninhouh, 22 de set. de 2012 em Scripts
info
Grupo: Banidos
Registrado: 30/07/12
Posts: 279
Reputação: +16
Char no Tibia: Raidou

Nao é so criar dois npcs?
So que o segundo revertendo as posições,para da primeira ves?
info
Grupo: Visconde
Registrado: 26/08/12
Posts: 318
Reputação: +118
Gênero: Masculino

Pode ser 2 npc tb, mais eu queria um em cada city ![]()
Em data/npcs crie um arquivo.xml e cole isto dentro:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="NOMEDOSEUNPC" script="data/npc/scripts/NOMEDOSEUARQUIVO.lua" walkinterval="5000" floorchange="0">
<health now="100" max="100"/>
<look type="128" head="38" body="39" legs="96" feet="118" addons="3"/>
<parameters>
<parameter key="message_greet" value="Hello, |PLAYERNAME|! I can {travel} you to many places."/>
<parameter key="message_farewell" value="Good bye."/>
<parameter key="module_keywords" value="1" />
</parameters>
</npc>
Em data/npcs/scripts crie um arquivo.lua e cole isto:
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 t = {
["treiner"] = {pos = {x=1,y=1,z=1}},
["thais"] = {pos = {x=1,y=1,z=1}}
}
if msgcontains(msg, "travel") or msgcontains(msg, "Travel") then
selfSay("Posso te levar para {treiner} ou {thais}.", cid)
talkState[talkUser] = 1
elseif talkState[talkUser] == 1 then
if t[msg] then
doTeleportThing(cid, t[msg].pos)
doSendMagicEffect(t[msg].pos, 10)
selfSay("Boa viagem.", cid)
talkState[talkUser] = 0
end
end
return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
info
Grupo: Visconde
Registrado: 26/08/12
Posts: 318
Reputação: +118
Gênero: Masculino

Leoxtibia | Mais esse ai é como se fosse um npc normal de navio.
Eu keria ele assim:
NPC de volta
Eu: hi
NPC: Se vc esta falando comigo é pq deseja voltar para o mundo inferior?
Eu: Yes
NPC de ida
Eu: hi
NPC: oi, qr ir {treinar}
Eu: yes
Acho que agr eu expliquei melhor
Editado Setembro 22 por Noninhouh
Agora explicou...
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 thais = {x=1,y=1,z=1}
if msgcontains(msg, "travel") or msgcontains(msg, "Travel") then
if getPlayerStorageValue(cid, 3210) == -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
doTeleportThing(cid, treiner)
doSendMagicEffect(treiner, 10)
setPlayerStorageValue(cid, 3210, 1)
selfSay("Boa viagem.", cid)
talkState[talkUser] = 0
elseif talkState[talkUser] == 2 and msgcontains(msg, "yes") then
doTeleportThing(cid, thais)
doSendMagicEffect(thais, 10)
setPlayerStorageValue(cid, 3210, -1)
selfSay("Boa viagem.", cid)
talkState[talkUser] = 0
end
return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
É só editar as posições treiner e thais.
info
Grupo: Visconde
Registrado: 26/08/12
Posts: 318
Reputação: +118
Gênero: Masculino

Hm... assim:
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())
info
Grupo: Visconde
Registrado: 26/08/12
Posts: 318
Reputação: +118
Gênero: Masculino

Leoxtibia | u.u estou imprecionado ![]()
REP++ pra vc
---- @EDIT@ ----
So pra saber...
Se o player estiver pk ou em area que não é pz ele transporta o player?
Editado Setembro 23 por Noninhouh
info
Grupo: Herói
Registrado: 20/05/10
Posts: 3.4k
Reputação: +1.5k
Gênero: Masculino

pedido atendido e movido!
rep + leo
info
Grupo: Visconde
Registrado: 26/08/12
Posts: 318
Reputação: +118
Gênero: Masculino
Iae galera do xtibia...
Queria um npc tipo assim \/
REP++ pra qm consegui
Editado Setembro 22 por Noninhouh