Vamos começar:
Porque fazer um NPC que compra joias?
Se você como eu, gosta de um ot com um sistema de negociação, exemplo, os players estão vendendo o item da caçada, é muito bom, por que aumenta a frequencia da negociação
Para começar recomendo ter Sistema de Mineração, aqui no XTibia tem um monte, é só você ir la e escolher
E também recomendo uma Cidade de Dwarfs, e la o unico lugar para ter esse NPC
Começando
Vá em Data/NPC, copie um arquivo xml renomeie para Jack e dentro coloque:
<?xml version="1.0"?>
<npc name="Jack" script="data/npc/scripts/joias.lua" access="3" lookdir="1" autowalk="100" speed="200">
<health now="100" max="100"/>
<look type="69" head="57" body="59" legs="40" feet="76" addons="2" corpse="2212"/>
<parameters/>
</npc>
Explicando:
<npc name="Jack"... Nome do NPC, mude a vontade...
script="data/npc/scripts/joais.lua"...Nome do script aonde o NPC reconhece os comandos, não mude
access="3"...É o acesso do NPC, caso você coloque menos de 3 os players poderão atacar, recomendo 3.
speed="200">...Velociadade do NPC
<Look type="69"...Look do NPC, a "roupa" dele, no caso 69 é roupa de Dwarf, mas mude ao seu gosto
Agora que ja foi explicado vamos ao Script
Vá em data/npc/scripts copiei um arquivo do tipo LUA, renomeie para joias e dentro coloque:
-----By MatheusMSN-----
target = 0
following = false
attacking = false
focus = 0
itemid = 0
count = 0
payback = 0
talkcount = 0
talk_start = 0
function onThingMove(creature, thing, oldpos, oldstackpos)
end
function onCreatureAppear(creature)
end
function onCreatureDisappear(id)
if id == target then
target = 0
attacking = false
selfAttackCreature(0)
following = false
end
focus = 0
itemid = 0
end
function onCreatureTurn(creature)
end
function onCreatureSay(cid, type, msg)
msg = string.lower(msg)
dist = getDistanceToCreature(cid)
if dist >= 8 then
return
end
talk_start = os.clock()
if string.find(msg, 'hi') and string.len(msg) == 2 then
if focus == cid then
selfSay('Ja to falando contigo')
else if focus > 0 then
selfSay('Estou ocupado')
end
end
if(focus == 0) then
selfSay('Olá , compro joias, ' .. creatureGetName(cid) .. '.')
focus = cid
end
talk_start = os.clock()
end
if string.find(msg, '(%a*)sell black pearl(%a*)') and focus == cid then
selfSay('Do you want to sell a Black Pearl for 280gps?')
talk_start = os.clock()
price = 280
talkcount = 2
itemid = 2144
count = 1
return
end
if string.find(msg, '(%a*)sell white pearl(%a*)') and focus == cid then
selfSay('Do you want to sell a White Pearl for 280gps?')
talk_start = os.clock()
price = 280
talkcount = 2
itemid = 2143
count = 1
return
end
if string.find(msg, '(%a*)sell small diamond(%a*)') and focus == cid then
selfSay('Do you want to sell a Small Diamond for 225gps?')
talk_start = os.clock()
price = 225
talkcount = 2
itemid = 2145
count = 1
return
end
if string.find(msg, '(%a*)sell small sapphire(%a*)') and focus == cid then
selfSay('Do you want to sell a Small Sapphire for 200gps?')
talk_start = os.clock()
price = 200
talkcount = 2
itemid = 2146
count = 1
return
end
if string.find(msg, '(%a*)sell small ruby(%a*)') and focus == cid then
selfSay('Do you want to sell a Small Ruby for 300gps?')
talk_start = os.clock()
price = 300
talkcount = 2
itemid = 2147
count = 1
return
end
if string.find(msg, '(%a*)sell small smerald(%a*)') and focus == cid then
selfSay('Do you want to sell a Small Smerald for 180gps?')
talk_start = os.clock()
price = 180
talkcount = 2
itemid = 2149
count = 1
return
end
if string.find(msg, '(%a*)sell small amethyst(%a*)') and focus == cid then
selfSay('Do you want to sell a Small Amethyst for 200gps?')
talk_start = os.clock()
price = 200
talkcount = 2
itemid = 2150
count = 1
return
end
if string.find(msg, '(%a*)sell gold nugget(%a*)') and focus == cid then
selfSay('WoW, you have a Gold Nugget? I return 500gps.')
talk_start = os.clock()
price = 500
talkcount = 2
itemid = 2157
count = 1
return
end
if string.find(msg, '(%a*)sell some golden fruits(%a*)') and focus == cid then
selfSay('Wow, you have Some Golden Fruits for 1000gps?')
talk_start = os.clock()
price = 1000
talkcount = 2
itemid = 2137
count = 1
return
end
if string.find(msg, '(%a*)yes(%a*)') and cid == focus then
if talkcount == 1 then
buy(cid,itemid,count,price)
talk_start = os.clock()
end
if talkcount == 2 then
sell(cid,itemid,count,price)
talk_start = os.clock()
end
if string.find(msg, '(%a*)bye(%a*)') and focus == cid and getDistanceToCreature(cid) < 3 then
selfSay('Adeus')
focus = 0
itemid = 0
talk_start = 0
talkcount = 0
end
end
function onCreatureChangeOutfit(creature)
end
function onThink()
if (os.clock() - talk_start) > 30 then
if focus > 0 then
selfSay('Até logo...')
talkcount = 0
end
focus = 0
itemid = 0
talk_start = 0
end
if focus == 0 then
cx, cy, cz = selfGetPosition()
randmove = math.random(1,50)
if randmove == 1 then
nx = cx + 1
end
if randmove == 2 then
nx = cx - 1
end
if randmove == 3 then
ny = cy + 1
end
if randmove == 4 then
ny = cy - 1
end
if randmove >= 5 then
nx = cx
ny = cy
end
moveToPosition(nx, ny, cz)
--summons = 30
--summons2 = 30
end
end
end
Pronta agora teste.
Primeiramente já havia um NPC comprador de jóias no XTibia, ele porém, no meu OT, não funcionava, a dona do primeiro se chama UpKing
Lembre-se, eu só copiei a idéia, mas não copiei preços e ids.