Hello I have a little probleme,
My NPC SCRIPT:
It doesn't work, He doesn't talk when I say hola, or Hi, Hello or Greet. Could someone help me please! I give Rep!
My NPC SCRIPT:
LUA:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
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 oracle(cid, message, keywords, parameters, node)
if(not npcHandler:isFocused(cid)) then
return false
end
local cityNode = node:getParent():getParent()
local vocNode = node:getParent()
local destination = cityNode:getParameters().destination
local town = cityNode:getParameters().town
local vocation = vocNode:getParameters().vocation
if(destination ~= nil and vocation ~= nil and town ~= nil) then
if(getPlayerLevel(cid) < parameters.level) then
npcHandler:say('Primer tienes que lleguar al nivel ' .. parameters.level .. '!', cid)
npcHandler:resetNpc()
else
if(getPlayerVocation(cid) > 0) then
npcHandler:say('Como te metiste! Vete anda no hagas trampas')
doTeleportThing(cid, {x=208, y=156, x=5)
npcHandler:resetNpc()
else
doPlayerSetVocation(cid, vocation)
doPlayerSetTown(cid, town)
npcHandler:resetNpc()
local tmp = getCreaturePosition(cid)
doTeleportThing(cid, destination)
doSendMagicEffect(tmp, CONST_ME_POFF)
doSendMagicEffect(destination, CONST_ME_TELEPORT)
end
end
end
return true
end
function greetCallback(cid)
if(getPlayerLevel(cid) < 8) then
npcHandler:say('Ven cuando crezcas!!')
return false
else
return true
end
end
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setMessage(MESSAGE_GREET, 'Hola |PLAYERNAME|. Estamos en el futuro del tiempo de Irus, mi hija, conozco muchas cosas nuevas que Irus no sabe, haber si las puedes construir. Haz un tipo de telefono no? Jajaj.Estas preparado para enfrentar tu destino?')
local yesNode = KeywordNode:new({'si'}, oracle, {level = 8})
local noNode = KeywordNode:new({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, moveup = 1, text = 'Que vocacion quieres?'})
local node1 = keywordHandler:addKeyword({'si'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Donde quieres irte? {Entrenamiento} o {Irus}?'})
local node2 = node1:addChildKeyword({'Entrenamiento'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, town = 1, destination = {x=39, y=29, z=7}, text = 'Entrenamiento eh? Ahi entrenas mola bastante para los principiante, asi porcierto que vocacion quieres probar? Hechicero, Satasan, Caballero, Mago, Arquero?'})
local node3 = node2:addChildKeyword({'hechicero'}, StdModule.say, {npcHandler = npcHandler, vocation = 1, onlyFocus = true, text = 'El ataque Masivo del equipo! Como si fuera la pantalla de la television! Jaja! Seguro que no lo puedo cambiar mas tarde :/.'})
node3:addChildKeywordNode(yesNode)
node3:addChildKeywordNode(noNode)
node3 = node2:addChildKeyword({'mago'}, StdModule.say, {npcHandler = npcHandler, vocation = 2, onlyFocus = true, text = 'El curado del equipo! Como si fuera el recargador de un IPod! Seguro?'})
node3:addChildKeywordNode(yesNode)
node3:addChildKeywordNode(noNode)
node3 = node2:addChildKeyword({'arquero'}, StdModule.say, {npcHandler = npcHandler, vocation = 3, onlyFocus = true, text = 'El ataque! Como si fuera el color de un pincel Uno de mis favoritos. Seguro no se pede cambiar mas tarde.''})
node3:addChildKeywordNode(yesNode)
node3:addChildKeywordNode(noNode)
node3 = node2:addChildKeyword({'caballero'}, StdModule.say, {npcHandler = npcHandler, vocation = 4, onlyFocus = true, text = 'La base del equipo! Como si fuera la Carta SIM del telefono! Seguro, no se puede cambiar luego.'})
node3:addChildKeywordNode(yesNode)
node3:addChildKeywordNode(noNode)
node3 = node2:addChildKeyword({'satasan'}, StdModule.say, {npcHandler = npcHandler, vocation = 5, onlyFocus = true, text = 'La gran, pero la mas grande del equipo, como si fuero el disco duro de un ordenador. Seguro? Esta decision no se puede cambiar!'})
node3:addChildKeywordNode(yesNode)
node3:addChildKeywordNode(noNode)
node2 = node1:addChildKeyword({'Irus'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, town = 1, destination = {x=208, y=156, z=5}, text = 'Entrenamiento eh? Ahi entrenas mola bastante para los principiante, asi porcierto que vocacion quieres probar? Hechicero, Satasan, Caballero, Mago, Arquero?'})
node3 = node2:addChildKeyword({'hechicero'}, StdModule.say, {npcHandler = npcHandler, vocation = 1, onlyFocus = true, text = 'El ataque Masivo del equipo! Como si fuera la pantalla de la television! Jaja! Seguro que no lo puedo cambiar mas tarde :/.'})
node3:addChildKeywordNode(yesNode)
node3:addChildKeywordNode(noNode)
node3 = node2:addChildKeyword({'mago'}, StdModule.say, {npcHandler = npcHandler, vocation = 2, onlyFocus = true, text = 'El curado del equipo! Como si fuera el recargador de un IPod! Seguro?'})
node3:addChildKeywordNode(yesNode)
node3:addChildKeywordNode(noNode)
node3 = node2:addChildKeyword({'arquero'}, StdModule.say, {npcHandler = npcHandler, vocation = 3, onlyFocus = true, text = 'El ataque! Como si fuera el color de un pincel Uno de mis favoritos. Seguro? no se pede cambiar mas tarde.'})
node3:addChildKeywordNode(yesNode)
node3:addChildKeywordNode(noNode)
node3 = node2:addChildKeyword({'caballero'}, StdModule.say, {npcHandler = npcHandler, vocation = 4, onlyFocus = true, text = 'La base del equipo! Como si fuera la Carta SIM del telefono! Seguro, no se puede cambiar luego.'})
node3:addChildKeywordNode(yesNode)
node3:addChildKeywordNode(noNode)
node3 = node2:addChildKeyword({'satasan'}, StdModule.say, {npcHandler = npcHandler, vocation = 5, onlyFocus = true, text = 'La gran, pero la mas grande del equipo, como si fuero el disco duro de un ordenador. Seguro? Esta decision no se puede cambiar!'})
node3:addChildKeywordNode(yesNode)
node3:addChildKeywordNode(noNode)
keywordHandler:addKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Vuelve cuando estes preparado'})
npcHandler:addModule(FocusModule:new())
XML:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="The Oracle" floorchange="0" walkinterval="0">
<health now="150" max="150"/>
<look typeex="1448"/>
<interaction range="3" idletime="5">
<interact keywords="hola" focus="1">
<!--These are the keywords will trigger this interaction-->
<keywords>hola</keywords>
<keywords>greet</keywords>
<response>
<action name="script">
<!--
if(getPlayerVocation(cid) ~= 0) then
selfSay("SORRY, YOU HAVE ALREADY MADE YOUR CHOICE IN LIFE!")
_state.isidle = true
return
end
-->
if(getPlayerLevel(cid)) >= 8 then
selfSay(Querido getCreatureName(cid) .. ", Has venido a rescatar el mundo de Irus! Desde que he muerto, los poderosos paises se enfrentaron a mis hijas, Irus, Caltravan, Vinus y Teca. Teca Murio hace bastante tiempo, Snif :(. Los restos ayudan a Irus de proteger el mundo. Estas preparado para ser un Heroe!??")
_state.b1 = (isPremium(cid) == TRUE)
_state.topic = 1
else
selfSay("Amigo, Vuelve quando crezcas!")
_state.isidle = true
end
</action>
</response>
</interact>
<interact keywords="si" topic="1">
<!--Premium account, b1 is set in above-->
<response b1="1" text="Donde quieres irte? Al campo de Entrenamiento a directamente a Irus?">
<action name="topic" value="2"/>
</response>
<!--Normal account-->
<response text="Donde quieres irte? Al 'campo de Entrenamiento' a directamente a 'Irus'?">
<action name="topic" value="2"/>
</response>
</interact>
<interact keywords="campo de Entrenamiento" topic="2">
<response text="Al campo de Entrenamiento! Que decidiste ser: 'Caballero', 'Arquero', 'Mago', 'Hechicero' o 'Satasan'?">
<!--n1: 1 = carlin, 2 = edron, 3 = thais, 4 = venore-->
<action name="script">
_state.n1 = 1
_state.topic = 3
</action>
</response>
</interact>
<interact keywords="Irus" topic="2">
<response text="Aha, ya eres un Tibiano no? Que decidiste ser: 'Caballero', 'Arquero', 'Mago', 'Hechicero' o 'Satasan'?">
<!--n1: 1 = carlin, 2 = edron, 3 = thais, 4 = venore-->
<action name="script">
_state.n1 = 2
_state.topic = 3
</action>
</response>
</interact>
<!--If the player does not say any city, repeat our question-->
<interact keywords="|*|" topic="2">
<response b1="1" text="Ejem... Campo de Entrenamiento o Irus?"/>
<response text="Ya no? No tengo todo el dia. Campo de Entrenamiento o Irus?"/>
</interact>
<interact keywords="hechicero" topic="3">
<response text="El ataque Masivo del equipo! Como si fuera la pantalla de la television! Jaja! Seguro que no lo puedo cambiar mas tarde :/.">
<!--n2: 1 = sorcerer, 2 = druid, 3 = paladin, 4 = knight-->
<action name="script">
_state.n2 = 1
_state.topic = 4
</action>
</response>
</interact>
<interact keywords="mago" topic="3">
<response text="El curado del equipo! Como si fuera el recargador de un IPod! Seguro?">
<!--n2: 1 = sorcerer, 2 = druid, 3 = paladin, 4 = knight-->
<action name="script">
_state.n2 = 2
_state.topic = 4
</action>
</response>
</interact>
<interact keywords="arquero" topic="3">
<response text="El ataque! Como si fuera el color de un pincel Uno de mis favoritos. Seguro no se pede cambiar mas tarde.">
<!--n2: 1 = sorcerer, 2 = druid, 3 = paladin, 4 = knight-->
<action name="script">
_state.n2 = 3
_state.topic = 4
</action>
</response>
</interact>
<interact keywords="caballero" topic="3">
<response text="La base del equipo! Como si fuera la Carta SIM del telefono! Seguro, no se puede cambiar luego.">
<!--n2: 1 = sorcerer, 2 = druid, 3 = paladin, 4 = knight-->
<action name="script">
_state.n2 = 4
_state.topic = 4
</action>
</response>
</interact>
<interact keywords="Satasan" topic="3">
<response text="La gran, pero la mas grande del equipo, como si fuero el disco duro de un ordenador. Seguro? Esta decision no se puede cambiar!">
<!--n2: 1 = sorcerer, 2 = druid, 3 = paladin, 4 = knight-->
<action name="script">
_state.n2 = 5
_state.topic = 4
</action>
</response>
</interact>
<!--If the player does not say any profession, repeat our question-->
<interact keywords="|*|" topic="3">
<response text="CABALLERO, MAGO, HECHICERO, ARQUERO O SATASAN OSTIA!"/>
</interact>
<interact keywords="yes" topic="4">
<response>
<!--n1: 1 = carlin, 2 = edron, 3 = thais, 4 = venore-->
<!--n2: 1 = knight, 2 = paladin, 3 = sorcerer, 4 = druid-->
<action name="script">
local pos = 0
if(_state.n1 == 1) then
pos = {x=36, y=28, z=7}
elseif(_state.n1 == 2) then
pos = {x=208, y=156, z=5}
else
selfSay("OSTIA YO NO CONOZCO ESA VOCACION! ELIJE!!")
return
end
selfSay("PUES SEE LO!")
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
if(doTeleportThing(cid, pos) == 0) then
doPlayerSetVocation(cid, _state.n2)
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
end
</action>
<action name="idle" value="1"/>
</response>
</interact>
<interact keywords="adios" focus="0">
<keywords>Adios Amigo</keywords>
<response text="Adios, gracias por usar mi servicio."/>
</interact>
<!--
If the event onBusy exists, the npc will make a queue like Tibia, if the event is removed
the npc will be able to talk to all customers at the same time without problems.
-->
<interact event="onBusy">
<response text="Espera hasta que sea tu turno!">
<action name="addqueue" value="|PLAYER|"/>
</response>
</interact>
<!--This event triggers if the player goes to far away from the npc/logout/idle timeout-->
<interact event="onPlayerLeave" focus="0">
<response text="Nececito ayudar a Irus! Porfavor estoy gastando fuerza para hacer este lugar flotante!!"/>
</interact>
</interaction>
</npc>
It doesn't work, He doesn't talk when I say hola, or Hi, Hello or Greet. Could someone help me please! I give Rep!
Last edited by a moderator: