gorz 1 Postado Fevereiro 18, 2011 Share Postado Fevereiro 18, 2011 Gente,eu tava preciando de um npc que vende food e outro npc q vende itens de atirar com arrows,bolt etc.Me arranjem ae plz.A vercao e 8.7 Link para o comentário Compartilhar em outros sites More sharing options...
KamuiRunt 55 Postado Fevereiro 19, 2011 Share Postado Fevereiro 19, 2011 Food: 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('Xauzin Gordo ;O.') 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á ' .. creatureGetName(cid) .. '! Eu vendo: hams, meats, carrots, apples, brown breads, brown mushrooms and eggs (Tudo por apenas 9gps).') focus = cid talk_start = os.clock() elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then selfSay('Ow, ' .. creatureGetName(cid) .. '! Calma Ae =).') elseif focus == cid then talk_start = os.clock() if msgcontains(msg, 'brown bread') or msgcontains(msg, 'brown breads')then count = getCount(msg) price = count*8 buy(cid,2691,count,price) elseif msgcontains(msg, 'ham') or msgcontains(msg, 'hams')then count = getCount(msg) price = count*8 buy(cid,2671,count,price) elseif msgcontains(msg, 'carrot') or msgcontains(msg, 'carrots') then count = getCount(msg) price = count*8 buy(cid,2684,count,price) elseif msgcontains(msg, 'meat') or msgcontains(msg, 'meats')then count = getCount(msg) price = count*8 buy(cid,2666,count,price) elseif msgcontains(msg, 'apple') or msgcontains(msg, 'apples')then count = getCount(msg) price = count*8 buy(cid,2674,count,price) elseif msgcontains(msg, 'brown mushroom') or msgcontains(msg, 'brown mushroooms')then count = getCount(msg) price = count*8 buy(cid,2789,count,price) elseif msgcontains(msg, 'egg') or msgcontains(msg, 'eggs')then count = getCount(msg) price = count*8 buy(cid,2695,count,price) elseif msgcontains(msg, 'bye') 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('Proximo -.-.') end focus = 0 end if focus ~= 0 then if getDistanceToCreature(focus) > 5 then selfSay('Xauzin _|_.') focus = 0 end end end Bows: 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('Xauzin '-'.') 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á ' .. creatureGetName(cid) .. '! Eu Vendo throwing star (300gps), viper star(300gps), assassin star(1k), crossbows (200gps), bows (100gps), arrows (30gps), bolts (50gps), earth arrow (50gps), flash arrow (50gps), sniper arrow (50gps), piercing bolt (60gps), flaming arrow (50gps), shiver arrow (50gps), onyx arrow (50gps), viper star (100gps) and spears (20gps).') focus = cid talk_start = os.clock() elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then selfSay('Desculpe, ' .. creatureGetName(cid) .. '! Ja ja eu falo com você ^^.') 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, 'throwing star') then buy(cid,2399,getCount(msg),300) elseif msgcontains(msg, 'viper star') then buy(cid,7366,getCount(msg),300) elseif msgcontains(msg, 'assassin star') then buy(cid,7368,getCount(msg),1000) elseif msgcontains(msg, 'arrows') then buy(cid,2544,getCount(msg),30) elseif msgcontains(msg, 'bolts') then buy(cid,2543,getCount(msg),50) elseif msgcontains(msg, 'spears') then buy(cid,2389,getCount(msg),20) elseif msgcontains(msg, 'earth arrow') then buy(cid,7850,getCount(msg),50) elseif msgcontains(msg, 'flash arrow') then buy(cid,7838,getCount(msg),50) elseif msgcontains(msg, 'sniper arrow') then buy(cid,7364,getCount(msg),50) elseif msgcontains(msg, 'piercing bolt') then buy(cid,7363,getCount(msg),60) elseif msgcontains(msg, 'flaming arrow') then buy(cid,7840,getCount(msg),50) elseif msgcontains(msg, 'shiver arrow') then buy(cid,7839,getCount(msg),50) elseif msgcontains(msg, 'onyx arrow') then buy(cid,7365,getCount(msg),50) 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() -- 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 ;D') end focus = 0 end if focus ~= 0 then if getDistanceToCreature(focus) > 5 then selfSay('Olha la aonde você vai enfiar essa flecha em ;D kkkkk (:.') focus = 0 end end end Se te ajudei da um rep + ;D Abraços ;* Link para o comentário Compartilhar em outros sites More sharing options...
Demonbholder 420 Postado Fevereiro 19, 2011 Share Postado Fevereiro 19, 2011 Nossa, Kamui, acho que ele criou um double topic, porque eu já ajudei outro dele igual a esse. Link do doubletopic: http://www.xtibia.com/forum/topic/151947-fechado-food-npc/ Link para o comentário Compartilhar em outros sites More sharing options...
LorDz 14 Postado Fevereiro 19, 2011 Share Postado Fevereiro 19, 2011 double topic, Fechado. Link para o comentário Compartilhar em outros sites More sharing options...
Posts Recomendados