Ir para conteúdo

Arruma Meu Npc Plz


PedroMutter

Posts Recomendados

esse meu npc ai era pra telporta o player pra tal lugar(ja ta certim) e troca esses pa d item(n ta peganu)

 

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)



-- OTServ event handling functions start
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
-- OTServ event handling functions end


-- Don't forget npcHandler = npcHandler in the parameters. It is required for all StdModule functions!
local travelNode = keywordHandler:addKeyword({'back'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want come back?'})
travelNode:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = false, level = 1, cost = 0, destination = {x=629, y=476, z=8} })
travelNode:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Ok'})

keywordHandler:addKeyword({'travel'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'How i can bring you,i can come {back} you.'})

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, 'neutral matter') or msgcontains(msg, 'mission') then
selfSay('Do..do..do you realy take the pieces and the neutral matter??', cid)
talkState[talkUser] = '1'
elseif msgcontains(msg, 'yes') and talkState[talkUser] = 1 then
if getPlayerItemCount(cid, {11254},{2335},{2336},{2337},{2338},{2339},{2340},{2341},{8310}) = 1 then
doPlayerRemoveItem(cid, {11254, 1},{2335, 1},{2336, 1},{2337, 1},{2338, 1},{2339, 1},{2340, 1},{2341, 1},{8310, 1})
doPlayerAddItem(cid, 2341, 1)
selfSay('Here are your reward, you are realy hero for tibians, thanks and congratulations.', cid)
else
selfSay('Enter the door there to face and defeat the lord of elements to achieve {neutral matter}!!!', cid)
end
talkState[talkUser] = 0
elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser]) = TRUE) then
talkState[talkUser] = 0
selfSay('-.- '', cid)
end

return true
end

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

Link para o comentário
Compartilhar em outros sites

kkkkkk,ok,a funçao d teleporta ja ta certa, eu qero q vc arrume a funçao d troca items do meu npc

o player da os items :11254,2335,2336,2337,2338,2339,2340,2341,8310 e o npc da o item 2342

tendeo?

Link para o comentário
Compartilhar em outros sites

troca o

elseif msgcontains(msg, 'yes') and talkState[talkUser] = 1 then

por

if msgcontains(msg, 'yes') and talkState[talkUser] = 1 then

e adiciona outro end embaixo.

Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...