Exclusivo para XTibia
favor não postar em outro forum
Cansei de ver as BPs da mesma cor nos OTs
Criei esse NPC Back Picka
(AhuHhehUahaE)
1° - Vamos acertar uma das BPs
Confira seu data\items\items.xml
Se estiver assim :
<item id="3960" name="backpack"> <attribute key="weight" value="1800"/> <attribute key="containerSize" value="20"/> <attribute key="slotType" value="backpack"/> </item>
troca por isto :
<item id="3960" name="an old and used backpack"> <attribute key="description" value="A label on the backpack reads: Property of Sam, Thais."/> <attribute key="weight" value="1800"/> <attribute key="containerSize" value="20"/> <attribute key="slotType" value="backpack"/> </item>
=======================================================================
2° - Criando o NPC
data\npc\BackPicka.xml
<?xml version="1.0"?> <npc name="Back Picka" script="data/npc/scripts/bp.lua" access="3" lookdir="1" autowalk="200" speed="200"> <health now="1" max="1"/> <look type="160" head="38" body="79" legs="107" feet="114"/> </npc>
Altere o look type a gosto.
A velocidade de andar e mover eu puz 200
(quase não fica parado e anda na velocidade BOH)
=======================================================================
3° - Criando o Script
data\npc\scripts\bp.lua
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('Hello ' .. creatureGetName(cid) .. '! I sell all types of BackPack for 20 gps each.') 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 if msgcontains(msg, 'bp') or msgcontains(msg, 'backpack') or msgcontains(msg, 'bps') or msgcontains(msg, 'backpacks') then selfSay('I sell brown (1) , green (2) , yellow (3) , red (4) , purple (5) , blue (6) , gray(7) , golden (8) , star (9) , camouflage (10).') selfSay('I can sell specials pirate (11) , holding (12) , sam (13) , fur (14).') talk_start = os.clock() elseif msgcontains(msg, 'brown') or msgcontains(msg, '1') then buy(cid,1988,1,20) elseif msgcontains(msg, 'green') or msgcontains(msg, '2') then buy(cid,1998,1,20) elseif msgcontains(msg, 'yellow') or msgcontains(msg, '3') then buy(cid,1999,1,20) elseif msgcontains(msg, 'red') or msgcontains(msg, '4') then buy(cid,2000,1,20) elseif msgcontains(msg, 'purple') or msgcontains(msg, '5') then buy(cid,2001,1,20) elseif msgcontains(msg, 'blue') or msgcontains(msg, '6') then buy(cid,2002,1,20) elseif msgcontains(msg, 'gray') or msgcontains(msg, '7') then buy(cid,2003,1,20) elseif msgcontains(msg, 'golden') or msgcontains(msg, '8') then buy(cid,2004,1,20) elseif msgcontains(msg, 'star') or msgcontains(msg, '9') then buy(cid,5949,1,20) elseif msgcontains(msg, 'camouflage') or msgcontains(msg, '10') then buy(cid,3940,1,20) elseif msgcontains(msg, 'pirate') or msgcontains(msg, '11') then buy(cid,5926,1,20) elseif msgcontains(msg, 'holding') or msgcontains(msg, '12') then buy(cid,2365,1,20) elseif msgcontains(msg, 'sam') or msgcontains(msg, '13') then buy(cid,3960,1,20) -- elseif msgcontains(msg, 'fur') or msgcontains(msg, '14') then -- buy(cid,7342,1,20) 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() 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
O Player vai poder comprar a BP pela cor ou pelo número.
Todas BPs valem 20 gps.
Exemplo :
Trecho da fala do NPC
bla-bla-bla (7) , golden (8) , bla-bla-bla
Trecho do script
elseif msgcontains(msg, 'golden') or msgcontains(msg, '8') then buy(cid,2004,1,20)
Se o Player falar "golden" ou "8" ele vai comprar a BP Dourada de Ankrhamun por 20 gps.
(alterar o preço se desejar)
Acho que é só....
:XTibia_smile: