Ir para conteúdo

Posts Recomendados

Olá galera...

Eu estou querendo um script de npc que venda runas, wands, rods, pots...

tudo separadamente...

Exemplo: eu falo hi com o npc daí ele pergunta oque eu quero comprar...

Runes, wands rods ou pots? entende?

daí se eu falar rods aparece só rods...

agradeço desde já

Link para o comentário
https://xtibia.com/forum/topic/151811-npc-de-runas-etc/
Compartilhar em outros sites

Da uma olhada, ve se é isso:

 

 

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)

local msg = string.lower(msg)

 

if msgcontains(msg, 'hi') and focus == 0 and getDistanceToCreature(cid) < 4 then

selfSay('Hello ' .. creatureGetName(cid) .. '! I sell runes, potions, wands and rods.')

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, 'runes') then

selfSay('I sell hmms (10gps each), uhs (30gps each), gfbs (20gps each), explosions (30gps each), sds (40gps each)

 

and blank runes (5gps each).')

elseif msgcontains(msg, 'wands') then

selfSay('I sell wand of inferno (15k), wand of decay (5k), wand of cosmic energy (10k), wand of vortex (free) and

 

wand of dragonbreath (1k).')

elseif msgcontains(msg, 'rods') then

selfSay('I sell quagmire rod (10k), snakebite rod (free), hailstorm rod (15k), necrotic rod (5k) and moonlight rod

 

(1k).')

elseif msgcontains(msg, 'potions') then

selfSay('I sell healthpotion (150gp), manapotion (100gp), strong health potion (300gp), great health potion

 

(500gp), great mana potion (450gp), strong mana potion (250gp).')

 

-- inicio da venda de wands =)

 

elseif msgcontains(msg, 'inferno') then

count = getCount(msg)

if count == 0 then

selfSay('0 wand of inferno? LOL?')

talk_start = os.clock()

else

buy(cid,2187,count,15000)

end

 

elseif msgcontains(msg, 'decay') then

count = getCount(msg)

if count == 0 then

selfSay('0 wand of decay? LOL?')

talk_start = os.clock()

else

buy(cid,2188,count,5000)

end

 

elseif msgcontains(msg, 'cosmic energy') then

count = getCount(msg)

if count == 0 then

selfSay('0 wand of cosmic energy? LOL?')

talk_start = os.clock()

else

buy(cid,2189,count,10000)

end

 

elseif msgcontains(msg, 'vortex') then

count = getCount(msg)

if count == 0 then

selfSay('0 wand of vortex? LOL?')

talk_start = os.clock()

else

buy(cid,2190,count,0)

end

 

elseif msgcontains(msg, 'dragonbreath') then

count = getCount(msg)

if count == 0 then

selfSay('0 Wand of Dragonbreath? LOL?')

talk_start = os.clock()

else

buy(cid,2191,count,1000)

end

 

-- fim da venda de wands =)

-- inicio da venda de rods =)

 

elseif msgcontains(msg, 'quagmire') then

count = getCount(msg)

if count == 0 then

selfSay('0 Quagmire Rod? LOL?')

talk_start = os.clock()

else

buy(cid,2181,count,10000)

end

 

elseif msgcontains(msg, 'snakebite') then

count = getCount(msg)

if count == 0 then

selfSay('0 Snakebite Rod? LOL?')

talk_start = os.clock()

else

buy(cid,2182,count,0)

end

 

elseif msgcontains(msg, 'hailstorm') then

count = getCount(msg)

if count == 0 then

selfSay('0 Hailstorm Rod? LOL?')

talk_start = os.clock()

else

buy(cid,2183,count,15000)

end

 

elseif msgcontains(msg, 'volcanic') then

count = getCount(msg)

if count == 0 then

selfSay('0 Volcanic Rod? LOL?')

talk_start = os.clock()

else

buy(cid,2185,count,5000)

end

 

elseif msgcontains(msg, 'moonlight') then

count = getCount(msg)

if count == 0 then

selfSay('0 Moonlight Rod? LOL?')

talk_start = os.clock()

else

buy(cid,2186,count,1000)

end

 

-- fim da venda de rods =)

-- inicio da venda de runas =)

 

elseif msgcontains(msg, 'hmm') then

count = getCount(msg)

if count == 0 then

selfSay('0 Hmm? LOL?')

talk_start = os.clock()

else

buy(cid,2311,count,10)

end

 

elseif msgcontains(msg, 'uh') then

count = getCount(msg)

if count == 0 then

selfSay('0 UH? LOL?')

talk_start = os.clock()

else

buy(cid,2273,count,25)

end

 

elseif msgcontains(msg, 'gfb') then

count = getCount(msg)

if count == 0 then

selfSay('0 GFB? LOL?')

talk_start = os.clock()

else

buy(cid,2304,count,20)

end

 

elseif msgcontains(msg, 'explosion') then

count = getCount(msg)

if count == 0 then

selfSay('0 EXPLO? LOL?')

talk_start = os.clock()

else

buy(cid,2313,count,20)

end

 

elseif msgcontains(msg, 'sd') then

count = getCount(msg)

if count == 0 then

selfSay('0 SD? LOL?')

talk_start = os.clock()

else

buy(cid,2268,count,30)

end

 

-- fim da venda de runas =)

-- inicio da venda de potions =)

 

elseif msgcontains(msg, 'manapotion') or msgcontains(msg, 'mp') then

buy(cid,7620,getCount(msg),100)

elseif msgcontains(msg, 'healthpotion') or msgcontains(msg, 'hp') then

buy(cid,7618,getCount(msg),150)

elseif msgcontains(msg, 'strong mana potion') or msgcontains(msg, 'smp') then

buy(cid,7589,getCount(msg),250)

elseif msgcontains(msg, 'strong health potion') or msgcontains(msg, 'shp') then

buy(cid,7588,getCount(msg),300)

elseif msgcontains(msg, 'great mana potion') or msgcontains(msg, 'gmp') then

buy(cid,7590,getCount(msg),400)

elseif msgcontains(msg, 'great health potion') or msgcontains(msg, 'ghp') then

buy(cid,7591,getCount(msg),500)

 

-- fim da venda venda de potions =)

 

elseif string.find(msg, '(%a*)bye(%a*)') and getDistanceToCreature(cid) < 4 then

selfSay('Good bye, ' .. creatureGetName(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('Next Please...')

end

focus = 0

end

if focus ~= 0 then

if getDistanceToCreature(focus) > 5 then

selfSay('Good bye then.')

focus = 0

end

end

end

 

 

;

 

Caso for, da um rep+ ;D

Abraços ;*

Link para o comentário
https://xtibia.com/forum/topic/151811-npc-de-runas-etc/#findComment-1002991
Compartilhar em outros sites

×
×
  • Criar Novo...