Bom consegui fazer o npc que venda bps de runas sem compilar etc...
ai vai o codigo e uma explicaçao rapida!
meu segundo tuto o primeiro e sobre runa a anda na agua , fogo e swap link
http://www.xtibia.com/forum/index.php?showtopic=23533
focus = 0talk_start = 0
target = 0
following = false
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 ((string.find(msg, '(%a*)hi(%a*)')) and (focus == 0)) and getDistanceToCreature(cid) < 3 then
selfSay('Olá ' .. creatureGetName(cid) .. '! Eu vendo bps de runas. por favor no local onde fica sua bp deixe-o com espaço ou vazio , diga por exemplo: bp sd 100')
focus = cid
talk_start = os.clock()
elseif string.find(msg, '(%a*)hi(%a*)') and (focus ~= cid) and getDistanceToCreature(cid) < 3 then
selfSay('Desculpe, ' .. creatureGetName(cid) .. '! Eu falo com você em um minuto.')
elseif msgcontains(msg, 'bps') and focus == cid then
selfSay('Eu vendo bps de runas 100 cargas! Diga por exemplo: "bp sd 100".')
talk_start = os.clock()
elseif msgcontains(msg, 'runas') and focus == cid then
selfSay('Eu vendo bps de runas 100 cargas! Diga por exemplo: "bp sd 100".')
talk_start = os.clock()
elseif msgcontains(msg, 'bp 100') and focus == cid then
selfSay('Eu vendo bps de hmm 100x (1k), gfb 100x (2k), explosion 100x (4k), uh 100x (6k), sd 100x (8k).')
talk_start = os.clock()
elseif msgcontains(msg, 'runa 100') and focus == cid then
selfSay('Eu vendo bps de hmm 100x (50gps), gfb 100x (100gps), explosion 100x (200gps), uh 100x (300), sd 100x (400).')
talk_start = os.clock()
elseif msgcontains(msg, 'bp gfb 100') and focus == cid then
buy(cid,2000,1,2000)
buy(cid,2304,100,0)
buy(cid,2304,100,0)
buy(cid,2304,100,0)
buy(cid,2304,100,0)
buy(cid,2304,100,0)
buy(cid,2304,100,0)
buy(cid,2304,100,0)
buy(cid,2304,100,0)
buy(cid,2304,100,0)
buy(cid,2304,100,0)
buy(cid,2304,100,0)
buy(cid,2304,100,0)
buy(cid,2304,100,0)
buy(cid,2304,100,0)
buy(cid,2304,100,0)
buy(cid,2304,100,0)
buy(cid,2304,100,0)
buy(cid,2304,100,0)
buy(cid,2304,100,0)
buy(cid,2304,100,0)
talk_start = os.clock()
elseif msgcontains(msg, '100 gfb') and focus == cid then
buy(cid,2000,100,100)
talk_start = os.clock()
elseif msgcontains(msg, 'bp explosion 100') and focus == cid then
buy(cid,2001,1,2001)
buy(cid,2313,100,0)
buy(cid,2313,100,0)
buy(cid,2313,100,0)
buy(cid,2313,100,0)
buy(cid,2313,100,0)
buy(cid,2313,100,0)
buy(cid,2313,100,0)
buy(cid,2313,100,0)
buy(cid,2313,100,0)
buy(cid,2313,100,0)
buy(cid,2313,100,0)
buy(cid,2313,100,0)
buy(cid,2313,100,0)
buy(cid,2313,100,0)
buy(cid,2313,100,0)
buy(cid,2313,100,0)
buy(cid,2313,100,0)
buy(cid,2313,100,0)
buy(cid,2313,100,0)
talk_start = os.clock()
elseif msgcontains(msg, '100 explosion') and focus == cid then
buy(cid,2001,100,200)
talk_start = os.clock()
elseif msgcontains(msg, 'bp uh 100') and focus == cid then
buy(cid,2002,1,2002)
buy(cid,2273,100,0)
buy(cid,2273,100,0)
buy(cid,2273,100,0)
buy(cid,2273,100,0)
buy(cid,2273,100,0)
buy(cid,2273,100,0)
buy(cid,2273,100,0)
buy(cid,2273,100,0)
buy(cid,2273,100,0)
buy(cid,2273,100,0)
buy(cid,2273,100,0)
buy(cid,2273,100,0)
buy(cid,2273,100,0)
buy(cid,2273,100,0)
buy(cid,2273,100,0)
buy(cid,2273,100,0)
buy(cid,2273,100,0)
buy(cid,2273,100,0)
buy(cid,2273,100,0)
buy(cid,2273,100,0)
talk_start = os.clock()
elseif msgcontains(msg, '100 uh') and focus == cid then
buy(cid,2002,100,300)
talk_start = os.clock()
elseif msgcontains(msg, 'bp sd 100') and focus == cid then
buy(cid,2003,1,2003)
buy(cid,2268,100,0)
buy(cid,2268,100,0)
buy(cid,2268,100,0)
buy(cid,2268,100,0)
buy(cid,2268,100,0)
buy(cid,2268,100,0)
buy(cid,2268,100,0)
buy(cid,2268,100,0)
buy(cid,2268,100,0)
buy(cid,2268,100,0)
buy(cid,2268,100,0)
buy(cid,2268,100,0)
buy(cid,2268,100,0)
buy(cid,2268,100,0)
buy(cid,2268,100,0)
buy(cid,2268,100,0)
buy(cid,2268,100,0)
buy(cid,2268,100,0)
buy(cid,2268,100,0)
buy(cid,2268,100,0)
talk_start = os.clock()
elseif msgcontains(msg, '100 sd') and focus == cid then
buy(cid,2003,100,400)
talk_start = os.clock()
elseif msgcontains(msg, 'blank') and focus == cid then
buy(cid,3085,1,5)
talk_start = os.clock()
elseif string.find(msg, '(%a*)bye(%a*)') and getDistanceToCreature(cid) < 3 then
selfSay('Até logo, ' .. creatureGetName(cid) .. '!')
focus = 0
talk_start = 0
end
end
function onCreatureChangeOutfit(creature)
end
function onThink()
if (os.clock() - talk_start) > 30 then
if focus > 0 then
selfSay('Próximo por favor...')
end
focus = 0
end
end
OBS: PARA QUE AS RUNAS VENHAM DENTRO DA BP E PRECISO AVISA AOS PLAYER Q RETIREM A BP PRINCIPAL, CASO ISSO NAO SEJA FEITO AS RUNAS CAIRAM NO CHAO.
1.criando o arquivo abre a pasta \data\npc\scripts copie qualquer arquivo.lua apage tudo q ha dentro dele e cole os codigo do quote acima,renomeire como bp.lua
2.na pasta data/npc copie um npcqualquer muda o nome e dentro do arquivo do npc mude o diretorio ex: <npc name="BP" script="data/npc/scripts/bp.lua".
Pronto agora NPC feito.
Comentem plx =]
Nao retirem os creditos!!