Pedroddcunha 3 #1 Postado 18 Novembro, 2006 Ae Não sei se é esta a área certa Mas vai la Créditos *colex -> ele que fez *pedroddcunha -> trouxe para aqui Função buytype(uid,txt,id,min,max,price) Explicando uid variavel do player, normalmente é cid txt varialvel das falas do player, normalmente é msg id id do item que quer vender (apenas para itens em quantidade) min quantidade mínima que ele pode comprar de tal item max quantidade máxima que ele pode comprar de tal item price preço por cada quantidade Exemplo Vendendo Hmm por 40 gp's cada tiro, sendo máximo que se pode comprar é 100 e o mínimo 5 buytype(cid,msg,2311,5,100,40) Exemplo de uma conversa Player Hi Npc Hello Player, I sell runes and arrow's. Player 100 hmm (Player receberá 100x de Hmm) Npc Here you are Player abc50 uh (Player receberá 50x de Uh) Npc Here you are Player arrow (Player receberá a quantidade mínima de arrow) Npc Here you are Adicione 1° Abra o arquivo npc.lua que se encontra na pasta datanpcscriptslib e coloque no final do arquivo isto: -------function buytype by Colex-------function buytype(uid,txt,id,min,max,price)x = string.gsub(txt,"%a","")x = tonumber(x)if x ~= nill and x > min thenif x <= max then price = x * price buy(uid,id,x,price)else price = max * price buy(uid,id,max,price)endelsebuy(uid,id,min,price)endendVamos ao um exemplo de Npc que vende runas, sendo o máximo de tiros em cada rune é 100. focus = 0talk_start = 0target = 0following = falseattacking = falsefunction onThingMove(creature, thing, oldpos, oldstackpos)endfunction onCreatureAppear(creature)endfunction onCreatureDisappear(cid, pos) if focus == cid then selfSay('Good bye then.') focus = 0 talk_start = 0 endendfunction onCreatureTurn(creature)endfunction msgcontains(txt, str) return (string.find(txt, str) and not string.find(txt, '(%w+)' .. str) and not string.find(txt, str .. '(%w+)'))endfunction onCreatureSay(cid, type, msg) msg = string.lower(msg) -- greeting phraseif string.find(msg, '(%a*)hi(%a*)') and focus == 0 and string.len(msg) == 2 and getDistanceToCreature(cid) < 3 then selfSay('Hello ' .. creatureGetName(cid) .. '! I sell runes.') focus = cid talk_start = os.clock() elseif focus == cid then talk_start = os.clock() if msgcontains(msg, 'runes') then selfSay('I sell hmm(40gps), uh(90gps), gfb(60gps), explosion(80gps), sd(100gps) and blank runes(5gps).) elseif msgcontains(msg, 'hmm') then buytype(cid,msg,2311,5,150,40) elseif msgcontains(msg, 'uh') then buytype(cid,msg,2273,1,150,90) elseif msgcontains(msg, 'gfb') then buytype(cid,msg,2304,3,150,60) elseif msgcontains(msg, 'explosion') then buytype(cid,msg,2313,3,150,80) elseif msgcontains(msg, 'sd') then buytype(cid,msg,2311,1,150,100) elseif msgcontains(msg, 'blank') then buy(cid,2260,1,5) ---não usa buytype porque não é item de quantidade elseif string.find(msg, '(%a*)bye(%a*)') and getDistanceToCreature(cid) < 4 then selfSay('Good bye, ' .. creatureGetName(cid) .. '!') focus = 0 talk_start = 0 endendendfunction onCreatureChangeOutfit(creature)endfunction onThink()end Observações*Não retirem os créditos de Colex *Isto serve para qualquer item que seja em quantidade Exemplo: Food's (Meat's, Ham's, Dragon Ham's, ..), Jóias (Smal Ruby / Emerald / ...) entre outros Fui Compartilhar este post Link para o post Compartilhar em outros sites
Flatos 0 #2 Postado 18 Novembro, 2006 Legal, e é a area certa sim. Compartilhar este post Link para o post Compartilhar em outros sites
fagnerx20 0 #3 Postado 19 Novembro, 2006 Olá eu queria saber se existe um selltype tb,e qto ao buytype,se eu coloco min=1 e max=100 ele vai poder comprar de 1 até 100 qtdes,tipow,pd comprar 2,3,50,85,100...é isso? Compartilhar este post Link para o post Compartilhar em outros sites
Pedroddcunha 3 #4 Postado 19 Novembro, 2006 @fagnerx20É, é isso mesmoVocê configura ate o máximo que você quiserAi você fala-Buy 27 boltsVocê vai compra 27 boltsNão sei se tem a selltype ainda Compartilhar este post Link para o post Compartilhar em outros sites
T l l S 0 #5 Postado 23 Novembro, 2006 mto bom cara continua assim Compartilhar este post Link para o post Compartilhar em outros sites
Magus 2 #6 Postado 25 Novembro, 2006 Crie você mesmo uma função selltype(), modificando a postada nesse tópico. Movido para Tutoriais. Compartilhar este post Link para o post Compartilhar em outros sites
-3C- 0 #7 Postado 25 Novembro, 2006 Ótimo tutorial!Conheço o Colex, já trabalhamos juntos!Ele fas ótimos scripts!Abraços,-3C- Compartilhar este post Link para o post Compartilhar em outros sites
Corel 0 #8 Postado 25 Novembro, 2006 Muito Bom mesmo o Tutorial http://forum.otserv.com.br/style_emoticons/<#EMO_DIR#>/smile.gif Gostei Compartilhar este post Link para o post Compartilhar em outros sites
Brunou 0 #9 Postado 25 Novembro, 2006 Essa função é muito boa eu usso em quase todos npcs que eu faço é muito boa ela ;D Compartilhar este post Link para o post Compartilhar em outros sites
(Sic)Army 0 #10 Postado 25 Novembro, 2006 Boa! Aprovado! Continue assim! http://forum.otserv.com.br/style_emoticons/<#EMO_DIR#>/biggrin.gif Compartilhar este post Link para o post Compartilhar em outros sites
DouG 0 #11 Postado 27 Novembro, 2006 LoLMais um tutorial para a revoluçãoHehehe Compartilhar este post Link para o post Compartilhar em outros sites
Kenzo 0 #12 Postado 27 Novembro, 2006 Meu muito bom eu naum sabia u.uMuit bom msm Tinha qe ser do Colex ^^//Kenzo Compartilhar este post Link para o post Compartilhar em outros sites
Kenzo 0 #13 Postado 27 Novembro, 2006 Meu muito bom eu naum sabia u.uMuit bom msm Tinha qe ser do Colex ^^//Kenzo Compartilhar este post Link para o post Compartilhar em outros sites
Convidado Rabico #14 Postado 12 Dezembro, 2006 KKkk Fiko mt Top xD Parabens~ Compartilhar este post Link para o post Compartilhar em outros sites
Convidado Rabico #15 Postado 12 Dezembro, 2006 KKkk Fiko mt Top xD Parabens~ Compartilhar este post Link para o post Compartilhar em outros sites
WexXxley 0 #16 Postado 20 Dezembro, 2006 Aaaahhhh ééééé Caraca, tava a muito tempo atrás de um script parecido, muito bom mesmo, ajudou MUITA GENTE! Colex apavora =P Valew pedro por nos disponibilizar =) Edit1: Cara, sei lá, aqui não rolou no npc, fica dando erro! Sabe o que pode ser? Edit2: Aeeee, dá uma olhada xD 23:22 Malak: Hello GM Carioca! I sell runes. 23:22 GM Carioca [2]: hi 23:22 Malak: Here you are. 23:22 GM Carioca [2]: 71 uh 23:22 You see a spell rune for level 4. It's an "adura vita" spell (71x). It weighs 1.20 oz. ID: 2273. Position(X: 444 Y: 526 Z: 7) Edit3: Coloquei um post do NPC e do npc.lua (data/npc/scripts/lib) sem bugs, arrumei aqui em casa e fiquei muito feliz xD Estou disponibilizando, só que está na próxima página deste mesmo tópico! Falow Compartilhar este post Link para o post Compartilhar em outros sites
WexXxley 0 #17 Postado 20 Dezembro, 2006 Aaaahhhh ééééé Caraca, tava a muito tempo atrás de um script parecido, muito bom mesmo, ajudou MUITA GENTE! Colex apavora =P Valew pedro por nos disponibilizar =) Edit1: Cara, sei lá, aqui não rolou no npc, fica dando erro! Sabe o que pode ser? Edit2: Aeeee, dá uma olhada xD 23:22 Malak: Hello GM Carioca! I sell runes. 23:22 GM Carioca [2]: hi 23:22 Malak: Here you are. 23:22 GM Carioca [2]: 71 uh 23:22 You see a spell rune for level 4. It's an "adura vita" spell (71x). It weighs 1.20 oz. ID: 2273. Position(X: 444 Y: 526 Z: 7) Edit3: Coloquei um post do NPC e do npc.lua (data/npc/scripts/lib) sem bugs, arrumei aqui em casa e fiquei muito feliz xD Estou disponibilizando, só que está na próxima página deste mesmo tópico! Falow Compartilhar este post Link para o post Compartilhar em outros sites
WexXxley 0 #18 Postado 21 Dezembro, 2006 Ae, arrumei os bugs que estavam impedindo o funcionamento do script...lá vai hein: No arquivo: data/npc/scripts/lib/npc.lua Vá até o final do arquivo, pule uma linha do último "end" e cole: function buytype(uid,txt,id,min,max,price) x = string.gsub(txt,"%a","") x = tonumber(x) if x ~= nill and x > min then if x <= max then price = x * price buy(uid,id,x,price) else price = max * price buy(uid,id,max,price) end else buy(uid,id,min,price) end end **************************** Agora, faça esse npc de runas: data/npc/scripts/runes.lua 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 string.len(msg) == 2 and getDistanceToCreature(cid) < 3 then if string.find(msg, '(%a*)hi(%a*)') and focus == 0 and string.len(msg) == 2 then selfSay('Hello ' .. creatureGetName(cid) .. '! I sell runes.') focus = cid talk_start = os.clock() elseif focus == cid then talk_start = os.clock() if msgcontains(msg, 'runes') then selfSay('I sell hmm(40gps), uh(90gps), gfb(60gps), explosion(80gps), sd(100gps) and blank runes(5gps).') elseif msgcontains(msg, 'hmm') then buytype(cid,msg,2311,5,150,40) elseif msgcontains(msg, 'uh') then buytype(cid,msg,2273,1,150,90) elseif msgcontains(msg, 'gfb') then buytype(cid,msg,2304,3,150,60) elseif msgcontains(msg, 'explosion') then buytype(cid,msg,2313,3,150,80) elseif msgcontains(msg, 'sd') then buytype(cid,msg,2311,1,150,100) elseif msgcontains(msg, 'blank') then buy(cid,2260,1,5) ---não usa buytype porque não é item de quantidade elseif string.find(msg, '(%a*)bye(%a*)') then selfSay('Good bye, ' .. creatureGetName(cid) .. '!') focus = 0 talk_start = 0 end end end function onCreatureChangeOutfit(creature) end function onThink() end ---------------------------------------------------------- Bom, é só isso...espero que não tenham problemas ainda ;D Falow a todos! OBS: Coloquem no server que vale a pena. Compartilhar este post Link para o post Compartilhar em outros sites
WexXxley 0 #19 Postado 21 Dezembro, 2006 Ae, arrumei os bugs que estavam impedindo o funcionamento do script...lá vai hein: No arquivo: data/npc/scripts/lib/npc.lua Vá até o final do arquivo, pule uma linha do último "end" e cole: function buytype(uid,txt,id,min,max,price) x = string.gsub(txt,"%a","") x = tonumber(x) if x ~= nill and x > min then if x <= max then price = x * price buy(uid,id,x,price) else price = max * price buy(uid,id,max,price) end else buy(uid,id,min,price) end end **************************** Agora, faça esse npc de runas: data/npc/scripts/runes.lua 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 string.len(msg) == 2 and getDistanceToCreature(cid) < 3 then if string.find(msg, '(%a*)hi(%a*)') and focus == 0 and string.len(msg) == 2 then selfSay('Hello ' .. creatureGetName(cid) .. '! I sell runes.') focus = cid talk_start = os.clock() elseif focus == cid then talk_start = os.clock() if msgcontains(msg, 'runes') then selfSay('I sell hmm(40gps), uh(90gps), gfb(60gps), explosion(80gps), sd(100gps) and blank runes(5gps).') elseif msgcontains(msg, 'hmm') then buytype(cid,msg,2311,5,150,40) elseif msgcontains(msg, 'uh') then buytype(cid,msg,2273,1,150,90) elseif msgcontains(msg, 'gfb') then buytype(cid,msg,2304,3,150,60) elseif msgcontains(msg, 'explosion') then buytype(cid,msg,2313,3,150,80) elseif msgcontains(msg, 'sd') then buytype(cid,msg,2311,1,150,100) elseif msgcontains(msg, 'blank') then buy(cid,2260,1,5) ---não usa buytype porque não é item de quantidade elseif string.find(msg, '(%a*)bye(%a*)') then selfSay('Good bye, ' .. creatureGetName(cid) .. '!') focus = 0 talk_start = 0 end end end function onCreatureChangeOutfit(creature) end function onThink() end ---------------------------------------------------------- Bom, é só isso...espero que não tenham problemas ainda ;D Falow a todos! OBS: Coloquem no server que vale a pena. Compartilhar este post Link para o post Compartilhar em outros sites
Arcannos 0 #20 Postado 22 Dezembro, 2006 Aprovo e vou usar. vou tentar fazer a funçao "Selltype" baseada nessa ai do colex Compartilhar este post Link para o post Compartilhar em outros sites