Ir para conteúdo
  • Cadastre-se

(Resolvido)[PEDIDO] - NPC Bank


Ir para solução Resolvido por Danihcv,

Posts Recomendados

Estou usando o seguinte script abaixo pro NPC bank, porém ele não funciona na parte deposita all e transfery, se alguém conseguir corrigir isso. Ou fazer um simples que apenas deposit all e deposit x quantia, withdraw, balance

 

http://www.tibiaking.com/forum/topic/11454-npc-bank-igual-tibia-global/

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, 'change gold') then
selfSay('How many platinum coins do you want to get?', cid)
talkState[talkUser] = 8

elseif msgcontains(msg, 'change platinum') then
selfSay('Do you want to change your platinum coins to gold or crystal?', cid)
talkState[talkUser] = 10

elseif msgcontains(msg, 'change crystal') then
selfSay('How many crystal coins do you want to change to platinum?', cid)
talkState[talkUser] = 15

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('Sucessfull. Now your balance account is ' ..getPlayerBalance(cid)..' golds.', 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)
talkState[talkUser] = 0
end
else
selfSay('There is not enough gold on your account', cid)
talkState[talkUser] = 0
end
else
selfSay('Ok then', cid)
talkState[talkUser] = 0
end

----------------------CHANGE GOLD---------------------------------------------------------------------------------
elseif talkState[talkUser] == 8 then
n = getNumber(msg)
b = n * 100
selfSay('So I should change '..b..' of your gold coins to '..n..' platinum coins for you?', cid)
talkState[talkUser] = 9

elseif talkState[talkUser] == 9 then
if msgcontains(msg, 'yes') then
if doPlayerRemoveItem(cid, 2148, b) == TRUE then
doPlayerAddItem(cid, 2152, n)
talkState[talkUser] = 0
else
selfSay('You don\'t have money.', cid)
talkState[talkUser] = 0
end
else
selfSay('Ok. We cancel.', cid)
talkState[talkUser] = 0
end

---------------------CHANGE PLATINUM-------------------------------------------------------------------------
elseif talkState[talkUser] == 10 then
if msgcontains(msg, 'gold') then
selfSay('How many platinum coins do you want to change to gold?', cid)
talkState[talkUser] = 11
elseif msgcontains(msg, 'crystal') then
selfSay('How many crystal coins do you want to get?', cid)
talkState[talkUser] = 13
end


elseif talkState[talkUser] == 11 then
n = getNumber(msg)
b = n * 100
selfSay('So I should change '..n..' of your platinum coins to '..b..' gold coins for you?', cid)
talkState[talkUser] = 12

elseif talkState[talkUser] == 12 then
if msgcontains(msg, 'yes') then
if doPlayerRemoveItem(cid, 2152, n) == TRUE then
doPlayerAddItem(cid, 2148, b)
talkState[talkUser] = 0
else
selfSay('You don\'t have money.', cid)
talkState[talkUser] = 0
end
else
selfSay('Ok. We cancel.', cid)
talkState[talkUser] = 0
end

elseif talkState[talkUser] == 13 then
n = getNumber(msg)
b = n * 100
selfSay('So I should change '..b..' of your platinum coins to '..n..' crystal coins for you?', cid)
talkState[talkUser] = 14

elseif talkState[talkUser] == 14 then
if msgcontains(msg, 'yes') then
if doPlayerRemoveItem(cid, 2152, b) == TRUE then
doPlayerAddItem(cid, 2160, n)
talkState[talkUser] = 0
else
selfSay('You don\'t have money.', cid)
talkState[talkUser] = 0
end
else
selfSay('Ok. We cancel.', cid)
talkState[talkUser] = 0
end

---------------------CHANGE CRYSTAL-------------------------------------------------------------------------------
elseif talkState[talkUser] == 15 then
n = getNumber(msg)
b = n * 100
selfSay('So I should change '..n..' of your crystal coins to '..b..' platinum coins for you?', cid)
talkState[talkUser] = 16

elseif talkState[talkUser] == 16 then
if msgcontains(msg, 'yes') then
if doPlayerRemoveItem(cid, 2160, n) == TRUE then
doPlayerAddItem(cid, 2152, b)
talkState[talkUser] = 0
else
selfSay('You don\'t have money.', cid)
talkState[talkUser] = 0
end
else
selfSay('Ok. We cancel.', cid)
talkState[talkUser] = 0
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
Editado por jNo (veja o histórico de edições)

(1º) | [8.60] - Galaxy Server - Download

(2º) | [8.60] - Glorious Server - Download

(3º) | [8.60] - Epic Server - Download

Link para o post
Compartilhar em outros sites
  • Solução

Se ngm.te ajudar até hj de noite. Eu vejo o que posso fazer. Mas peço pra que vc me lembre por pm... shuashuas :s

 

@Edit:

Aqui está o script que uso em meu server e que faz tudo certo, sem bug nenhum:

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, 'change gold') then
selfSay('How many platinum coins do you want to get?', cid)
talkState[talkUser] = 8

elseif msgcontains(msg, 'change platinum') then
selfSay('Do you want to change your platinum coins to gold or crystal?', cid)
talkState[talkUser] = 10

elseif msgcontains(msg, 'change crystal') then
selfSay('How many crystal coins do you want to change to platinum?', cid)
talkState[talkUser] = 15

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('Sucessfull. Now your balance account is ' ..getPlayerBalance(cid)..' golds.', 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)
talkState[talkUser] = 0
end
else
selfSay('There is not enough gold on your account', cid)
talkState[talkUser] = 0
end
else
selfSay('Ok then', cid)
talkState[talkUser] = 0
end

----------------------CHANGE GOLD---------------------------------------------------------------------------------
elseif talkState[talkUser] == 8 then
n = getNumber(msg)
b = n * 100
selfSay('So I should change '..b..' of your gold coins to '..n..' platinum coins for you?', cid)
talkState[talkUser] = 9

elseif talkState[talkUser] == 9 then
if msgcontains(msg, 'yes') then
if doPlayerRemoveItem(cid, 2148, b) == TRUE then
doPlayerAddItem(cid, 2152, n)
talkState[talkUser] = 0
else
selfSay('You don\'t have money.', cid)
talkState[talkUser] = 0
end
else
selfSay('Ok. We cancel.', cid)
talkState[talkUser] = 0
end

---------------------CHANGE PLATINUM-------------------------------------------------------------------------
elseif talkState[talkUser] == 10 then
if msgcontains(msg, 'gold') then
selfSay('How many platinum coins do you want to change to gold?', cid)
talkState[talkUser] = 11
elseif msgcontains(msg, 'crystal') then
selfSay('How many crystal coins do you want to get?', cid)
talkState[talkUser] = 13
end


elseif talkState[talkUser] == 11 then
n = getNumber(msg)
b = n * 100
selfSay('So I should change '..n..' of your platinum coins to '..b..' gold coins for you?', cid)
talkState[talkUser] = 12

elseif talkState[talkUser] == 12 then
if msgcontains(msg, 'yes') then
if doPlayerRemoveItem(cid, 2152, n) == TRUE then
doPlayerAddItem(cid, 2148, b)
talkState[talkUser] = 0
else
selfSay('You don\'t have money.', cid)
talkState[talkUser] = 0
end
else
selfSay('Ok. We cancel.', cid)
talkState[talkUser] = 0
end

elseif talkState[talkUser] == 13 then
n = getNumber(msg)
b = n * 100
selfSay('So I should change '..b..' of your platinum coins to '..n..' crystal coins for you?', cid)
talkState[talkUser] = 14

elseif talkState[talkUser] == 14 then
if msgcontains(msg, 'yes') then
if doPlayerRemoveItem(cid, 2152, b) == TRUE then
doPlayerAddItem(cid, 2160, n)
talkState[talkUser] = 0
else
selfSay('You don\'t have money.', cid)
talkState[talkUser] = 0
end
else
selfSay('Ok. We cancel.', cid)
talkState[talkUser] = 0
end

---------------------CHANGE CRYSTAL-------------------------------------------------------------------------------
elseif talkState[talkUser] == 15 then
n = getNumber(msg)
b = n * 100
selfSay('So I should change '..n..' of your crystal coins to '..b..' platinum coins for you?', cid)
talkState[talkUser] = 16

elseif talkState[talkUser] == 16 then
if msgcontains(msg, 'yes') then
if doPlayerRemoveItem(cid, 2160, n) == TRUE then
doPlayerAddItem(cid, 2152, b)
talkState[talkUser] = 0
else
selfSay('You don\'t have money.', cid)
talkState[talkUser] = 0
end
else
selfSay('Ok. We cancel.', cid)
talkState[talkUser] = 0
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

Editado por danihcv (veja o histórico de edições)

Te ajudei?? REP + e ficamos quites... <ahttp://www.tibiaking.com/forum/uploads/emoticons/default_happyy.png' alt=';D'>

Atenciosamente,

Daniel.

Abraços!

Link para o post
Compartilhar em outros sites
O problema do meu é isso, ele não esta reconhecendo que eu tenho dinheiro, e eu tinha 1kk na bp
07:02 [ADMIN] Juliano [20]: deposit all
07:02 Bank Gates: Please tell me how much gold it is you would like to deposit.
07:02 [ADMIN] Juliano [20]: yes
07:02 Bank Gates: Do you want deposit 0 golds ?
07:02 [ADMIN] Juliano [20]: deposit 10000
07:02 Bank Gates: Please tell me how much gold it is you would like to deposit.
07:02 [ADMIN] Juliano [20]: deposit 1000
07:02 Bank Gates: Please tell me how much gold it is you would like to deposit.
07:02 [ADMIN] Juliano [20]: withdraw 500
07:02 Bank Gates: Please tell me how much gold you would like to withdraw.
07:02 [ADMIN] Juliano [20]: withdraw 500
07:02 Bank Gates: Please tell me how much gold you would like to withdraw.
07:02 [ADMIN] Juliano [20]: balance
07:02 Bank Gates: Your balance are 0 golds.
 
Eu testei esse aqui abaixo, ele deposita, só não da withdraw, a transfery nem importa o balance funciona
 
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
local moneyTo = {}
local playerTo = {}

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

local function isValidMoney(money)
    if isNumber(money) == TRUE and money > 0 and money < 999999999 then
        return TRUE
    end
    return FALSE
end

function creatureSayCallback(cid, type, msg)

    if(not npcHandler:isFocused(cid)) then
        return false
    end

    if msgcontains(msg, 'help') or msgcontains(msg, 'offer') then
        selfSay("You can check the {balance} of your bank account, {deposit} money or {withdraw} it. You can also {transfer} money to other characters, provided that they have a vocation.", cid)
        talkState[cid] = 0
-----------------------------------------------------------------
---------------------------- Balance ----------------------------
-----------------------------------------------------------------
    elseif msgcontains(msg, 'balance') or msgcontains(msg, 'Balance') then
        selfSay('Your account balance is '..getPlayerBalance(cid)..' gold.', cid)
        talkState[cid] = 0
-----------------------------------------------------------------
---------------------------- Help -------------------------------
-----------------------------------------------------------------
    elseif msgcontains(msg, 'basic functions') then
        selfSay('You can check the {balance{ of your bank account, Pdeposit{ money or Pwithdraw{ it. You can also {transfer} money to othercharacters, provided that they have a vocation.', cid)
        talkState[cid] = 0
    elseif msgcontains(msg, 'advanced functions') then
        selfSay('Renting a house has never been this easy. Simply make a bid for an auction. We will check immediately if you haveenough money.', cid)
        talkState[cid] = 0
-----------------------------------------------------------------
---------------------------- Deposit ----------------------------
-----------------------------------------------------------------
    elseif msgcontains(msg, 'deposit all') then
        moneyTo[cid] = getPlayerMoney(cid)
        if moneyTo[cid] < 1 then
            selfSay('You don\'t have any money to deposit in you inventory..', cid)
            talkState[cid] = 0
        else
            selfSay('Would you really like to deposit '..moneyTo[cid]..' gold?', cid)
            talkState[cid] = 2
        end
    elseif msgcontains(msg, 'deposit') then
        selfSay("Please tell me how much gold it is you would like to deposit.", cid)
        talkState[cid] = 1
    elseif talkState[cid] == 1 then
        moneyTo[cid] = tonumber(msg)
        if isValidMoney(moneyTo[cid]) == TRUE then
            selfSay('Would you really like to deposit '..moneyTo[cid]..' gold?', cid)
            talkState[cid] = 2
        else
            selfSay('Is isnt valid amount of gold to deposit.', cid)
            talkState[cid] = 0
        end
    elseif talkState[cid] == 2 then
        if msgcontains(msg, 'yes') then
            if doPlayerDepositMoney(cid, moneyTo[cid], 1) ~= TRUE then
                selfSay('You do not have enough gold.', cid)
            else
                selfSay('Alright, we have added the amount of '..moneyTo[cid]..' gold to your balance. You can withdraw your money anytime you want to. Your account balance is ' .. getPlayerBalance(cid) .. '.', cid)
            end
        elseif msgcontains(msg, 'no') then
            selfSay('As you wish. Is there something else I can do for you?', cid)
        end
        talkState[cid] = 0
-----------------------------------------------------------------
---------------------------- Withdraw ---------------------------
-----------------------------------------------------------------
    elseif msgcontains(msg, 'withdraw') then
        selfSay("Please tell me how much gold you would like to withdraw.", cid)
        talkState[cid] = 6
    elseif talkState[cid] == 6 then
        moneyTo[cid] = tonumber(msg)
        if isValidMoney(moneyTo[cid]) == TRUE then
            selfSay('Are you sure you wish to withdraw '..moneyTo[cid]..' gold from your bank account?', cid)
            talkState[cid] = 7
        else
            selfSay('Is isnt valid amount of gold to withdraw.', cid)
            talkState[cid] = 0
        end
    elseif talkState[cid] == 7 then
        if msgcontains(msg, 'yes') then
            if doPlayerWithdrawMoney(cid, moneyTo[cid]) ~= TRUE then
                selfSay('There is not enough gold on your account. Your account balance is '..getPlayerBalance(cid)..'. Please tell me the amount of gold coins you would like to withdraw.', cid)
            else
                selfSay('Here you are, ' .. moneyTo[cid] .. ' gold. Please let me know if there is something else I can do for you.', cid)
                talkState[cid] = 0
            end
        elseif msgcontains(msg, 'no') then
            selfSay('As you wish. Is there something else I can do for you?', cid)
            talkState[cid] = 0
        end
-----------------------------------------------------------------
---------------------------- Transfer ---------------------------
-----------------------------------------------------------------
    elseif msgcontains(msg, 'transfer') then
        selfSay("Please tell me the amount of gold you would like to transfer.", cid)
        talkState[cid] = 11
    elseif talkState[cid] == 11 then
        moneyTo[cid] = tonumber(msg)
        if isValidMoney(moneyTo[cid]) == TRUE then
            selfSay('Who would you like transfer '..moneyTo[cid]..' gold to?', cid)
            talkState[cid] = 12
        else
            selfSay('Is isnt valid amount of gold to transfer.', cid)
            talkState[cid] = 0
        end
    elseif talkState[cid] == 12 then
        playerTo[cid] = msg

        if getCreatureName(cid) == playerTo[cid] then
            selfSay('Ehm, You want transfer money to yourself? Its impossible!', cid)
            talkState[cid] = 0
            return TRUE
        end

        if playerExists(playerTo[cid]) then
            selfSay('So you would like to transfer ' .. moneyTo[cid] .. ' gold to "' .. playerTo[cid] .. '" ?', cid)
            talkState[cid] = 13
        else
            selfSay('Player with name "' .. playerTo[cid] .. '" doesnt exist.', cid)
            talkState[cid] = 0
        end
    elseif talkState[cid] == 13 then
        if msgcontains(msg, 'yes') then
            if getPlayerBalance(cid) < moneyTo[cid] then
                selfSay('You dont have enought money on your bank account.', cid)
                return TRUE
            end

            if doPlayerTransferMoneyTo(cid, playerTo[cid], moneyTo[cid]) ~= TRUE then
                selfSay('This player does not exist on this world or have no vocation.', cid)
            else
                selfSay('You have transferred ' .. moneyTo[cid] .. ' gold to "' .. playerTo[cid] ..' ".', cid)
                playerTo[cid] = nil
            end
        elseif msgcontains(msg, 'no') then
            selfSay('As you wish. Is there something else I can do for you?', cid)
        end
        talkState[cid] = 0
    end
    return TRUE
end

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

Editado por jNo (veja o histórico de edições)

(1º) | [8.60] - Galaxy Server - Download

(2º) | [8.60] - Glorious Server - Download

(3º) | [8.60] - Epic Server - Download

Link para o post
Compartilhar em outros sites

Dá algum erro na distro?

Te ajudei?? REP + e ficamos quites... <ahttp://www.tibiaking.com/forum/uploads/emoticons/default_happyy.png' alt=';D'>

Atenciosamente,

Daniel.

Abraços!

Link para o post
Compartilhar em outros sites

@jNo, eu acabei de ver o seu diálogo com o npc. E não diria que está muito certo... O certo seria:

07:02 [ADMIN] Juliano [20]: deposit
07:02 Bank Gates: Please tell me how much gold it is you would like to deposit.
07:02 [ADMIN] Juliano [20]: all
07:02 Bank Gates: Do you want deposit *aparece quanto gold vc tem* golds ?
07:02 [ADMIN] Juliano [20]: yes
 
Tem que ser uma informação de cada vez, basta ler e interpretar ao pé da letra as falas do npc. ^^
 
Experimente o script que eu mandei.
Editado por danihcv (veja o histórico de edições)

Te ajudei?? REP + e ficamos quites... <ahttp://www.tibiaking.com/forum/uploads/emoticons/default_happyy.png' alt=';D'>

Atenciosamente,

Daniel.

Abraços!

Link para o post
Compartilhar em outros sites

Ah sim, funciono agora, achei que era igual do global kkk :) valeu

(1º) | [8.60] - Galaxy Server - Download

(2º) | [8.60] - Glorious Server - Download

(3º) | [8.60] - Epic Server - Download

Link para o post
Compartilhar em outros sites

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emojis são permitidos.

×   Seu link foi automaticamente incorporado.   Mostrar como link

×   Seu conteúdo anterior foi restaurado.   Limpar o editor

×   Não é possível colar imagens diretamente. Carregar ou inserir imagens do URL.

  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

  • Conteúdo Similar

    • Por Scorpiondaniel
      Quero que o balance do bank do personagem apareça na conta do cara no site

      Script usado:
       
       
       

      NPC BANKMAN
      <?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="Welcome |PLAYERNAME|! Here, you can {deposit}, {withdraw} or {transfer} your money from your bank account. I can change your coins too."/> <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>  
       
       
      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, 'change gold') then selfSay('How many platinum coins do you want to get?', cid) talkState[talkUser] = 8 elseif msgcontains(msg, 'change platinum') then selfSay('Do you want to change your platinum coins to gold or crystal?', cid) talkState[talkUser] = 10 elseif msgcontains(msg, 'change crystal') then selfSay('How many crystal coins do you want to change to platinum?', cid) talkState[talkUser] = 15 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('Sucessfull. Now your balance account is ' ..getPlayerBalance(cid)..' golds.', 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) talkState[talkUser] = 0 end else selfSay('There is not enough gold on your account', cid) talkState[talkUser] = 0 end else selfSay('Ok then', cid) talkState[talkUser] = 0 end ----------------------CHANGE GOLD--------------------------------------------------------------------------------- elseif talkState[talkUser] == 8 then n = getNumber(msg) b = n * 100 selfSay('So I should change '..b..' of your gold coins to '..n..' platinum coins for you?', cid) talkState[talkUser] = 9 elseif talkState[talkUser] == 9 then if msgcontains(msg, 'yes') then if doPlayerRemoveItem(cid, 2148, b) == TRUE then doPlayerAddItem(cid, 2152, n) talkState[talkUser] = 0 else selfSay('You don\'t have money.', cid) talkState[talkUser] = 0 end else selfSay('Ok. We cancel.', cid) talkState[talkUser] = 0 end ---------------------CHANGE PLATINUM------------------------------------------------------------------------- elseif talkState[talkUser] == 10 then if msgcontains(msg, 'gold') then selfSay('How many platinum coins do you want to change to gold?', cid) talkState[talkUser] = 11 elseif msgcontains(msg, 'crystal') then selfSay('How many crystal coins do you want to get?', cid) talkState[talkUser] = 13 end elseif talkState[talkUser] == 11 then n = getNumber(msg) b = n * 100 selfSay('So I should change '..n..' of your platinum coins to '..b..' gold coins for you?', cid) talkState[talkUser] = 12 elseif talkState[talkUser] == 12 then if msgcontains(msg, 'yes') then if doPlayerRemoveItem(cid, 2152, n) == TRUE then doPlayerAddItem(cid, 2148, b) talkState[talkUser] = 0 else selfSay('You don\'t have money.', cid) talkState[talkUser] = 0 end else selfSay('Ok. We cancel.', cid) talkState[talkUser] = 0 end elseif talkState[talkUser] == 13 then n = getNumber(msg) b = n * 100 selfSay('So I should change '..b..' of your platinum coins to '..n..' crystal coins for you?', cid) talkState[talkUser] = 14 elseif talkState[talkUser] == 14 then if msgcontains(msg, 'yes') then if doPlayerRemoveItem(cid, 2152, b) == TRUE then doPlayerAddItem(cid, 2160, n) talkState[talkUser] = 0 else selfSay('You don\'t have money.', cid) talkState[talkUser] = 0 end else selfSay('Ok. We cancel.', cid) talkState[talkUser] = 0 end ---------------------CHANGE CRYSTAL------------------------------------------------------------------------------- elseif talkState[talkUser] == 15 then n = getNumber(msg) b = n * 100 selfSay('So I should change '..n..' of your crystal coins to '..b..' platinum coins for you?', cid) talkState[talkUser] = 16 elseif talkState[talkUser] == 16 then if msgcontains(msg, 'yes') then if doPlayerRemoveItem(cid, 2160, n) == TRUE then doPlayerAddItem(cid, 2152, b) talkState[talkUser] = 0 else selfSay('You don\'t have money.', cid) talkState[talkUser] = 0 end else selfSay('Ok. We cancel.', cid) talkState[talkUser] = 0 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
    • Por Adriano SwaTT
      Procurei aqui pelo forum, e não achei um NPC de Bank que fosse tão perfeito como este que estou postando...
      Eu mesmo havia postado há alguns dias atrás um NPC de Bank, mas não é tão bom quanto este...

      Detalhes do NPC:
      Executa as funções como do Tibia Global.
      Deposit, Transfer, Withdraw, Change Gold, Change Platinum, Change Crystal...

      Funcionando perfeitamente...
      #Testado'

      Vamos ao que interessa.

      Crie um arquivo chamado "bank.xml" na pasta "data / npc"... Cole o código abaixo dentro do arquivo:
      <?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="Welcome |PLAYERNAME|! Here, you can {deposit}, {withdraw} or {transfer} your money from your bank account. I can change your coins too."/> <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> Salve e feche o arquivo.

      Agora vá na pasta Scripts e crie um arquivo chamado "bank.lua" e cole o código abaixo dentro do mesmo:
       
      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, 'change gold') then selfSay('How many platinum coins do you want to get?', cid) talkState[talkUser] = 8 elseif msgcontains(msg, 'change platinum') then selfSay('Do you want to change your platinum coins to gold or crystal?', cid) talkState[talkUser] = 10 elseif msgcontains(msg, 'change crystal') then selfSay('How many crystal coins do you want to change to platinum?', cid) talkState[talkUser] = 15 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('Sucessfull. Now your balance account is ' ..getPlayerBalance(cid)..' golds.', 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) talkState[talkUser] = 0 end else selfSay('There is not enough gold on your account', cid) talkState[talkUser] = 0 end else selfSay('Ok then', cid) talkState[talkUser] = 0 end ----------------------CHANGE GOLD--------------------------------------------------------------------------------- elseif talkState[talkUser] == 8 then n = getNumber(msg) b = n * 100 selfSay('So I should change '..b..' of your gold coins to '..n..' platinum coins for you?', cid) talkState[talkUser] = 9 elseif talkState[talkUser] == 9 then if msgcontains(msg, 'yes') then if doPlayerRemoveItem(cid, 2148, b) == TRUE then doPlayerAddItem(cid, 2152, n) talkState[talkUser] = 0 else selfSay('You don\'t have money.', cid) talkState[talkUser] = 0 end else selfSay('Ok. We cancel.', cid) talkState[talkUser] = 0 end ---------------------CHANGE PLATINUM------------------------------------------------------------------------- elseif talkState[talkUser] == 10 then if msgcontains(msg, 'gold') then selfSay('How many platinum coins do you want to change to gold?', cid) talkState[talkUser] = 11 elseif msgcontains(msg, 'crystal') then selfSay('How many crystal coins do you want to get?', cid) talkState[talkUser] = 13 end elseif talkState[talkUser] == 11 then n = getNumber(msg) b = n * 100 selfSay('So I should change '..n..' of your platinum coins to '..b..' gold coins for you?', cid) talkState[talkUser] = 12 elseif talkState[talkUser] == 12 then if msgcontains(msg, 'yes') then if doPlayerRemoveItem(cid, 2152, n) == TRUE then doPlayerAddItem(cid, 2148, b) talkState[talkUser] = 0 else selfSay('You don\'t have money.', cid) talkState[talkUser] = 0 end else selfSay('Ok. We cancel.', cid) talkState[talkUser] = 0 end elseif talkState[talkUser] == 13 then n = getNumber(msg) b = n * 100 selfSay('So I should change '..b..' of your platinum coins to '..n..' crystal coins for you?', cid) talkState[talkUser] = 14 elseif talkState[talkUser] == 14 then if msgcontains(msg, 'yes') then if doPlayerRemoveItem(cid, 2152, b) == TRUE then doPlayerAddItem(cid, 2160, n) talkState[talkUser] = 0 else selfSay('You don\'t have money.', cid) talkState[talkUser] = 0 end else selfSay('Ok. We cancel.', cid) talkState[talkUser] = 0 end ---------------------CHANGE CRYSTAL------------------------------------------------------------------------------- elseif talkState[talkUser] == 15 then n = getNumber(msg) b = n * 100 selfSay('So I should change '..n..' of your crystal coins to '..b..' platinum coins for you?', cid) talkState[talkUser] = 16 elseif talkState[talkUser] == 16 then if msgcontains(msg, 'yes') then if doPlayerRemoveItem(cid, 2160, n) == TRUE then doPlayerAddItem(cid, 2152, b) talkState[talkUser] = 0 else selfSay('You don\'t have money.', cid) talkState[talkUser] = 0 end else selfSay('Ok. We cancel.', cid) talkState[talkUser] = 0 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  
       
       

      Salve o arquivo e feche-o.

      Agora seu NPC está pronto, basta adicioná-lo ao seu mapa usando o Map Editor.
      Espero que seja de utilidade de alguém...

      Créditos: Tibiaa4e (outro forum)
      Pequeno Tuto: Adriano Swatt
       
      Testado em:
      Versões do Client: 8.54 e 8.60.
      Versões da Distro: TFS 3.4.5, TFS 0.4 e Alissow 0.4.1.

      Espero que seja útil.


      Abraços'
    • Por marvadon
      Boa noite pessoal.
       
       
      To com problemas com os npcs dos bank.
       
      o único que funciona é o NPC de Thais, o resto dos npcs não respondem aos comandos(balance, deposit, withdraw)
       
       
      alguém poderia me ajudar?
       
       
      obrigado
    • Por xWhiteWolf
      Vi um pessoal atrás desse sistema e decidi trazer pra cá ;]
      O que é: Um sistema em que você insere um Cartão de Crédito em um Caixa Eletrônico para executar ações iguais às de um banco de verdade.

      Crie um arquivo em mods com extensão .xml e coloque isso dentro
      Por recomendações do criador do script, é sugerido que se coloque NO-LOGOUT na área da fila.

      Veja as imagens abaixo: 
       
       
      Observações:
      - Para usar o caixa eletrônico, você tem que dar Use With nele com o cartão.
      Créditos:
      LuckOake -- Pelo sistema
    • Por xFatality
      Bastante pessoa quer o sistema de Bank,que a maioria sempre ta bugada,então vou postar uma aqui,que está sem BUG.
      1.Primeiramente vá na pasta talkactions crie uma pasta chamada Bank.Dentro da pasta Bank faça arquivos (.lua) chamados...
      Balance
      Deposit
      Deposit_All
      Transfer
      Transfer_All
      Withdraw
      Withdraw_All
        <!-- Bank --> <talkaction log="yes" words="!balance" script="bank\balance.lua"> <talkaction log="yes" words="!deposit" script="bank\deposit.lua"> <talkaction log="yes" words="!withdraw" script="bank\withdraw.lua"> <talkaction log="yes" words="!transfer" script="bank\transfer.lua"> <talkaction log="yes" words="!depositall" script="bank\deposit_all.lua"> <talkaction log="yes" words="!withdrawall" script="bank\withdraw_all.lua"> <talkaction log="yes" words="!transferall" script="bank\transfer_all.lua"> O Tutorial foi esse,espero que tenham gostado. e por ultimo : Comandos,e para que servem.
        !balance ,Para você ver quanto você tem na sua conta bancaria. !deposit ,Para você depositar certa quantia Ex:!deposit 100. !withdraw ,Para você Retirar certa quantia Ex:!withdraw 100. !transfer ,Para você transferir certa quantia para outro player. !depositall ,Para você depositar tudo o que tem na Backpack. !withdrawall ,Para você retirar tudo o que tem na sua conta. !transferall ,Para você transferir tudo o que tem para outro player. Obrigado,
      Abraços.
×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo