focus = 0 talk_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) < 4 then selfSay('Hello, ' .. creatureGetName(cid) .. '! I sell ropes (50gps), shovels (20gps), backpacks (10gps), manafluids (100gps), lifefluids (60gps) and fishing rods (100gps). I buy vials (10gps).') focus = cid talk_start = os.clock() elseif string.find(msg, '(%a*)hi(%a*)') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then selfSay('Sorry, ' .. creatureGetName(cid) .. '! I talk to you in a minute.') elseif msgcontains(msg, 'rope') and focus == cid then buy(cid,2941,1,50) talk_start = os.clock() elseif msgcontains(msg, 'shovel') and focus == cid then buy(cid,3395,1,20) talk_start = os.clock() elseif msgcontains(msg, 'backpack') and focus == cid then buy(cid,2792,1,10) talk_start = os.clock() elseif msgcontains(msg, 'manafluid') or msgcontains(msg, 'mana fluid') and focus == cid then buy(cid,2812,7,100) talk_start = os.clock() elseif msgcontains(msg, 'lifefluid') or msgcontains(msg, 'life fluid') and focus == cid then buy(cid,2812,10,60) talk_start = os.clock() elseif msgcontains(msg, 'fishing rod') and focus == cid then buy(cid,3421,1,100) talk_start = os.clock() elseif (msgcontains(msg, 'vial') or msgcontains(msg, 'flask')) and focus == cid then sell(cid,2812,1,10) talk_start = os.clock() elseif string.find(msg, '(%a*)bye(%a*)') and focus == cid and getDistanceToCreature(cid) < 4 then selfSay('Good bye, ' .. 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('Next Please...') end focus = 0 end if focus ~= 0 then if getDistanceToCreature(focus) > 5 then selfSay('Good bye then.') focus = 0 end end end
AGORA VOCÊ FAZ O SEGUINTE:
elseif msgcontains(msg, 'rope') and focus == cid thenbuy(cid,2941,1,50)
talk_start = os.clock()
EXPLICAÇÃO:
Laranja: PALAVRA QUE O PLAYER TEM QUE FALAR PARA COMPRAR O ITEM.
AZUL: ID DO ITEM QUE O VO PLAYER VAI COMPRAR.
Verde: Quantidade do item que o player vai receber ao comprar. Ex: se você colocar 2 e o player for comprar uma corda, na hora que ele falar "hi" - "rope", ele irá receber 2 cordas. Então, deixe 1.
Amarelo: Quantidade de dinheiro que o player vai ter que pagar! EM GPS!
Espero ter ajudado. Qualquer dúvida :laughing: