Vamos Começar.
E sem créditos aprendi sozinho :]
Vai : seuot/data/npc
ai vão ter vários
copia 1 e renomeie pro nome que quiser : Ex : Joao
Ai dentro vai ficar assim:
<?xml version="1.0"?>
<npc name="Joao" script="data/npc/scripts/municao.lua" access="3" lookdir="2">
<mana now="800" max="800"/>
<health now="200" max="200"/>
<look type="128" head="20" body="30" legs="40" feet="50"/>
</npc>
Explicação:
Negrito : É o nome do npc... que no nosso exemplo é Joao. Isso nunca tentei mas é mais garantido botar SEM acento.
Azul: Ali é onde vai ficar tudo que seu npc vai falar... mas vamos configurar depois.Nomeie por exemplo como : municao . SEM acento e Ç
Rosa: Ali é o access que se ficar "3" ninguém pode atacar seu NPC.
Verde: Alí é outfit do Npc. Mude se quiser... mas não é necessário.
Npc feito agora vamos para o script:
Vai : seuot/data/npc/script
Vão ter vários novamente.
Então copie e renomeie para o script que colocamos antes... no exemplo foi : municao
Lá dentro vai ter :
local focus = 0local 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 crossbows (200gps), bows (100gps), arrows (100gps), bolts (150gps), burst arrow (150gps), power bolt (300gps) and spears (100gps).')
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
talk_start = os.clock()
if msgcontains(msg, 'crossbow') then
buy(cid,2455,getCount(msg),200)
elseif msgcontains(msg, 'bow') then
buy(cid,2456,getCount(msg),100)
elseif msgcontains(msg, 'arrows') then
buy(cid,2544,getCount(msg),100)
elseif msgcontains(msg, 'bolts') then
buy(cid,2543,getCount(msg),150)
elseif msgcontains(msg, 'spears') then
buy(cid,2389,getCount(msg),100)
elseif msgcontains(msg, 'burst arrow') then
buy(cid,2546,getCount(msg),150)
elseif msgcontains(msg, 'power bolt') then
buy(cid,2547,getCount(msg),300)
elseif msgcontains(msg, 'bye') and focus == cid and getDistanceToCreature(cid) < 4 then
selfSay('Good bye, ' .. creatureGetName(cid) .. '!')
focus = 0
talk_start = 0
end
end
end
function onCreatureChangeOutfit(creature)
end
function onThink()
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
Vamos mexer apenas nas coisas simples...
Tudo que estiver em vermelho é o que o player fala e em azul o que seu npc responde.
Primeira parte:
Player fala : Hi
Npc Responde: Hello, "Mariazinha"... I sell crossbow... << isso vc pode editar.. colocando em portugues ... editando os preços...Mas eu recomendo deixar em inglês pq se algum player fora do brasil for jogar... ele tem que comprar tb :]
Segunda Parte:
NPC ocupado:
Player fala : Hi
Npc Responde : Sorry, "Mariazinha", i talk u...<< quando ele estiver com alguem sendo atendido vai fala isso... editar só se vc quiser por portugês.
Terceira Parte:
Esse script não é bem completo... um completo responderia tudo que o player fala... esse apenas dá o item pra ser mais rápido...
Ex:
Player fala: crossbow (vermelho)
ai em rosa é o ID do item que vai dar. crossbow :2455
e em verde é a quantia que vai ser retirada do player. crossbow :200 << pode editar o valor do crossbow e dos items se quiser :].
E finalmente o bye:
Player diz: bye
Npc diz: Good bye , "Mariazinha".
Isso ai
e o spawn do seu npc depende de seu OT...
Eu não conheço mto bem os OT's então não pergunte essa parte pra mim
Pq só sei do meu ^^!
E é isso
valeu
e postem sobre o que acharam.
E não sei se já tem npc de munição.... se tiver desculpa
By GOD Oni