Exclusivo para XTibia
favor não postar em outro forum
Um usuário me pediu um NPC que troca itens.......
Parte do PMOlá Conde Sapo. gostaria de pedir ajuda a você, por favor, visite meu tópico de dúvidas...http://www.xtibia.com/forum/index.php?showtopic=67166
Obrigado!!!
[]'s, Taxijab.
data\npc\Taxijab.xml
<?xml version="1.0"?> <npc name="Taxijab" script="data/npc/scripts/Cheese.lua" access="3" lookdir="1" autowalk="200" speed="200"> <health now="1" max="1"/> <look type="120" head="38" body="79" legs="107" feet="114"/> </npc>
data\npc\scripts\Cheese.lua
-- NPC de troca - By Conde Sapo 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) .. '... Eu daria tudo por alguns queijos... Você tem 5 sobrando aí? Eu posso te dar meu escudo em troca!') focus = cid talk_start = os.clock() elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then selfSay('Sorry, ' .. getCreatureName(cid) .. '! I talk to you in a minute.') elseif focus == cid then talk_start = os.clock() if msgcontains(msg, 'queijo') or msgcontains(msg, 'escudo') then if doPlayerRemoveItem(cid,2696,5) == 0 then selfSay('Eu disse 5 QUEIJOS!') addon_state = 0 else selfSay('Obrigado, muito mesmo! Tome, isto pode ser útil para você!') doPlayerAddItem(cid, 2512, 1) talk_start = 0 end elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then selfSay('Good bye, ' .. getCreatureName(cid) .. '! Come back soon..') focus = 0 talk_start = 0 end end end function onCreatureChangeOutfit(creature) end function onThink() doNpcSetCreatureFocus(focus) 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
É um NPC estremamente simples mas útil pros servers que tem ROOKGARD
O Player entra com 5 queijos e sai com o Wooden Shield
Os usuários mais criatvos podem transformar este simples NPC em um NPC que troca coisas mais interessantes.
o único limite é a criatividade.
Boas Criações.
:XTibia_smile: