Olá. Eu estava precisando de um NPC que trocasse Worn Soft Boots por Soft Boots novas. Então, peguei um NPC que trocava items por outros items, e editei para que ele trocasse Soft Boots. Mais acontece que não deu certo, o NPC não responde a "hi", "hello", nem nada. Será que alguém pode me dizer o que há de errado com ele? O script está abaixo.
local focus = 0 local talk_start = 0 local target = 0 local following = false local attacking = false local addon_state = 0 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á ' .. getCreatureName(cid) .. '... Olá... Você gostaria que eu reparasse sua worn {soft boots}?') focus = cid talk_start = os.clock() elseif focus == cid then talk_start = os.clock() if msgcontains(msg, 'repair') or msgcontains(msg, 'soft boots') then if doPlayerRemoveItem(cid,6530,1) and doPlayerRemoveItem(cid,2160,1) == 0 then selfSay('Desculpe, voce nao tem uma Worn Soft Boots e/ou o dinheiro necessario.') addon_state = 0 else selfSay('Prontinho. Aqui está seu par de soft boots.') doPlayerAddItem(cid,2460, 1) talk_start = 0 end elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then selfSay('Adeus, ' .. getCreatureName(cid) .. '! Volte quando quiser..') focus = 0 talk_start = 0 end end end function onCreatureChangeOutfit(creature) end function onThink() doNpcSetCreatureFocus(focus) if (os.clock() - talk_start) > 60 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
Esqueci de dizer a versão do server em que testei... Que eh TFS 0.3.1 8.40
Agradeço desde já!