Vá na pasta data/npcs e crie um arquivo chamado MAILLER.xml, adicione isso dentro:
<?xml version="1.0"?> <npc name="PostManager" script="data/npc/scripts/mail.lua" access="3" lookdir="3" walkinterval="2000"> <health now="1" max="1"/> <look type="128" head="20" body="100" legs="50" feet="99"/> </npc>
Agora vá na pasta data/npcs/scripts e crie um arquivo chamado mail.lua, adicione isso dentro:
local focus = 0
local talk_start = 0
local talk_state = 0
function onThingMove(creature, thing, oldpos, oldstackpos)
end
function onCreatureAppear(creature)
end
function onCreatureTurn(creature)
end
function onCreatureDisappear(cid, pos)
if focus == cid then
selfSay('Ate mais, '.. creatureGetName(cid).. ' !')
focus = 0
talk_start = 0
end
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)
quantidade = getCount(msg)
if (msgcontains(msg, 'hi') and focus == 0) and getDistanceToCreature(cid) < 4 then
selfSay('Ola ' .. creatureGetName(cid) .. ' ! Eu vendo parcels e labels.')
focus = cid
talk_start = os.clock()
talk_state = 1
elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
selfSay('Desculpe-me, ' .. creatureGetName(cid) .. '! Falo com voce em um minuto.')
elseif quantidade >= 21 then
selfSay('Desculpe mas so posso vender ate 20 itens.')
elseif msgcontains(msg, 'parcel') and quantidade <= 20 and talk_state == 1 or msgcontains(msg, 'parcels') and quantidade <= 20 and talk_state == 1 then
selfSay('Deseja comprar ' .. quantidade .. ' parcel(s) e ' .. quantidade.. ' label(s) por ' .. quantidade*30 .. ' gps?')
talk_start = os.clock()
talk_state = 2
if msgcontains(msg, 'yes') and talk_state == 2 or msgcontains(msg, 'sim') and talk_state == 2 then
buy(cid,2595,getCount(msg),20)
buy(cid,2599,getCount(msg),10)
talk_start = os.clock()
end
elseif msgcontains(msg, 'label') and quantidade <= 20 and talk_state == 1 or msgcontains(msg, 'labels') and quantidade <= 20 and talk_state == 1 then
selfSay('Deseja comprar ' .. quantidade .. ' label(s) por ' .. quantidade*10 .. ' gps ?')
talk_start = os.clock()
talk_state = 3
if msgcontains(msg, 'yes') and talk_state == 3 or msgcontains(msg, 'sim') and talk_state == 3 then
buy(cid,2599,getCount(msg),10)
talk_start = os.clock()
end
elseif focus == cid and msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 5 then
selfSay('Ate mais, ' .. creatureGetName(cid) .. '!')
focus = 0
talk_start = 0
talk_state = 0
elseif (focus == cid) and getDistanceToCreature(cid) < 5 then
selfSay('Desculpe-me, ' .. creatureGetName(cid) .. '! Nao entendi.')
talk_start = os.clock()
talk_state = 0
end
end
function onCreatureChangeOutfit(creature)
end
function onThink()
doNpcSetCreatureFocus(focus)
if (os.clock() - talk_start) > 30 then
if focus > 0 then
selfSay('Proximo por favor!')
talk_start = 0
talk_state = 0
focus = 0
end
end
if focus ~= 0 then
if getDistanceToCreature(focus) > 5 then
selfSay('Ate mais, '.. creatureGetName(focus).. ' !')
focus = 0
talk_start = 0
talk_state = 0
end
end
end
@EDITADO, TESTE!





info
Grupo: Barão
Registrado: 23/03/08
Posts: 205
Reputação: +4
venho aqui pedir para voces um script para um npc que venda item, exemplo label e parcel
tipo hi label yes
parcel yes
entendeeram? sem usar trade