1°
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 Sweet(cid, message, keywords, parameters, node)
if(not npcHandler:isFocused(cid)) then
return false
end
for i = 1, table.maxn(parameters.items) do
if getPlayerItemCount(cid, parameters.items[i]) <= 0 then
npcHandler:say('You don\'t have these items!', cid)
return true
end
end
for i = 1, table.maxn(parameters.items) do
doPlayerRemoveItem(cid,parameters.items[i], 1)
end
npcHandler:say('Here is your item!', cid)
doPlayerAddItem(cid, parameters.reward,1)
return true
end
local node1 = keywordHandler:addKeyword({'nome do item'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Você quer trocar dois itens por este item?'})
node1:addChildKeyword({'yes'}, Sweet, {items = {8262,8263},reward = 8266})
node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Ok, then.', reset = true})
npcHandler:addModule(FocusModule:new())
explicando
keywordHandler:addKeyword({'nome do item'} -- aki vc coloca o nome do item q ele vai troca pelos 2 items
items = {8262,8263} -- itens que serão removidos,se quiser adicionar mais só colocar uma virgula e o id do item,ex:
items = {8262,8263,8264}
reward = 8266 -- item q ele receba em troca!