Bom irei botar o Script de troca e o Script de NPC completo você edita da maneira que quiser ai na sua casa...
Script basico de troca de itens:
elseif talk_state == 1 then
if msgcontains(msg, 'yes') then
itemstatus = doPlayerRemoveItem(cid,2379,1)
if itemstatus == 0 then
selfSay('Sorry, you not have this item.')
else
doPlayerAddItem(cid,2148,2)
selfSay('Thanks for this item.')
end
end
talk_state = 0
NPC Completo:
local focus = 0
local talk_start = 0
local target = 0
local following = false
local attacking = false
function onThingMove(creature, thing, oldpos, oldstackpos)
end
function onCreatureAppear(creature)
end
function onCreatureDisappear(cid, pos)
if focus == cid then
selfSay('Good bye then.')
focus = 0
talk_start = 0
end
end
function onCreatureTurn(creature)
end
function msgcontains(txt, str)
return (string.find(txt, str) and not string.find(txt, '(%w+)' .. str) and not string.find(txt, str .. '(%w+)'))
end
function onCreatureSay(cid, type, msg)
msg = string.lower(msg)
if (msgcontains(msg, 'hi') and (focus == 0)) and getDistanceToCreature(cid) < 4 then
selfSay('Olá ' .. creatureGetName(cid) .. '! Eu te dou um Demon Shield por um Royal Helmet.')
focus = cid
talk_start = os.clock()
elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
selfSay('Sorry, ' .. creatureGetName(cid) .. '! I talk to you in a minute.')
elseif focus == cid then
talk_start = os.clock()
if msgcontains(msg, 'troca') or msgcontains(msg,'trade') then
if queststatus == -1 then
selfSay('Você quer trocar um royal helmet por um demon shield?')
talk_state = 1
elseif msgcontains(msg, 'exemplo de quest') or msgcontains(msg,'exemplo de quest.') then
selfSay('Você quer trocar um royal helmet por um demon shield?')
talk_state = 2
elseif talk_state == 1 then
if msgcontains(msg, 'yes') then
itemstatus = doPlayerRemoveItem(cid,2498,1) <------ Item que será removido para trocar
if itemstatus == 0 then
selfSay('Sorry, you not have items.')
else
doPlayerAddItem(cid,2520,2) <---- Item que o player ganhará na troca
selfSay('Thanks for items.')
end
end
talk_state = 0
elseif talk_state == 2 then
if msgcontains(msg, 'yes') then
itemstatus = doPlayerRemoveItem(cid,2498,1)
if itemstatus == 0 then
selfSay('Sorry, you not have items.')
else
doPlayerAddItem(cid,2520,2)
selfSay('Thanks for items.')
end
end
talk_state = 0
elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then
selfSay('Good bye, ' .. creatureGetName(cid) .. '!')
focus = 0
talk_start = 0
end
end
end
function onCreatureChangeOutfit(creature)
end
function onThink()
if (os.clock() - talk_start) > 30 then
if focus > 0 then
selfSay('Next Please...')
end
focus = 0
end
if focus ~= 0 then
if getDistanceToCreature(focus) > 5 then
selfSay('Good bye then.')
focus = 0
end
end
end
Créditos pelo script: Tryller.
Espero ter ajudado...





info
Grupo: Artesão
Registrado: 09/08/07
Posts: 138
Reputação: +1
Char no Tibia: Gabii'zinhaa
Galera, alguem tem algum NPC que troque itens?
Por exemplo:Eu falo com ele e ele me da 10 spool of yarn em troca de 100 gss
Agradeço desde ja
obrigada.