Ir para conteúdo
  • 0

Ajuda com npc


Fjinst

Pergunta

Bom, eu tenho esse npc aqui, queria que vocês me ajudassem a configurar esse npc pra poder teleportar a um canto, npc de barco, só que quando tento falar, hi travel, na hora que falo yes, da erro de call back, alguém pode me ajudar?

 

 

 

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
local itemId = 8261
local countItem = 1
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if msgcontains(msg, 'mission') then
if getPlayerStorageValue(cid, 30012) == -1 then
npcHandler:say('Good, I need you to infiltre the shadow mountain and get one '.. getItemNameById(itemId) ..' for me, you think you can do this task?', cid)
talkState[talkUser] = 1
else
npcHandler:say('I remember you.', cid)
end
elseif msgcontains(msg, 'yes') and talkState[talkUser] == 1 then
npcHandler:say('Nice, i will wait you.', cid)
setPlayerStorageValue(cid, 30012, 1)
talkState[talkUser] = 0
elseif msgcontains(msg, 'treasure') then
if getPlayerStorageValue(cid, 30013) == -1 then
if getPlayerItemCount(cid, 8261) == 1 then
doPlayerRemoveItem (cid, 8261, 1)
setPlayerStorageValue(cid, 30013, 1)
npcHandler:say('I really dont beliave, you geet my treasure, niceee!!! brother, now you can travel with me for galdronia.', cid)
else
npcHandler:say('You do not have my treasure.', cid)
end
else
npcHandler:say('Thank for give my treasure for me.', cid)
end
posicao = {x=1077, y=1082, z=7}
elseif msgcontains(msg, 'galdronia') or msgcontains(msg, 'travel') then
npcHandler:say('Really do you want travel to galdronia? this will cost 50 valys.', cid)
talkState[talkUser] = 2
elseif msgcontains(msg, 'yes') and talkState[talkUser] == 2 then
if doPlayerRemoveMoney(cid, 50) then
doTeleportThing(cid, posicao)
talkState[talkUser] = 0
else
selfSay('You don\'t have enough money.', cid)
end
end
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 

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

5 respostass a esta questão

Posts Recomendados

  • 0

tenta mudar essa parte

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

coloca


npcHandler:setCallback(CALLBACK_ONTHINK, thinkCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Link para o comentário
Compartilhar em outros sites

  • 0

O error é esse

[08/12/2015 18:05:56] [Error - Npc interface]
[08/12/2015 18:05:56] data/npc/scripts/missao2.lua:onCreatureSay
[08/12/2015 18:05:56] Description:
[08/12/2015 18:05:56] attempt to index a nil value
[08/12/2015 18:05:56] stack traceback:
[08/12/2015 18:05:56] [C]: in function 'doTeleportThing'
[08/12/2015 18:05:56] data/npc/scripts/missao2.lua:58: in function 'callback'
[08/12/2015 18:05:56] data/npc/lib/npcsystem/npchandler.lua:390: in function 'onCreatureSay'
[08/12/2015 18:05:56] data/npc/scripts/missao2.lua:9: in function <data/npc/scripts/missao2.lua:9>

 

 

 

Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...