Aí, gostaria de um script de npc no qual ele vendesse um item ao falar com ele, simples não? (mas eu nao sei fazer..) Exemplo:
Player: Hi
Npc: Hi
Player: 10 chicken feathers
Npc: Do you want buy 10 chicken feather for 10000 gold coins?
Info: Ot 8.6
Obs: Não pode ser: Hi/trade e dai ta la os itens... tem que ser por fala mesmo. Se alguém puder ajudar... vou colocar o script de um só que quando eu falo hi não acontece nada se alguém quiser, tbm pode arrumar ^^ Obrigado desde já.
SCRIPT:
-- Walking --
max_x = 1 -- change the max x here. Means the NPC wont walk more to east or west as the number which is set here.
max_y = 1 --change the max y here. Means the NPC wont walk more to north or south as the number which is set here.
current_x = 0 --do nothing change here
current_y = 0 --do nothing change here
max_x = max_x - 1 --do nothing change here
max_y = max_y - 1 --do nothing change here
-- End Walking--
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('olá ' .. getcreatureName(cid) .. '! eu vendo os itens para addons , todos por 10k(cada) , fale o item que você quer que eu irei vender..')
focus = cid
talk_start = os.clock()
elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
selfSay('Desculpa, ' .. getcreatureName(cid) .. '! Ja falo com você.')
elseif focus == cid then
talk_start = os.clock()
if msgcontains(msg, 'chicken feather') then
buy(cid,5890,1,1000)
elseif msgcontains(msg, 'minotaur leather') then
buy(cid,5878,1,1000)
elseif msgcontains(msg, 'Holy Orchid') then
buy(cid,5922,1,10000)
elseif msgcontains(msg, 'ape fur') then
buy(cid,5883,1,1000)
elseif msgcontains(msg, 'honeycomb') then
buy(cid,5902,1,1000)
elseif msgcontains(msg, 'sniper gloves') then
buy(cid,5875,1,10000)
elseif msgcontains(msg, 'iron ore') then
buy(cid,5880,1,1000)
elseif msgcontains(msg, 'demon horn') then
buy(cid,5954,1,10000)
elseif msgcontains(msg, 'green dragon scale') then
buy(cid,5920,1,10000)
elseif msgcontains(msg, 'holy orchid') then
buy(cid,5922,1,1000)
elseif msgcontains(msg, 'turtle shell') then
buy(cid,5899,1,1000)
elseif msgcontains(msg, 'green dragon leather') then
buy(cid,5877,1,1000)
elseif msgcontains(msg, 'bat wing') then
buy(cid,5894,1,1000)
elseif msgcontains(msg, 'giant spider silk') then
buy(cid,5879,1,1000)
elseif msgcontains(msg, 'blue piece of cloth') then
buy(cid,5912,1,1000)
elseif msgcontains(msg, 'wolf paw') then
buy(cid,5897,1,1000)
elseif msgcontains(msg, 'demon dust') then
buy(cid,5906,1,50000)
elseif msgcontains(msg, 'Green Piece of Cloth') then
buy(cid,5910,1,1000)
elseif msgcontains(msg, 'brown piece of cloth') then
buy(cid,5913,1,1000)
elseif msgcontains(msg, 'demonic essence') then
buy(cid,6500,1,1000)
elseif msgcontains(msg, 'red dragon leather') then
buy(cid,5948,1,10000)
elseif msgcontains(msg, 'white piece of cloth') then
buy(cid,5909,1,1000)
elseif msgcontains(msg, 'red dragon scale') then
buy(cid,7314,1,1000)
elseif msgcontains(msg, 'vampire dust') then
buy(cid,5905,1,1000)
elseif msgcontains(msg, 'behemoth claw') then
buy(cid,5930,1,1000)
elseif msgcontains(msg, 'staff') then
buy(cid,2401,1,10000)
elseif msgcontains(msg, 'yellow piece of cloth') then
buy(cid,5914,1,1000)
elseif msgcontains(msg, 'wolf paw') then
buy(cid,5897,1,10000)
elseif msgcontains(msg, 'red piece of cloth') then
buy(cid,5911,1,1000)
elseif msgcontains(msg, 'lizard leather') then
buy(cid,5876,1,1000)
elseif msgcontains(msg, 'lizard scale') then
buy(cid,5881,1,1000)
elseif msgcontains(msg, 'perfect behemoth fang') then
buy(cid,5893,1,1000)
elseif msgcontains(msg, 'fish fin') then
buy(cid,5895,1,1000)
elseif msgcontains(msg, 'bear paw') then
buy(cid,5896,1,1000)
elseif msgcontains(msg, 'beholder eye') then
buy(cid,5898,1,1000)
elseif msgcontains(msg, 'dwarven beard') then
buy(cid,5900,1,1000)
elseif msgcontains(msg, 'heaven blossom') then
buy(cid,5921,1,1000)
elseif msgcontains(msg, 'shard') then
buy(cid,7290,1,1000)
elseif msgcontains(msg, 'hardened bone') then
buy(cid,5925,1,1000)
elseif msgcontains(msg, 'blessed wooden stake') then
buy(cid,5942,1,10000)
elseif msgcontains(msg, 'enchanted chicken wing') then
buy(cid,5891,1,15000)
elseif msgcontains(msg, 'piece of royal steel') then
buy(cid,5887,1,55000)
elseif msgcontains(msg, 'piece of draconian steel') then
buy(cid,5889,1,55000)
elseif msgcontains(msg, 'piece of hell steel') then
buy(cid,5888,1,55000)
elseif msgcontains(msg, 'ankh') then
buy(cid,2193,1,5000)
elseif msgcontains(msg, 'huge chunk of crude iron') then
buy(cid,5892,1,130000)
elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then
selfSay('Adeus, ' .. getcreatureName(cid) .. '!')
focus = 0
talk_start = 0
end
end
end
function onCreatureChangeOutfit(creature)
end
function onThink()
-- Walking --
if focus == 0 and max_x >= 0 and max_y >= 0 then
cx, cy, cz = selfGetPosition()
randmove = math.random(1,20)
if randmove == 4 and current_x <= max_x then
nx = cx + 1
current_x = current_x + 1
elseif randmove == 8 and current_x >= (max_x - (max_x * 2)) then
nx = cx - 1
current_x = current_x - 1
elseif randmove == 12 and current_y <= max_y then
ny = cy + 1
current_y = current_y + 1
elseif randmove == 16 and current_y >= (max_y - (max_y * 2)) then
ny = cy - 1
current_y = current_y - 1
elseif randmove <= 20 then
nx = cx
ny = cy
end
moveToPosition(nx, ny, cz)
end
-- End Walking --
if (os.clock() - talk_start) > 30 then
if focus > 0 then
selfSay('proximo...')
end
focus = 0
end
if focus ~= 0 then
if getDistanceToCreature(focus) > 5 then
selfSay('Good bye then.')
focus = 0
end
end
end