Ir para conteúdo

colex

Visconde
  • Total de itens

    301
  • Registro em

  • Última visita

Tudo que colex postou

  1. @soulblaster ele ta a dar erro numa função do próprio LUA, tenta noutra versão e ve se o erro continua. eu testei aqui outra vez pra ver se da esse erro, mas não da
  2. UPDATE chegou, agora com o sistema de transfer como o soulblaster havia pedido. não se esqueçam de criar a pasta bank dentro da pasta data caso contrário o NPC não funcionará nota: como foi dito no tópico, daqui a pouco eu edito com o sistema transfer funcionando em servidores SQL (não vai ficar tão bom como em servidores XML) Atenciosamente, Colex
  3. @soulblaster eu ja tava trabalhando nisso e vou aproveitar e ja acrescentar outras coisas. Abraços, Colex
  4. @soulblaster nill funcionou na mesma por isso acho que nem vale a pena mudar se ficou correto mas mostar que voce leu o code Abraços, Colex
  5. em 7.6 pega com certeza, alias eu fiz esse NPC numa versão de ot 7.6 se voce for ver os IDs são 7.6 abraços, Colex
  6. Obrigado pro dar a opinião. depois eu baixo essa versão e arrumo para funcionar nele tambem Abraços, Colex
  7. Olá, Este NPC foi feito pro mim, tentei fazer igual ao do Tibia e este foi o resultado, espero que gostem! As Funções deste NPC são: - Deposit (depositar dinheiro) - Withdraw (retirar dinheiro) - Balance (ver quanto dinheiro tem na conta) -TRANSFER (transferir dinheiro entre players) <-- UPDATE No "withdraw" o NPC da ao jogador crystal, platinum e gold quando necssário 10110 <- neste exemplo o NPC daria 1 crystal, 1 platinum e 10 gold Aqui esta o script: ---------NPC Banker by Colex-----------focus = 0talk_start = 0target = 0dep = 0wit = 0trans = 0following = falseattacking = false--ALTERE DE ACORDO COM A SUA VERSÃO-----IDs----gold_id = 2148plat_id = 2152crys_id = 2160function 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) nome = creatureGetName(cid)--------------------------------------Begin---------------------------------------------- if (msgcontains(msg, 'hi') or msgcontains(msg, 'hello')) and (focus == 0) and getDistanceToCreature(cid) < 4 then if io.open("data/bank/"..nome..".dat", "r") then io.close(); else newAccount(nome) end dep = 0 wit = 0 trans = 0 selfSay('Hello ' .. nome .. '! Well come to the local bank, what do you want to do? here you can access your bank account saying (deposit, withdraw, balance, transfer).') 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.') end--------------------------------------Deposit---------------------------------------------- if dep == 0 then if (msgcontains(msg, 'deposit')) and (focus == cid) and getDistanceToCreature(cid) < 4 then selfSay('How much do you wish to deposit?') dep = 1 wit = 0 trans = 0 talk_start = os.clock() end end if dep == 1 then if (focus == cid) and getDistanceToCreature(cid) < 4 then n = getNumber(msg) if n ~= 0 then talk_start = os.clock() selfSay('Do you really want to deposit '..n..' gold pieces?') dep = 2 end end end if dep == 2 and (focus == cid) and getDistanceToCreature(cid) < 4 then if (msgcontains(msg, 'yes')) then dep = 0 talk_start = os.clock() if pay(cid,n) then addMoney(nome,n) selfSay('Deposit Succesful!') else selfSay('Sorry, you dont have enought money!') end end if (msgcontains(msg, 'no')) then selfSay('Ok then.') dep = 0 talk_start = os.clock() end end-------------------------------------------Withdraw--------------------------------------- if wit == 0 then if (msgcontains(msg, 'withdraw')) and (focus == cid) and getDistanceToCreature(cid) < 4 then selfSay('How much do you wish to withdraw?') dep = 0 trans = 0 wit = 1 talk_start = os.clock() end end if wit == 1 then if (focus == cid) and getDistanceToCreature(cid) < 4 then n = getNumber(msg) if n ~= 0 then talk_start = os.clock() selfSay('Do you really want to withdraw '..n..' gold pieces?') wit = 2 end end end if wit == 2 and (focus == cid) and getDistanceToCreature(cid) < 4 then if (msgcontains(msg, 'yes')) then wit = 0 talk_start = os.clock() if n <= getMoney(nome) then takeMoney(nome,n) gold = n plat = 0 crys = {} crys[1] = 0 i = 1 repeat if gold >= 100 then plat = plat + 1 gold = gold - 100 end until gold < 100 repeat if plat >= 100 then if crys[i] == 100 then i = i + 1 crys[i] = 0 end crys[i] = crys[i] + 1 plat = plat - 100 end until plat < 100 if crys[1] > 0 then repeat buy(cid,crys_id,crys[i],0) i = i-1 until i == 0 end if plat > 0 then buy(cid,plat_id,plat,0) end if gold > 0 then buy(cid,gold_id,gold,0) end selfSay('withdraw successful!') else selfSay('Sorry, you dont have enought money in your account!') end end if (msgcontains(msg, 'no')) then selfSay('Ok then.') dep = 0 talk_start = os.clock() end end-------------------------------------------Balance--------------------------------------- if (msgcontains(msg, 'balance')) and (focus == cid) and getDistanceToCreature(cid) < 4 then selfSay('You have got '..getMoney(nome)..' gold pieces in your bank account.') dep = 0 wit = 0 trans = 0 talk_start = os.clock() end-------------------------------------------Transfer--------------------------------------- if trans == 4 and (focus == cid) and getDistanceToCreature(cid) < 4 then if io.open("data/bank/"..rec..".dat", "r") then io.close(); else newAccount(rec) end if (msgcontains(msg, 'yes')) then Transfer(nome,rec,quant) selfSay('The money was successfuly transfered!') trans = 0 talk_start = os.clock() elseif (msgcontains(msg, 'no')) then selfSay('Ok then!') trans = 0 talk_start = os.clock() end end if trans == 3 and (focus == cid) and getDistanceToCreature(cid) < 4 then if io.open("data/players/"..msg..".xml", "r") then io.close(); rec = msg selfSay('Do you want to transfer '..quant..' gps to '..rec..'?') trans = 4 talk_start = os.clock() else selfSay('This name does not exist!') trans = 0 talk_start = os.clock() end end if trans == 2 and (focus == cid) and getDistanceToCreature(cid) < 4 then if (msgcontains(msg, 'yes')) then if getMoney(nome) >= quant then selfSay('Who do you want to trasnfer the money to?') trans = 3 talk_start = os.clock() else selfSay('Sorry, you do not have enough money!') trans = 0 talk_start = os.clock() end elseif (msgcontains(msg, 'no')) then selfSay('Ok then!') talk_start = os.clock() trans = 0 end end if trans == 1 and (focus == cid) and getDistanceToCreature(cid) < 4 then quant = getNumber(msg) if quant > 0 then selfSay('Do you really want to transfer '..quant..' gold pieces?') trans = 2 talk_start = os.clock() end end if trans == 0 then if (msgcontains(msg, 'transfer')) and (focus == cid) and getDistanceToCreature(cid) < 4 then selfSay('How much do you want to transfer?') dep = 0 wit = 0 trans = 1 talk_start = os.clock() end end-------------------------------------------End-------------------------------------------- if (msgcontains(msg, 'bye')) and (focus == cid) and getDistanceToCreature(cid) < 4 then selfSay('Have a nice day Sir!') focus = 0 dep = 0 wit = 0 trans = 0 endendfunction onCreatureChangeOutfit(creature)endfunction onThink() if (os.clock() - talk_start) > 30 then if focus > 0 then selfSay('Next Please...') end focus = 0 dep = 0 wit = 0 trans = 0 end if focus ~= 0 then if getDistanceToCreature(focus) > 5 then selfSay('Good bye then.') focus = 0 dep = 0 wit = 0 trans = 0 end endendfunction getNumber(txt)x = string.gsub(txt,"%a","")x = tonumber(x)if x ~= nill and x > 0 thenreturn xelsereturn 0endendfunction getMoney(name)file = io.open("data/bank/"..name..".dat", "r")x = file:read("*number")file:close()return xendfunction newAccount(name)file = io.open("data/bank/"..name..".dat", "w")file:write("0")file:close()return 1endfunction addMoney(name,money)file = io.open("data/bank/"..name..".dat", "r")x = file:read("*number")x = x + moneyfile:close()file = io.open("data/bank/"..name..".dat", "w")file:write(x)file:close()return 1endfunction takeMoney(name,money)file = io.open("data/bank/"..name..".dat", "r")x = file:read("*number")x = x - moneyfile:close()file = io.open("data/bank/"..name..".dat", "w")file:write(x)file:close()return 1endfunction Transfer(name1,name2,money)takeMoney(name1,money)addMoney(name2,money)return 1end ----------Novo update lançado-------- Agora o NPC tem sistema de transferencia de dinheiro entre players necessário a criação de uma pasta com nome "bank" dentro da pasta "data" ficando "data\bank" o sistema de transferencia poderá não funcionar bem em servidores SQL então daqui a pouco eu edito e coloco para download uma versão para servidores SQL. #bugfix no withdraw -- obrigado por me avisar GM Dudu Aproveitem o NPC mas não tirem os creditos Atenciosamente, Colex
  8. é um metodo legal e bem pensado. Lembrando que não é uma action este não é o local apropriado! mas obrigado por ter trazido esse metódo para ca. Movido para a seção de tutoriais
  9. Fui eu que criei sim, se voce viu em algum fórum sem créditos avisa =P
  10. Não se deve falar nada sem ter 100% de certeza o script é 100% meu sim pelas seguintes razões: 1º quando eu fiz esta rune não existia neverland com esse comando 2º OMG!!! Actions não usa as funções utilizadas em um code feito nas sources por C++ (falar /tp é feito pelas sources caso voce não saiba) 3º Não vou dizer com toda certeza, mas provavelmente esse /TP não faz a mesma coisa que esta rune Espero que não se repita "acusações" desse tipo Atenciosamente, Colex
  11. Por actions essa é a unica maneira mas mesmu andando por use, é facil de andar
  12. desculpa, mas voce não deve ter lido o script porque um bom mapper faz houses e dp em PZ e não da para usar a rune em PZ mas é inutil sim, mas não pelos motivos mencionados
  13. o exhaust é para actions, é separado do exhaust das spells, como o exhaust de ataque é separado dos exhaust de heal nas spells. as actions podem ou não podem (dependendo do utilizador) alterar o exhaust de outras actions. Mas é tudo entre actions. Lembrando, que um exhaust independente do exhaust, é sempre um exhaust verdadeiro. Abraços, Colex
  14. @Smaug voce não é obrigado a gostar de nenhum trabalho meu ou de qualquer outra pessoa, mas para ser usuário do fórum voce tem que respeitar enumeradas regras. Uma dessa regras diz que é proibido fazer flood, ou seja voce não pode fazer posts sem nexo ou de akguma forma inuteis. Outra regra é não ser mal-educado com outros membros do fórum. Leia as regras antes de postar e não cometa os mesmos erros duas vezes, espero que voce venha a ter um bom desenvolvimento nesta comunidade. Atenciosamente, Alexandre Santos
  15. Realmente ja tinha visto uma tipo essa num Test Server a uns 4 meses atraz, tambem não acho que tenha sidu a primeira a ser criada. mas ta bem legal. bom trabalho! Abraços, Colex
  16. eu não disse que não pdoeria ser usado em mana rune, eu disse que este script não é uma mana rune
  17. Gostei muito. Foi bom da tua parte ter liberado o code. Para mim voce é o melhor php programmer do XTibia. bom trabalho. Abraços, Colex
  18. ficou muito bom o resultado gostei do code
  19. serve em qualquer versão com a função buy() normalmente os 7.8 tem
  20. Da em qualquer uma, é só trocar os IDs mas ai eu estou usando os ids de 7.6
  21. Olá, venho postar uma função elaborada por mim que serve para vender items de quantidade mais facilmente. a função é a seguinte: buytype(uid,txt,id,min,max,price) uid - variavel do player, normalmente é cid txt - variavel das falas do player, normalmente é msg id - id do item que quer vender (função feita para items de quantidade) min - a quantidade minima que se pode comprar de tal item max - a quantidade maxima que se pode comprar de tal item price - preço por cada quantidade Exemplo: (vendendo hmm por 40gps cada tiro sendo o maximo que se pode comprar 255 e o minimo 5) buytype(cid,msg,2311,5,255,50) Exemplo de uma conversa entre o player e o NPC: player: Hi NPC: Hi, I sell runes and arrows! player: 15775 hmm (se o maximo for hmm de 100x, ele só recebe de 100x) NPC: Here you are. player: abc50 uh (o player irá comprar uma uh de 50x) NPC: Here you are. player: arrow (não colocou nenhum numero, então irá receber o minimo, neste caso poderia ser uma arrow) NPC: Here you are Agora vamos ao que interessa, 1º na pasta data\npc\scripts\lib abra o arquivo npc.lua e adicione o seguinte code no final: -------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 then if x <= max then price = x * price buy(uid,id,x,price) else price = max * price buy(uid,id,max,price) endelse buy(uid,id,min,price)endend Agora vou dar um exemplo de um NPC que vende runes, o maximo de cargas que ele vende em cada rune é de 150 e o minimo variado por cada rune: 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 phrase if 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 end endendfunction onCreatureChangeOutfit(creature)endfunction onThink() end Isto é só um exemplo para mostrar como usar a função! Alguma dúvida? encontrou algum bug? deixe aqui sua mensagem! Atenciosamente, Colex
  22. @gibin esta explicado na própria action é só mudar o valor da variavel time
  23. @Lucaspfa eu postei um sistema de exhausted, pequeno e facil de usar: http://www.xtibia.com/forum/index.php?showtopic=19317 LMAO, quando não sabe acha muito bom, quando aprende ja é um lixo (sem comentários parece que ficou vergonha de comentar num tópico de tutorial) xD
  24. voce tem que adicionar no Spells.xml, é só voce copiar o exemplo de outra magia e fazer para essa! nota: não faz "Citar" no tópico para responder, senão a msg fica muito grande Abraços, Cooler
  25. eu fiz ela no 7.6, nunca testei em 7.8 para ver se tem alguma diferença nas spells, então se esse server é 7.8 pode não funcionar.
  • Quem Está Navegando   0 membros estão online

    • Nenhum usuário registrado visualizando esta página.
×
×
  • Criar Novo...