Conde Sapo 4 Postado Outubro 8, 2007 Share Postado Outubro 8, 2007 (editado) O inicio deste meu tutorial era assim : nosso amiguinho BlackHero fez tutorial de NPC Banqueiro.infelismente o NPC dele usava comandos que gerava erro na maioria dos servers (mesmo os 8.0) Descobri que esse NPC é do COLEXDescula COLEX por dar créditos errados. COLEX <-- Vejam quem é COLEX ---------------------------------------------------------------------------------------------------------------------------------- Exclusivo para XTibia favor não postar em outro forum ---------------------------------------------------------------------------------------------------------------------------------- Vai ae um NPC Banqueiro que não usa comandos especiais. data\npc\scripts\Palmares.lua local focus = 0 local talk_start = 0 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 (msgcontains(msg, 'hi') and focus == 0) and getDistanceToCreature(cid) < 4 then selfSay('Hello ' .. creatureGetName(cid) .. '! wellcome to OT Bank System.') 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 if msgcontains(msg, 'balance') then balance(cid) talk_state = 0 talk_start = os.clock() elseif msgcontains(msg, 'deposit') and getCount(msg) > 0 then value = getCount(msg) selfSay('Would you really like to deposit '..value..' gold?') talk_state = 2 talk_start = os.clock() elseif msgcontains(msg, 'deposit') then selfSay('Please tell me how much gold it is you would like to deposit.') talk_state = 1 talk_start = os.clock() elseif talk_state == 1 then value = getCount(msg) if value > 0 then selfSay('Would you really like to deposit '..value..' gold?') talk_state = 2 else talk_state = 0 end elseif msgcontains(msg, 'yes') and talk_state == 2 then deposit(cid, value) talk_state = 0 elseif msgcontains(msg, 'transfer') and getCount(msg) > 0 then value = getCount(msg) selfSay('What Player NAME you want to Transfer '..value..' gold?') talk_state = 5 talk_start = os.clock() elseif talk_state == 5 then xid = getPlayerByName(msg) if xid == 0 then selfSay('Player "'..msg..'" not found!!!') talk_state = 0 elseif xid == cid then selfSay('You canot transfer money to yourself!!!') talk_state = 0 else NomeDele = getPlayerName(xid) selfSay('Are you sure you wish to transfer '..value..' gold from your bank to '..NomeDele..' bank?') talk_state = 8 end elseif msgcontains(msg, 'transfer') then selfSay('Please tell me how much gold you would like to transfer?') talk_state = 7 talk_start = os.clock() elseif talk_state == 7 then value = getCount(msg) if value > 0 then selfSay('What Player NAME you want to Transfer '..value..' gold?') talk_state = 5 talk_start = os.clock() else talk_state = 0 end elseif msgcontains(msg, 'yes') and talk_state == 8 then transfer(cid, value, xid) talk_state = 0 elseif msgcontains(msg, 'withdraw') and getCount(msg) > 0 then value = getCount(msg) selfSay('Are you sure you wish to withdraw '..value..' gold from your bank account?') talk_state = 3 talk_start = os.clock() elseif msgcontains(msg, 'withdraw') then talk_state = 4 selfSay('Please tell me how much gold you would like to withdraw.') talk_start = os.clock() elseif talk_state == 4 then value = getCount(msg) if value > 0 then selfSay('Are you sure you wish to withdraw '..value..' gold from your bank account?') talk_state = 3 else talk_state = 0 end elseif msgcontains(msg, 'yes') and talk_state == 3 then withdraw(cid, value) talk_state = 0 elseif msgcontains(msg, 'no') and talk_state == 2 then selfSay('As you wish. Is there something else I can do for you?') talk_state = 0 elseif msgcontains(msg, 'no') and talk_state == 3 then selfSay('The customer is king! Come back anytime you want to if you wish to withdraw your money.') talk_state = 0 elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then selfSay('Bye bye ' .. creatureGetName(cid) .. ', come back anytime you want talk about money.') focus = 0 talk_start = 0 elseif msg ~= "" then selfSay('You are in a Bank! Talk about Bank thinks.') talk_state = 0 end end end function onCreatureChangeOutfit(creature) end function onThink() doNpcSetCreatureFocus(focus) if (os.clock() - talk_start) > 30 then if focus > 0 then selfSay('Next money owner Please...') end focus = 0 talk_start = 0 end if focus ~= 0 then if getDistanceToCreature(focus) > 5 then selfSay('Good bye then. Good talk with you about money.') focus = 0 talk_start = 0 end end end Palmares é um amiguinho que pediu pra acertar este NPC Em sua homenagem fiz com o nome dele. Agora precisa a identificação do NPC data\npc\Palmares.xml <npc name="Palmares" script="data/npc/scripts/Banco.lua" access="3" lookdir="1" autowalk="200" speed="200"> <health now="100" max="100"/> <look type="134" head="57" body="59" legs="40" feet="76" corpse="2212"/> <parameters/> </npc> Este NPC usa funções pré-estabelecidas que ficam no arquivo data\npc\scripts\lib\npc.lua -- Funçoes de BANCO function getCount(msg) b, e = string.find(msg, "%d+") if b == nil or e == nil then count = 1 else count = tonumber(string.sub(msg, b, e)) end if count > 100000 then count = 100000 elseif count == 0 then count = 1 end return count end function balance(cid) local storage = 666 local value = getPlayerStorageValue(cid, storage) if value > 0 then selfSay('Your account balance is '..value..' gold.') else setPlayerStorageValue(cid, storage, 0) selfSay('You don\'t have money in your bank account.') end end function withdraw(cid, value) local storage = 666 local balance = getPlayerStorageValue(cid, storage) if balance == -1 then -- Não tinha depositos ainda -> Iniciar com 0 setPlayerStorageValue(cid, storage, 0) end if value <= 0 then selfSay('You cannot withdraw invalid values.') elseif balance < value then selfSay('There is not enough gold on your account.') else selfSay('Here you are, '..value..' gold. Please let me know if there is something else I can do for you.') setPlayerStorageValue(cid, storage, balance-value) doPlayerAddMoney(cid,value) end end function deposit(cid, value) local storage = 666 local balance = getPlayerStorageValue(cid, storage) if balance == -1 then -- Não tinha depositos ainda -> Iniciar com 0 setPlayerStorageValue(cid, storage, 0) end if value < 0 then selfSay('You cannot deposit negative values.') elseif doPlayerRemoveMoney(cid,value) == TRUE then selfSay('Alright, we have added the amount of '..value..' gold to your balance. You can withdraw your money anytime you want to.') setPlayerStorageValue(cid, storage, balance + value) else selfSay('You do not have enough gold.') end end function transfer(cid, value, xid) local storage = 666 local balanceEu = getPlayerStorageValue(cid, storage) local balanceEle = getPlayerStorageValue(xid, storage) if value <= 0 then selfSay('You cannot transfer illegal values.') elseif balanceEu >= value then setPlayerStorageValue(cid, storage, balanceEu - value) setPlayerStorageValue(xid, storage, balanceEle + value) selfSay('Alright, we have transfered the amount of '..value..' gold from your balance to '..NomeDele..' balance.') doPlayerSendTextMessage(xid,4,'OT Bank System : '..getPlayerName(cid)..' transfered the amount of '..value..' gold to your balance.') selfSay(getPlayerName(xid)..' received confirmation about transfer.') else selfSay('You do not have enough gold.') end end function doPlayerGetMoney(cid) local gold = getPlayerItemCount(cid,2148) local platinum = getPlayerItemCount(cid,2152) local crystal = getPlayerItemCount(cid,2160) local total = gold + (platinum*100) + (crystal*10000) return total end Caso não tenha , incluir no FIM do arquivo. A grana fica guardada no Storage 666 Caso esse número já esteja sendo usado , substituir. UpDates Acharam um erro que foge à minha compreensão Numa parte que nem é minha. Eu só usei um recurso que JÁ VEM NO SERVER Aqui : data\npc\scripts\lib\npc.lua <--- Já vem pronto no server Estava assim : elseif doPlayerRemoveMoney(cid,value) then Troquei por : elseif doPlayerRemoveMoney(cid,value) == TRUE then Não entendi porque esse erro, mas o player depositava grana mesmo sem ter o valor. TRANSFER Função TRANSFER adicionada sem os comandos de IO-OPEN só posso fazer TRANSFER pra player on-line o player que ganhou esse TRANFER recebe a mensagem que houve uma transferência da grana para a conta dele. Editado Janeiro 18, 2008 por Conde Sapo Link para o comentário https://xtibia.com/forum/topic/65174-npc-banqueiro-agora-com-transfer/ Compartilhar em outros sites More sharing options...
SephyrotSin 0 Postado Outubro 8, 2007 Share Postado Outubro 8, 2007 Não tenho nada pra dizer além de: Muito BOM... Não... "Muito BOM" não... ÓTIMO tutorial!! Link para o comentário https://xtibia.com/forum/topic/65174-npc-banqueiro-agora-com-transfer/#findComment-399509 Compartilhar em outros sites More sharing options...
thayam 0 Postado Outubro 8, 2007 Share Postado Outubro 8, 2007 Assino em Baxo Nero Ta muito bom aleluia um que funcione certinho, Conde vc é o cara mano Na minha opnião vc merece um cargo maior nesse forum, pois vc ajuda e manja muito Aprovado Parabens Link para o comentário https://xtibia.com/forum/topic/65174-npc-banqueiro-agora-com-transfer/#findComment-399605 Compartilhar em outros sites More sharing options...
Conde Sapo 4 Postado Outubro 9, 2007 Autor Share Postado Outubro 9, 2007 (editado) Na minha opnião vc merece um cargo maior nesse forum,AhuheUahuE Brigadúúúú pelo carinho. Quem tem cargo , tem que manter a postura. Sem cargo eu posso falar mal dos outros. Prefiro poder falar mal dos outros. Aewwwwwwww. Falei isto em outro tópico Tenho dó dos moderadores que veem coisas assim todos os diasmas tem que manter a postura. Não quero levar esta Cruz. É muito pesada......... Editado Outubro 9, 2007 por Conde Sapo Link para o comentário https://xtibia.com/forum/topic/65174-npc-banqueiro-agora-com-transfer/#findComment-399757 Compartilhar em outros sites More sharing options...
thayam 0 Postado Outubro 9, 2007 Share Postado Outubro 9, 2007 AhuheUahuE Brigadúúúú pelo carinho. Quem tem cargo , tem que manter a postura. Sem cargo eu posso falar mal dos outros. Prefiro poder falar mal dos outros. SHAUShuaHSuh. Poder Falar mal dos outros é bom sim, concordo plenamente com vc. Mais vai falar que vc não gostaria dum cargo maior?? xP Abraços ae Link para o comentário https://xtibia.com/forum/topic/65174-npc-banqueiro-agora-com-transfer/#findComment-399761 Compartilhar em outros sites More sharing options...
GODFakezin 1 Postado Outubro 9, 2007 Share Postado Outubro 9, 2007 (editado) BOM! Outros Npc's desses que eu vi em outros tutoriais. sempre com algum defeito! Agora ele foi reformado com sucesso! Cya. Anteciosamente: GoD Fakezin Editado Outubro 9, 2007 por GODFakezin Link para o comentário https://xtibia.com/forum/topic/65174-npc-banqueiro-agora-com-transfer/#findComment-399821 Compartilhar em outros sites More sharing options...
spot123123 0 Postado Outubro 9, 2007 Share Postado Outubro 9, 2007 Testei Aki Funciono Tudo certinho Cya~~ Link para o comentário https://xtibia.com/forum/topic/65174-npc-banqueiro-agora-com-transfer/#findComment-399853 Compartilhar em outros sites More sharing options...
BlackHero 0 Postado Outubro 10, 2007 Share Postado Outubro 10, 2007 (editado) Parabéns Conde Sapo, depois eu tentei fazer sem as funções <io>, mais não consegui e fiquei pouco tempo no pc Mas parabéns, vai ajudar muita gente que não conseguiu colocar em seu ot. Por mim: APROVADISSÍMO Abraços. Editado Outubro 10, 2007 por BlackHero Link para o comentário https://xtibia.com/forum/topic/65174-npc-banqueiro-agora-com-transfer/#findComment-400525 Compartilhar em outros sites More sharing options...
Jvchequer 63 Postado Outubro 14, 2007 Share Postado Outubro 14, 2007 Olá Xtibiano, Parabéns, o tópico está ótimo. Mais está na seção errada. Tópico Movido. Atenciosamente, JV Chequer *Diretor de Fórum Xtibia.com* Link para o comentário https://xtibia.com/forum/topic/65174-npc-banqueiro-agora-com-transfer/#findComment-403202 Compartilhar em outros sites More sharing options...
danilo9317 3 Postado Outubro 26, 2007 Share Postado Outubro 26, 2007 Ja vou colocar no meu Ot =] Link para o comentário https://xtibia.com/forum/topic/65174-npc-banqueiro-agora-com-transfer/#findComment-411551 Compartilhar em outros sites More sharing options...
danilo9317 3 Postado Outubro 27, 2007 Share Postado Outubro 27, 2007 Cara Tipo aki no meu ot quando a pessoa n tem o dinheiro pra depositar ele deposita do mesmo jeito oO como arrumo? Link para o comentário https://xtibia.com/forum/topic/65174-npc-banqueiro-agora-com-transfer/#findComment-412094 Compartilhar em outros sites More sharing options...
Conde Sapo 4 Postado Outubro 27, 2007 Autor Share Postado Outubro 27, 2007 (editado) Cara Tipo aki no meu ot quando a pessoa n tem o dinheiro pra depositar ele deposita do mesmo jeito oO como arrumo?Tem um erro que foge a minha compreensão... é numa parte que JÁ VEM NO SERVER Não é minha... só aproveitei um recurso que já existia. Neste lugar aqui : data\npc\scripts\lib\npc.lua Esse arquivo é do SERVER. No lugar disto : elseif doPlayerRemoveMoney(cid,value) then Colocar isto : elseif doPlayerRemoveMoney(cid,value) == TRUE then Já acertei no tutorial. Vlw pela dica. Mandei PM pra todos que responderam neste tutorial Quem pegou o banqueiro e nem falou nada , talvez esteja com o BUG ainda. Cópia da mensagem enviada : Estou enviando esta mensagem a TODOS que responderam no meu tutorial do NPC Banqueiro Npc Banqueiro, sem IO.Open <-- Clicar Acharam um erro que foge à minha compreensão Acertei lá Desculpa se causei algum dano em seu SERVER [ ]s Editado Janeiro 18, 2008 por Conde Sapo Link para o comentário https://xtibia.com/forum/topic/65174-npc-banqueiro-agora-com-transfer/#findComment-412132 Compartilhar em outros sites More sharing options...
4291226 0 Postado Novembro 4, 2007 Share Postado Novembro 4, 2007 Alguns Npc Seus Vem com a Seguinte Funçao Se Posso chamar assim: local keywordHandler = KeywordHandler:new()local npcHandler = NpcHandler:new(keywordHandler) Essas Coisa Dao erro no meu Ot .. Help Me :_ Link para o comentário https://xtibia.com/forum/topic/65174-npc-banqueiro-agora-com-transfer/#findComment-417822 Compartilhar em outros sites More sharing options...
Felipe Moraes 151 Postado Novembro 10, 2007 Share Postado Novembro 10, 2007 bem legal rapaz... realmente, mtus npcs banqueiros dao algum bug... parabens ae Link para o comentário https://xtibia.com/forum/topic/65174-npc-banqueiro-agora-com-transfer/#findComment-420117 Compartilhar em outros sites More sharing options...
Conde Sapo 4 Postado Novembro 13, 2007 Autor Share Postado Novembro 13, 2007 local keywordHandler = KeywordHandler:new()local npcHandler = NpcHandler:new(keywordHandler) Essas Coisa Dao erro no meu Ot .. São comandos do sistema JIDDO de NPCs Se você não tem JIDDO não vai funcionar. -- This file is part of Jiddo's advanced NpcSystem v3.0x. This npcsystem is free to use by anyone, for any purpuse. -- Initial release date: 2007-02-21 -- Credits: Jiddo, honux(I'm using a modified version of his Find function). -- Please include full credits whereever you use this system, or parts of it. -- For support, questions and updates, please consult the following thread: -- http://otfans.net/showthread.php?t=67810 Boa Sorte :smile_positivo: Link para o comentário https://xtibia.com/forum/topic/65174-npc-banqueiro-agora-com-transfer/#findComment-421519 Compartilhar em outros sites More sharing options...
Posts Recomendados