Ir para conteúdo
Entre para seguir isso  
tibiaa4e

Banker SQL para TFS 0.3.0 Alpha 4+

Recommended Posts

tibiaa4e    0
tibiaa4e

-------------------------------

Nome: Npc Banker

Versão: 8.31+

Tipo do script: NPC

Servidor Testado: The Forgotten Server 0.3.0 Alpha 4 e Beta 2

Autor: ta4e

-------------------------------

 

FIz esse npc pq n vi nenhuma que funcionasse com o novo Jiddo System

 

Acho que só funciona em The forgotten server, o resto é lixo, portanto não fará diferença

 

 

Ele faz deposit,withdraw e transfer sem bugs nenhum.

 

Para pega-lo crie em npcs

 

bank.xml

<?xml version="1.0" encoding="UTF-8"?>
<npc name="BankMan" script="data/npc/scripts/bank.lua" walkinterval="25" floorchange="0" access="5" >
   <health now="150" max="150"/>
   <look type="132" head="115" body="0" legs="114" feet="0" addons="3" corpse="2212"/>

   <parameters>
       <parameter key="message_greet" value="Hello |PLAYERNAME|. Welcome to my bank, you wanna {deposit}, {withdraw} or {transfer}."/>
       <parameter key="message_alreadyfocused" value="You are drunked ? I talk with you."/>
       <parameter key="message_farewell" value="Goodbye. I wanna see your money... oh you again."/>
   </parameters>
</npc>

 

 

Em npcs/scripts

 

bank.lua

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

function onCreatureAppear(cid)                npcHandler:onCreatureAppear(cid)            end
function onCreatureDisappear(cid)            npcHandler:onCreatureDisappear(cid)            end
function onCreatureSay(cid, type, msg)            npcHandler:onCreatureSay(cid, type, msg)        end
function onThink()                    npcHandler:onThink()                    end

function creatureSayCallback(cid, type, msg)
   if(not npcHandler:isFocused(cid)) then
       return false
   end

   local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

--------------------MESSAGES------------------------------------------------------------------------------
   if msgcontains(msg, 'deposit') then
       selfSay('Please tell me how much gold it is you would like to deposit.', cid)
       talkState[talkUser] = 1

   elseif msgcontains(msg, 'withdraw') then
       selfSay('Please tell me how much gold you would like to withdraw.', cid)
       talkState[talkUser] = 3

   elseif msgcontains(msg, 'transfer') then
       selfSay('Please tell me the amount of gold coins you would like to transfer.', cid)
       talkState[talkUser] = 5

   elseif msgcontains(msg, 'balance') then
       n = getPlayerBalance(cid)
       selfSay('Your balance are '..n..' golds.', cid)
       talkState[talkUser] = 0


----------------------DEPOSIT-------------------------------------------------------
   elseif talkState[talkUser] == 1 then
       if msgcontains(msg, 'all') then
           n = getPlayerMoney(cid)
           selfSay('Do you want deposit '..n..' golds ?', cid)
           talkState[talkUser] = 2            
       else
           n = getNumber(msg)
           selfSay('Do you want deposit '..n..' golds ?', cid)
           talkState[talkUser] = 2
       end

   elseif talkState[talkUser] == 2 then
       if msgcontains(msg, 'yes') then
           if getPlayerMoney(cid) >= n then
               doPlayerDepositMoney(cid,n)            
               selfSay('a', cid)
               talkState[talkUser] = 0
           else
               selfSay('You don\'t have money.', cid)
           end
       else
               selfSay('Ok then', cid)
       end

----------------------WITHDRAW------------------------------------------------------------------------------------------------------------------------------------    

   elseif talkState[talkUser] == 3 then
       if msgcontains(msg, 'all') then
           n = getPlayerBalance(cid)
           selfSay('Do you want withdraw '..n..' golds ?', cid)
           talkState[talkUser] = 4            
       else
           n = getNumber(msg)
           selfSay('Do you want withdraw '..n..' golds ?', cid)
           talkState[talkUser] = 4
       end

   elseif talkState[talkUser] == 4 then
       if msgcontains(msg, 'yes') then
           if getPlayerBalance(cid) >= n then
               doPlayerWithdrawMoney(cid, n)        
               selfSay('Here you are, '..n..' gold. Now your balance account is ' ..getPlayerBalance(cid)..' golds.', cid)
               talkState[talkUser] = 0
           else
               selfSay('There is not enough gold on your account', cid)
           end
       else
               selfSay('Ok then', cid)
       end

----------------------TRANSFER----------------------------------------------------------------------------------------        

   elseif talkState[talkUser] == 5 then
       if msgcontains(msg, 'all') then
           n = getPlayerBalance(cid)
           selfSay('Who would you like transfer '..n..' gold to?', cid)
           talkState[talkUser] = 6            
       else
           n = getNumber(msg)
           selfSay('Who would you like transfer '..n..' gold to?', cid)
           talkState[talkUser] = 6
       end

   elseif talkState[talkUser] == 6 then
       p = msg
       selfSay('So you would like to transfer '..n..' gold to '..p..'?', cid)
       talkState[talkUser] = 7

   elseif talkState[talkUser] == 7 then
       if msgcontains(msg, 'yes') then
           if getPlayerBalance(cid) >= n then
               if doPlayerTransferMoneyTo(cid, p, n) == TRUE then
                   selfSay('You have transferred '..n..' gold to '..p..' and your account balance is '..getPlayerBalance(cid)..' golds.', cid)
                   talkState[talkUser] = 0
               else
               selfSay('This player does not exist. Please tell me a valid name!', cid)
               end
           else
               selfSay('There is not enough gold on your account', cid)
           end
       else
           selfSay('Ok then', cid)
       end


   end
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())



-- function maded by Gesior--
function getNumber(txt) --return number if its number and is > 0, else return 0
x = string.gsub(txt,"%a","")
x = tonumber(x)
if x ~= nill and x > 0 then
return x
else
return 0
end
end

 

Foi feito por mim e se quiser postar em outro forum coloque os creditos

Editado por Mock

Compartilhar este post


Link para o post
Mock    32
Mock

Aprovado

Compartilhar este post


Link para o post
lucashgas    0
lucashgas

Quando inicia o ot não da nenhum problema...

Mas quando vc fala o valor para depositar acontece esse problema no console do ot:

 

Lua Script Error: [Npc interface]

data/npc/scripts/bank.lua:onCreatureSay

 

data/npc/scripts/bank.lua:52: attempt to call global ´doPlayerDepositMoney´<a nstack traceback:

data/npc/scripts/bank.lua:52: in function `callback`

data/npc/lib/npcsysten/npchandler.lua: in function `onCreatureSay`

data/npc/scripts/bank.lua:8: in function <data/npc/scripts/bank.lua:8>

 

o mesmo acontece quando retira ou transfere!

alguém me ajuda?

 

Obrigado

Compartilhar este post


Link para o post
tibiaa4e    0
tibiaa4e

o seu não é 0.3.0 :P

 

por isso da isso ai

 

Não tem essas funções

Compartilhar este post


Link para o post
Mohamed    0
Mohamed

tem alguns erros de ingles, que eu ja corrigi no meu, mas tirando isso tá ótimo! :D

Compartilhar este post


Link para o post
gamberlay    0
gamberlay

Aqui funciono certinho,mas como eu boto pra ter que pagar a casa com dinheiro do banco???

Compartilhar este post


Link para o post
Entre para seguir isso  
  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

×