hmn achei esse em outro forum acho que é oque você quer:
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 function playerHaveItems(cid, itemid) local items = type(itemid) == "table" and itemid or {itemid} for i = 1, #items do if getPlayerItemCount(cid, items) <= 0 then return false end end return true end function doPlayerRemoveItems(cid, itemid, count) local items = type(itemid) == "table" and itemid or {itemid} for i = 1, #items do doPlayerRemoveItem(cid, items, count ~= nil and count or 1) end return nil end function creatureSayCallback(cid, type, msg) if(not npcHandler:isFocused(cid)) then return false end if msgcontains(msg, "trocar") then if playerHaveItems(cid, {12149, 12150, 12151}) then doPlayerRemoveItems(cid, {12149, 12150, 12151}, 300) doPlayerAddItem(cid, 2200, 1) else selfSay("Você Não tem os itens necessarios.") end end return true endnpcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())
Agora vá em Data/Npc/Nomedonpc.xml
<?xml version="1.0" encoding="UTF-8"?> <npc name="Nomedonpc" script="trocaitems.lua" walkinterval="2000" floorchange="0"> <health now="100" max="100"/> <look type="169" head="114" body="86" legs="114" feet="0" addons="2"/> <parameters> <parameter key="message_greet" value="Ola, diga {trocar} para trocar 3 items por 1."/> </parameters> </npc>