Ot/data/npc copie qualquer script, renomeie pra trocadeitens , apague tud o que estiver dentro, e cole isto:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Nome do Npc" script="data/npc/scripts/troca.lua" walkinterval="2000" floorchange="0">
<health now="100" max="100"/>
<look type="332" head="0" body="0" legs="0" feet="0"/>
<parameters>
<parameter key="message_greet" value="Aqui voce bota uma msg que voce quiser, poder ser informando os itens que poder sem trocados , voce escolhe" />
</parameters>
</npc>
depois em data/npc/scripts , copie qualquer script, renomeie pra troca , apague tud o que estiver dentro, e cole isto:
local talk_state = 0
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 creatureSayCallback(cid, type, msg)
if msgcontains(msg, 'nome do item') then
if getPlayerItemCount(cid,6512) >= 1 then
if doPlayerRemoveItem(cid,6512,1) then
doPlayerAddItem(cid,1990,1)
npcHandler:say('mensagem quando o item é trocado.')
end
else
npcHandler:say('mensagem quando o player nao tem o item')
talk_state = 0
end
elseif msgcontains(msg, 'bye') then
npcHandler:say('Até mais, ' .. getCreatureName(cid) .. '! Volte em breve...')
talk_state = 0
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
explicando:
aonde ta ali "nome do item" é o que o player vai falar pra trocar os items!
if getPlayerItemCount(cid,6512) >= 1 then << aqi voce muda o id do item que o player precisa ter, e 1 then é a quantidade
if doPlayerRemoveItem(cid,6512,1) then << aqi pra remover o item, e a quantidade
doPlayerAddItem(cid,1990,1) << aqi o tem que o player irá ganhar na troca
ai voce muda pra o que voce quiser.
Espero ter ajudado!
^^