Ir para conteúdo
  • 0

Zikar

Pergunta

Olá galera do xtibia

 

Gostaria que me ajudassem a modifica esse script.

 

Eu gostaria que quando o jogador chegasse no destino, ao invés de somente remover a roupa e parar a rota, eu gostaria que teleportar-se

 

 

Esse é um script de trem, Eu queria que acontecesse o seguinte, O player fala com npc e tal, começaria a viagem, ai quando chegar no destino TELEPORTAR O PLAYER

 

lá vai o script

 

 

 

local avoidLogout = createConditionObject(CONDITION_INFIGHT, -1, 1660)

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

local config = {

ITEM_REMOVIDO = 2148, -- id do item a ser removido

ITEM_COUNT = 20, -- quantidade do item a ser removido

LOOKTYPE_DA_MOTO = 1034, -- outfit da moto, apenas looktype

DELAY_ENTRE_ANDADAS = 50, -- intervalo (em ms) a cada passo que o player dá

VELOCIDADE_EXTRA = 1000, -- velocidade a mais que o player ganha na moto

EMPURRAR_CRIATURAS = true, -- true/false, se true, todos os monstros/players que estiverem no caminho serão empurrados pro lado

ATRAVESSAR_OBSTACULOS = true, -- true/false, se true, vai entrar e passar por dentro de paredes, árvores etc...

POS_INICIAL = {x = 1041, y = 1072, z = 8}, -- onde o player irá ser teleportado ao confirmar a msg do npc

POS_FINAL = {x = 1041, y = 1174, z = 8},

ROTA_AUTOMATICA = false, -- procura por direções automaticamente, sem precisar configurar as directions

-- porém há grandes chance de encontrar obstáculos/falhar

ROTA_POR_DIRECTION = {SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, } -- apenas se ROTA_AUTOMATICA for false

}

local function getNextDir(cid, playerpos, finalpos)

local result = {}

local xy = 999999

for newDir = 0, 3 do

local p = getPosByDir(playerpos, newDir)

if doTileQueryAdd(cid, p, config.EMPURRAR_CRIATURAS and 4 or 0) == 1 or config.ATRAVESSAR_OBSTACULOS then

local d = math.abs(p.x - finalpos.x) + math.abs(p.y - finalpos.y)

if d < xy then result = {newDir} xy = d

elseif d == xy then table.insert(result, newDir) end

end

end

if #result == 0 then

for newDir = 4, 7 do

local p = getPosByDir(playerpos, newDir)

if doTileQueryAdd(cid, p, config.EMPURRAR_CRIATURAS and 4 or 0) == 1 or config.ATRAVESSAR_OBSTACULOS then

local d = math.abs(p.x - finalpos.x) + math.abs(p.y - finalpos.y)

if d < xy then result = {newDir} xy = d

elseif d == xy then table.insert(result, newDir) end

end

end

return #result == 0 and false or result[math.random(#result)]

else

return result[math.random(#result)]

end

return false

end

 

local function doPlayerFollowRoute(cid, stepId)

if not isCreature(cid) then return true end

if not stepId then

doCreatureSetNoMove(cid, true)

doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)

doChangeSpeed(cid, config.VELOCIDADE_EXTRA)

doSetCreatureOutfit(cid, {lookType = config.LOOKTYPE_DA_MOTO}, -1)

doAddCondition(cid, avoidLogout)

addEvent(doPlayerFollowRoute, config.DELAY_ENTRE_ANDADAS, cid, 1)

return true

end

local begin, finish = getThingPos(cid), (config.ROTA_AUTOMATICA and config.POS_FINAL or {x = -1, y = -1})

if (begin.x == finish.x and begin.y == finish.y) or (not config.ROTA_AUTOMATICA and stepId == #config.ROTA_POR_DIRECTION + 1) then

doPlayerSendCancel(cid, "Destino alcançado!")

doCreatureSetNoMove(cid, false)

doChangeSpeed(cid, -getCreatureSpeed(cid) + getCreatureBaseSpeed(cid))

doRemoveCondition(cid, CONDITION_OUTFIT)

doRemoveCondition(cid, CONDITION_INFIGHT, 1660)

return true

end

if getCreatureOutfit(cid).lookType ~= config.LOOKTYPE_DA_MOTO then

doChangeSpeed(cid, -getCreatureSpeed(cid) + getCreatureBaseSpeed(cid))

doCreatureSetNoMove(cid, false)

doRemoveCondition(cid, CONDITION_OUTFIT)

doRemoveCondition(cid, CONDITION_INFIGHT, 1660)

return true end

local nextPos = {}

if config.ROTA_AUTOMATICA then

nextPos = getPosByDir(getThingPos(cid), getNextDir(cid, getThingPos(cid), config.POS_FINAL) or getDirectionTo(getThingPos(cid), config.POS_FINAL))

else

nextPos = getPosByDir(getThingPos(cid), config.ROTA_POR_DIRECTION[stepId or 1])

end

if not (doTileQueryAdd(cid, nextPos) == 1 or config.ATRAVESSAR_OBSTACULOS) then

doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)

doChangeSpeed(cid, -getCreatureSpeed(cid) + getCreatureBaseSpeed(cid))

doRemoveCondition(cid, CONDITION_OUTFIT)

doCreatureSetNoMove(cid, false)

doRemoveCondition(cid, CONDITION_INFIGHT, 1660)

return doPlayerSendCancel(cid, "Obstáculo encontrado!")

end

 

if config.EMPURRAR_CRIATURAS and config.ATRAVESSAR_OBSTACULOS and getTileInfo(nextPos).creatures > 0 then

for pushCreatures = 1, #getTileInfo(nextPos).creatures do

local creature = getTopCreature(nextPos).uid

addEvent(doTeleportThing, 50, creature, getClosestFreeTile(creature, getThingPos(creature)))

end

end

 

doTeleportThing(cid, nextPos)

addEvent(doPlayerFollowRoute, config.DELAY_ENTRE_ANDADAS, cid, (stepId or 1) + 1)

end

 

function creatureSayCallback(cid, type, msg)

if msgcontains(msg, 'yes') then

if not doPlayerRemoveItem(cid, config.ITEM_REMOVIDO, config.ITEM_COUNT) then

selfSay("You not have enough money!")

return true

end

selfSay("OK! boa viajem.", cid)

doTeleportThing(cid, config.POS_INICIAL, false)

doPlayerFollowRoute(cid)

return true

end

end

 

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

npcHandler:addModule(FocusModule:new())

Link para o comentário
Compartilhar em outros sites

7 respostass a esta questão

Posts Recomendados

  • 0

 

local avoidLogout = createConditionObject(CONDITION_INFIGHT, -1, 1660)

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

local config = {

ITEM_REMOVIDO = 2148, -- id do item a ser removido

ITEM_COUNT = 20, -- quantidade do item a ser removido

LOOKTYPE_DA_MOTO = 1034, -- outfit da moto, apenas looktype

DELAY_ENTRE_ANDADAS = 50, -- intervalo (em ms) a cada passo que o player dá

VELOCIDADE_EXTRA = 1000, -- velocidade a mais que o player ganha na moto

EMPURRAR_CRIATURAS = true, -- true/false, se true, todos os monstros/players que estiverem no caminho serão empurrados pro lado

ATRAVESSAR_OBSTACULOS = true, -- true/false, se true, vai entrar e passar por dentro de paredes, árvores etc...

POS_INICIAL = {x = 1041, y = 1072, z = 8}, -- onde o player irá ser teleportado ao confirmar a msg do npc

POS_FINAL = {x = 1041, y = 1174, z = 8},

ROTA_AUTOMATICA = false, -- procura por direções automaticamente, sem precisar configurar as directions

coordenadas = {x = 123, y = 456, z = 7}

-- porém há grandes chance de encontrar obstáculos/falhar

ROTA_POR_DIRECTION = {SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, } -- apenas se ROTA_AUTOMATICA for false

}

local function getNextDir(cid, playerpos, finalpos)

local result = {}

local xy = 999999

for newDir = 0, 3 do

local p = getPosByDir(playerpos, newDir)

if doTileQueryAdd(cid, p, config.EMPURRAR_CRIATURAS and 4 or 0) == 1 or config.ATRAVESSAR_OBSTACULOS then

local d = math.abs(p.x - finalpos.x) + math.abs(p.y - finalpos.y)

if d < xy then result = {newDir} xy = d

elseif d == xy then table.insert(result, newDir) end

end

end

if #result == 0 then

for newDir = 4, 7 do

local p = getPosByDir(playerpos, newDir)

if doTileQueryAdd(cid, p, config.EMPURRAR_CRIATURAS and 4 or 0) == 1 or config.ATRAVESSAR_OBSTACULOS then

local d = math.abs(p.x - finalpos.x) + math.abs(p.y - finalpos.y)

if d < xy then result = {newDir} xy = d

elseif d == xy then table.insert(result, newDir) end

end

end

return #result == 0 and false or result[math.random(#result)]

else

return result[math.random(#result)]

end

return false

end

 

local function doPlayerFollowRoute(cid, stepId)

if not isCreature(cid) then return true end

if not stepId then

doCreatureSetNoMove(cid, true)

doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)

doChangeSpeed(cid, config.VELOCIDADE_EXTRA)

doSetCreatureOutfit(cid, {lookType = config.LOOKTYPE_DA_MOTO}, -1)

doAddCondition(cid, avoidLogout)

addEvent(doPlayerFollowRoute, config.DELAY_ENTRE_ANDADAS, cid, 1)

return true

end

local begin, finish = getThingPos(cid), (config.ROTA_AUTOMATICA and config.POS_FINAL or {x = -1, y = -1})

if (begin.x == finish.x and begin.y == finish.y) or (not config.ROTA_AUTOMATICA and stepId == #config.ROTA_POR_DIRECTION + 1) then

doPlayerSendCancel(cid, "Destino alcançado!")

doCreatureSetNoMove(cid, false)

doChangeSpeed(cid, -getCreatureSpeed(cid) + getCreatureBaseSpeed(cid))

doRemoveCondition(cid, CONDITION_OUTFIT)

doRemoveCondition(cid, CONDITION_INFIGHT, 1660)

doTeleportThing(cid, coordenadas)

return true

end

if getCreatureOutfit(cid).lookType ~= config.LOOKTYPE_DA_MOTO then

doChangeSpeed(cid, -getCreatureSpeed(cid) + getCreatureBaseSpeed(cid))

doCreatureSetNoMove(cid, false)

doRemoveCondition(cid, CONDITION_OUTFIT)

doRemoveCondition(cid, CONDITION_INFIGHT, 1660)

doTeleportThing(cid, coordenadas)

return true end

local nextPos = {}

if config.ROTA_AUTOMATICA then

nextPos = getPosByDir(getThingPos(cid), getNextDir(cid, getThingPos(cid), config.POS_FINAL) or getDirectionTo(getThingPos(cid), config.POS_FINAL))

else

nextPos = getPosByDir(getThingPos(cid), config.ROTA_POR_DIRECTION[stepId or 1])

end

if not (doTileQueryAdd(cid, nextPos) == 1 or config.ATRAVESSAR_OBSTACULOS) then

doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)

doChangeSpeed(cid, -getCreatureSpeed(cid) + getCreatureBaseSpeed(cid))

doRemoveCondition(cid, CONDITION_OUTFIT)

doCreatureSetNoMove(cid, false)

doRemoveCondition(cid, CONDITION_INFIGHT, 1660)

return doPlayerSendCancel(cid, "Obstáculo encontrado!")

end

 

if config.EMPURRAR_CRIATURAS and config.ATRAVESSAR_OBSTACULOS and getTileInfo(nextPos).creatures > 0 then

for pushCreatures = 1, #getTileInfo(nextPos).creatures do

local creature = getTopCreature(nextPos).uid

addEvent(doTeleportThing, 50, creature, getClosestFreeTile(creature, getThingPos(creature)))

end

end

 

doTeleportThing(cid, nextPos)

addEvent(doPlayerFollowRoute, config.DELAY_ENTRE_ANDADAS, cid, (stepId or 1) + 1)

end

 

function creatureSayCallback(cid, type, msg)

if msgcontains(msg, 'yes') then

if not doPlayerRemoveItem(cid, config.ITEM_REMOVIDO, config.ITEM_COUNT) then

selfSay("You haven't enough money!")

return true

end

selfSay("OK! boa viagem.", cid)

doTeleportThing(cid, config.POS_INICIAL, false)

doPlayerFollowRoute(cid)

return true

end

end

 

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

npcHandler:addModule(FocusModule:new())

 

 

Edite aqui:

 

coordenadas = {x = 123, y = 456, z = 7}

Link para o comentário
Compartilhar em outros sites

  • 0

LuckOake, fui testar seu script porem deu bug no npc.

 

Mensagem no executador

 

[16/09/2012 22:00:50] [Error - LuaScriptInterface::loadFile] data/npc/scripts/train.lua:22: '}' expected (to close '{' at line 9) near 'ROTA_POR_DIRECTION'

[16/09/2012 22:00:50] [Warning - NpcScript::NpcScript] Cannot load script: data/npc/scripts/train.lua

[16/09/2012 22:00:50] data/npc/scripts/train.lua:22: '}' expected (to close '{' at line 9) near 'ROTA_POR_DIRECTION'

Link para o comentário
Compartilhar em outros sites

  • 0

Opa, erro meu.

 

 

local avoidLogout = createConditionObject(CONDITION_INFIGHT, -1, 1660)

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

local config = {

ITEM_REMOVIDO = 2148, -- id do item a ser removido

ITEM_COUNT = 20, -- quantidade do item a ser removido

LOOKTYPE_DA_MOTO = 1034, -- outfit da moto, apenas looktype

DELAY_ENTRE_ANDADAS = 50, -- intervalo (em ms) a cada passo que o player dá

VELOCIDADE_EXTRA = 1000, -- velocidade a mais que o player ganha na moto

EMPURRAR_CRIATURAS = true, -- true/false, se true, todos os monstros/players que estiverem no caminho serão empurrados pro lado

ATRAVESSAR_OBSTACULOS = true, -- true/false, se true, vai entrar e passar por dentro de paredes, árvores etc...

POS_INICIAL = {x = 1041, y = 1072, z = 8}, -- onde o player irá ser teleportado ao confirmar a msg do npc

POS_FINAL = {x = 1041, y = 1174, z = 8},

ROTA_AUTOMATICA = false, -- procura por direções automaticamente, sem precisar configurar as directions

coordenadas = {x = 123, y = 456, z = 7},

-- porém há grandes chance de encontrar obstáculos/falhar

ROTA_POR_DIRECTION = {SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, SOUTH, } -- apenas se ROTA_AUTOMATICA for false

}

local function getNextDir(cid, playerpos, finalpos)

local result = {}

local xy = 999999

for newDir = 0, 3 do

local p = getPosByDir(playerpos, newDir)

if doTileQueryAdd(cid, p, config.EMPURRAR_CRIATURAS and 4 or 0) == 1 or config.ATRAVESSAR_OBSTACULOS then

local d = math.abs(p.x - finalpos.x) + math.abs(p.y - finalpos.y)

if d < xy then result = {newDir} xy = d

elseif d == xy then table.insert(result, newDir) end

end

end

if #result == 0 then

for newDir = 4, 7 do

local p = getPosByDir(playerpos, newDir)

if doTileQueryAdd(cid, p, config.EMPURRAR_CRIATURAS and 4 or 0) == 1 or config.ATRAVESSAR_OBSTACULOS then

local d = math.abs(p.x - finalpos.x) + math.abs(p.y - finalpos.y)

if d < xy then result = {newDir} xy = d

elseif d == xy then table.insert(result, newDir) end

end

end

return #result == 0 and false or result[math.random(#result)]

else

return result[math.random(#result)]

end

return false

end

 

local function doPlayerFollowRoute(cid, stepId)

if not isCreature(cid) then return true end

if not stepId then

doCreatureSetNoMove(cid, true)

doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)

doChangeSpeed(cid, config.VELOCIDADE_EXTRA)

doSetCreatureOutfit(cid, {lookType = config.LOOKTYPE_DA_MOTO}, -1)

doAddCondition(cid, avoidLogout)

addEvent(doPlayerFollowRoute, config.DELAY_ENTRE_ANDADAS, cid, 1)

return true

end

local begin, finish = getThingPos(cid), (config.ROTA_AUTOMATICA and config.POS_FINAL or {x = -1, y = -1})

if (begin.x == finish.x and begin.y == finish.y) or (not config.ROTA_AUTOMATICA and stepId == #config.ROTA_POR_DIRECTION + 1) then

doPlayerSendCancel(cid, "Destino alcançado!")

doCreatureSetNoMove(cid, false)

doChangeSpeed(cid, -getCreatureSpeed(cid) + getCreatureBaseSpeed(cid))

doRemoveCondition(cid, CONDITION_OUTFIT)

doRemoveCondition(cid, CONDITION_INFIGHT, 1660)

doTeleportThing(cid, config.coordenadas)

return true

end

if getCreatureOutfit(cid).lookType ~= config.LOOKTYPE_DA_MOTO then

doChangeSpeed(cid, -getCreatureSpeed(cid) + getCreatureBaseSpeed(cid))

doCreatureSetNoMove(cid, false)

doRemoveCondition(cid, CONDITION_OUTFIT)

doRemoveCondition(cid, CONDITION_INFIGHT, 1660)

doTeleportThing(cid, config.coordenadas)

return true end

local nextPos = {}

if config.ROTA_AUTOMATICA then

nextPos = getPosByDir(getThingPos(cid), getNextDir(cid, getThingPos(cid), config.POS_FINAL) or getDirectionTo(getThingPos(cid), config.POS_FINAL))

else

nextPos = getPosByDir(getThingPos(cid), config.ROTA_POR_DIRECTION[stepId or 1])

end

if not (doTileQueryAdd(cid, nextPos) == 1 or config.ATRAVESSAR_OBSTACULOS) then

doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)

doChangeSpeed(cid, -getCreatureSpeed(cid) + getCreatureBaseSpeed(cid))

doRemoveCondition(cid, CONDITION_OUTFIT)

doCreatureSetNoMove(cid, false)

doRemoveCondition(cid, CONDITION_INFIGHT, 1660)

return doPlayerSendCancel(cid, "Obstáculo encontrado!")

end

 

if config.EMPURRAR_CRIATURAS and config.ATRAVESSAR_OBSTACULOS and getTileInfo(nextPos).creatures > 0 then

for pushCreatures = 1, #getTileInfo(nextPos).creatures do

local creature = getTopCreature(nextPos).uid

addEvent(doTeleportThing, 50, creature, getClosestFreeTile(creature, getThingPos(creature)))

end

end

 

doTeleportThing(cid, nextPos)

addEvent(doPlayerFollowRoute, config.DELAY_ENTRE_ANDADAS, cid, (stepId or 1) + 1)

end

 

function creatureSayCallback(cid, type, msg)

if msgcontains(msg, 'yes') then

if not doPlayerRemoveItem(cid, config.ITEM_REMOVIDO, config.ITEM_COUNT) then

selfSay("You haven't enough money!")

return true

end

selfSay("OK! boa viagem.", cid)

doTeleportThing(cid, config.POS_INICIAL, false)

doPlayerFollowRoute(cid)

return true

end

end

 

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

npcHandler:addModule(FocusModule:new())

 

Editado por LuckOake
Link para o comentário
Compartilhar em outros sites

  • 0

Bom agora o npc funcionou, mais quando chega no final, acontece a mesma coisa de sempre, ele não teleporta...

 

ERRO No executador

 

[16/09/2012 22:12:36] [Error - Npc interface]

[16/09/2012 22:12:36] In a timer event called from:

[16/09/2012 22:12:36] data/npc/scripts/train.lua:onCreatureSay

[16/09/2012 22:12:37] Description:

[16/09/2012 22:12:37] attempt to index a nil value

[16/09/2012 22:12:37] stack traceback:

[16/09/2012 22:12:37] [C]: in function 'doTeleportThing'

[16/09/2012 22:12:37] data/npc/scripts/train.lua:69: in function <data/npc/scripts/train.lua:51>

 

Lembrando: O Servidor é versão 8.54

Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...