• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua Why still work transfer

tocold

New Member
Joined
Jun 12, 2016
Messages
73
Reaction score
2
I tryng make to
If player is not from rookgaard or not from dawnport
They can't transfer money to rookers/dawnporters

What is worng?

Code:
    if(getPlayerTown(cid) ~= 7) then
       if(getPlayerTown(v) == 7) then
         npcHandler:say('You cant transfer money to players from Rookgaard.', cid)
         Topic[cid] = nil
         return true
       end
     end
     if(getPlayerTown(cid) ~= 10) then
       if(getPlayerTown(v) == 10) then
         npcHandler:say('You cant transfer money to players from Dawnport.', cid)
         Topic[cid] = nil
         return true
       end
     end

Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local Topic, count, transfer = {}, {}, {}

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 getCount(s)
local b, e = s:find('%d+')
return b and e and math.min(4294967295, tonumber(s:sub(b, e))) or -1
end

local function findPlayer(name)
local q = db.getResult('SELECT name FROM players WHERE name=' .. db.escapeString(name) .. ' LIMIT 1'), nil
if q:getID() == -1 then
return
end
local r = q:getDataString('name')
q:free()
return r
end

function greet(cid)
Topic[cid], count[cid], transfer[cid] = nil, nil, nil
return true
end

function creatureSayCallback(cid, type, msg)
if not npcHandler:isFocused(cid) then
return false
elseif msgcontains(msg, 'balance') then
npcHandler:say('Your account balance is ' .. getPlayerBalance(cid) .. ' gold.', cid)
Topic[cid] = nil
elseif msgcontains(msg, 'deposit') and msgcontains(msg, 'all') then
if getPlayerMoney(cid) == 0 then
npcHandler:say('You don\'t have any gold with you.', cid)
Topic[cid] = nil
else
count[cid] = getPlayerMoney(cid)
npcHandler:say('Would you really like to deposit ' .. count[cid] .. ' gold?', cid)
Topic[cid] = 2
end
elseif msgcontains(msg, 'deposit') then
if getCount(msg) == 0 then
npcHandler:say('You are joking, aren\'t you??', cid)
Topic[cid] = nil
elseif getCount(msg) ~= -1 then
if getPlayerMoney(cid) >= getCount(msg) then
count[cid] = getCount(msg)
npcHandler:say('Would you really like to deposit ' .. count[cid] .. ' gold?', cid)
Topic[cid] = 2
else
npcHandler:say('You do not have enough gold.', cid)
Topic[cid] = nil
end
elseif getPlayerMoney(cid) == 0 then
npcHandler:say('You don\'t have any gold with you.', cid)
Topic[cid] = nil
else
npcHandler:say('Please tell me how much gold it is you would like to deposit.', cid)
Topic[cid] = 1
end
elseif Topic[cid] == 1 then
if getCount(msg) == -1 then
npcHandler:say('Please tell me how much gold it is you would like to deposit.', cid)
Topic[cid] = 1
elseif getPlayerMoney(cid) >= getCount(msg) then
count[cid] = getCount(msg)
npcHandler:say('Would you really like to deposit ' .. count[cid] .. ' gold?', cid)
Topic[cid] = 2
else
npcHandler:say('You do not have enough gold.', cid)
Topic[cid] = nil
end
elseif msgcontains(msg, 'yes') and Topic[cid] == 2 then
if doPlayerRemoveMoney(cid, count[cid]) then
doPlayerSetBalance(cid, getPlayerBalance(cid) + count[cid])
npcHandler:say('Alright, we have added the amount of ' .. count[cid] .. ' gold to your balance. You can withdraw your money anytime you want to.', cid)
else
npcHandler:say('I am inconsolable, but it seems you have lost your gold. I hope you get it back.', cid)
end
Topic[cid] = nil
elseif msgcontains(msg, 'no') and Topic[cid] == 2 then
npcHandler:say('As you wish. Is there something else I can do for you?', cid)
Topic[cid] = nil
elseif msgcontains(msg, 'withdraw') then
if getCount(msg) == 0 then
npcHandler:say('Sure, you want nothing you get nothing!', cid)
Topic[cid] = nil
elseif getCount(msg) ~= -1 then
if getPlayerBalance(cid) >= getCount(msg) then
count[cid] = getCount(msg)
npcHandler:say('Are you sure you wish to withdraw ' .. count[cid] .. ' gold from your bank account?', cid)
Topic[cid] = 4
else
npcHandler:say('There is not enough gold on your account.', cid)
Topic[cid] = nil
end
elseif getPlayerBalance(cid) == 0 then
npcHandler:say('You don\'t have any money on your bank account.', cid)
Topic[cid] = nil
else
npcHandler:say('Please tell me how much gold you would like to withdraw.', cid)
Topic[cid] = 3
end
elseif Topic[cid] == 3 then
if getCount(msg) == -1 then
npcHandler:say('Please tell me how much gold you would like to withdraw.', cid)
Topic[cid] = 3
elseif getPlayerBalance(cid) >= getCount(msg) then
count[cid] = getCount(msg)
npcHandler:say('Are you sure you wish to withdraw ' .. count[cid] .. ' gold from your bank account?', cid)
Topic[cid] = 4
else
npcHandler:say('There is not enough gold on your account.', cid)
Topic[cid] = nil
end
elseif msgcontains(msg, 'yes') and Topic[cid] == 4 then
if getPlayerBalance(cid) >= count[cid] then
doPlayerAddMoney(cid, count[cid])
doPlayerSetBalance(cid, getPlayerBalance(cid) - count[cid])
npcHandler:say('Here you are, ' .. count[cid] .. ' gold. Please let me know if there is something else I can do for you.', cid)
else
npcHandler:say('There is not enough gold on your account.', cid)
end
Topic[cid] = nil
elseif msgcontains(msg, 'no') and Topic[cid] == 4 then
npcHandler:say('The customer is king! Come back anytime you want to if you wish to withdraw your money.', cid)
Topic[cid] = nil
elseif msgcontains(msg, 'transfer') then
if getCount(msg) == 0 then
npcHandler:say('Please think about it. Okay?', cid)
Topic[cid] = nil
elseif getCount(msg) ~= -1 then
count[cid] = getCount(msg)
if getPlayerBalance(cid) >= count[cid] then
npcHandler:say('Who would you like to transfer ' .. count[cid] .. ' gold to?', cid)
Topic[cid] = 6
else
npcHandler:say('There is not enough gold on your account.', cid)
Topic[cid] = nil
end
else
npcHandler:say('Please tell me the amount of gold you would like to transfer.', cid)
Topic[cid] = 5
end
elseif Topic[cid] == 5 then
if getCount(msg) == -1 then
npcHandler:say('Please tell me the amount of gold you would like to transfer.', cid)
Topic[cid] = 5
else
count[cid] = getCount(msg)
if getPlayerBalance(cid) >= count[cid] then
npcHandler:say('Who would you like to transfer ' .. count[cid] .. ' gold to?', cid)
Topic[cid] = 6
else
npcHandler:say('There is not enough gold on your account.', cid)
Topic[cid] = nil
end
end
elseif Topic[cid] == 6 then
local v = getPlayerByName(msg)
if getPlayerBalance(cid) >= count[cid] then
   if v then
     transfer[cid] = msg
     npcHandler:say('Would you really like to transfer ' .. count[cid] .. ' gold to ' .. getPlayerName(v) .. '?', cid)
     Topic[cid] = 7
   elseif findPlayer(msg):lower() == msg:lower() then
     transfer[cid] = msg
     npcHandler:say('Would you really like to transfer ' .. count[cid] .. ' gold to ' .. findPlayer(msg) .. '?', cid)
     Topic[cid] = 7
   else
     npcHandler:say('This player does not exist.', cid)
     Topic[cid] = nil
   end
else
   npcHandler:say('There is not enough gold on your account.', cid)
   Topic[cid] = nil
end
elseif Topic[cid] == 7 and msgcontains(msg, 'yes') then
if getPlayerBalance(cid) >= count[cid] then
   local v = getPlayerByName(transfer[cid])
   if v then
     if(getPlayerTown(cid) ~= 7) then
       if(getPlayerTown(v) == 7) then
         npcHandler:say('You cant transfer money to players from Rookgaard.', cid)
         Topic[cid] = nil
         return true
       end
     end
     if(getPlayerTown(cid) ~= 10) then
       if(getPlayerTown(v) == 10) then
         npcHandler:say('You cant transfer money to players from Dawnport.', cid)
         Topic[cid] = nil
         return true
       end
     end
     doPlayerSetBalance(cid, getPlayerBalance(cid) - count[cid])
     doPlayerSetBalance(v, getPlayerBalance(v) + count[cid])
     npcHandler:say('Very well. You have transferred ' .. count[cid] .. ' gold to ' .. getPlayerName(v) .. '.', cid)
   elseif findPlayer(transfer[cid]):lower() == transfer[cid]:lower() then
     doPlayerSetBalance(cid, getPlayerBalance(cid) - count[cid])
     db.executeQuery('UPDATE players SET balance=balance+' .. count[cid] .. ' WHERE name=' .. db.escapeString(transfer[cid]) .. ' LIMIT 1')
     npcHandler:say('Very well. You have transferred ' .. count[cid] .. ' gold to ' .. findPlayer(transfer[cid]) .. '.', cid)
   else
     npcHandler:say('This player does not exist.', cid)
   end
else
   npcHandler:say('There is not enough gold on your account.', cid)
end
Topic[cid] = nil
elseif Topic[cid] == 7 and msgcontains(msg, 'no') then
npcHandler:say('Alright, is there something else I can do for you?', cid)
Topic[cid] = nil
elseif msgcontains(msg, 'change gold') then
npcHandler:say('How many platinum coins would you like to get?', cid)
Topic[cid] = 8
elseif Topic[cid] == 8 then
if getCount(msg) < 1 then
npcHandler:say('Hmm, can I help you with something else?', cid)
Topic[cid] = nil
else
count[cid] = math.min(500, getCount(msg))
npcHandler:say('So you would like me to change ' .. count[cid] * 100 .. ' of your gold coins into ' .. count[cid] .. ' platinum coins?', cid)
Topic[cid] = 9
end
elseif Topic[cid] == 9 then
if msgcontains(msg, 'yes') then
if doPlayerRemoveItem(cid, 2148, count[cid] * 100) then
npcHandler:say('Here you are.', cid)
doPlayerAddItem(cid, 2152, count[cid])
else
npcHandler:say('Sorry, you do not have enough gold coins.', cid)
end
else
npcHandler:say('Well, can I help you with something else?', cid)
end
Topic[cid] = nil
elseif msgcontains(msg, 'change platinum') then
npcHandler:say('Would you like to change your platinum coins into gold or crystal?', cid)
Topic[cid] = 10
elseif Topic[cid] == 10 then
if msgcontains(msg, 'gold') then
npcHandler:say('How many platinum coins would you like to change into gold?', cid)
Topic[cid] = 11
elseif msgcontains(msg, 'crystal') then
npcHandler:say('How many crystal coins would you like to get?', cid)
Topic[cid] = 13
else
npcHandler:say('Well, can I help you with something else?', cid)
Topic[cid] = nil
end
elseif Topic[cid] == 11 then
if getCount(msg) < 1 then
npcHandler:say('Hmm, can I help you with something else?', cid)
Topic[cid] = nil
else
count[cid] = math.min(500, getCount(msg))
npcHandler:say('So you would like me to change ' .. count[cid] .. ' of your platinum coins into ' .. count[cid] * 100 .. ' gold coins for you?', cid)
Topic[cid] = 12
end
elseif Topic[cid] == 12 then
if msgcontains(msg, 'yes') then
if doPlayerRemoveItem(cid, 2152, count[cid]) then
npcHandler:say('Here you are.', cid)
doPlayerAddItem(cid, 2148, count[cid] * 100)
else
npcHandler:say('Sorry, you do not have enough platinum coins.', cid)
end
else
npcHandler:say('Well, can I help you with something else?', cid)
end
Topic[cid] = nil
elseif Topic[cid] == 13 then
if getCount(msg) < 1 then
npcHandler:say('Hmm, can I help you with something else?', cid)
Topic[cid] = nil
else
count[cid] = math.min(500, getCount(msg))
npcHandler:say('So you would like me to change ' .. count[cid] * 100 .. ' of your platinum coins into ' .. count[cid] .. ' crystal coins for you?', cid)
Topic[cid] = 14
end
elseif Topic[cid] == 14 then
if msgcontains(msg, 'yes') then
if doPlayerRemoveItem(cid, 2152, count[cid] * 100) then
npcHandler:say('Here you are.', cid)
doPlayerAddItem(cid, 2160, count[cid])
else
npcHandler:say('Sorry, you do not have enough platinum coins.', cid)
end
else
npcHandler:say('Well, can I help you with something else?', cid)
end
Topic[cid] = nil
elseif msgcontains(msg, 'change crystal') then
npcHandler:say('How many crystal coins would you like to change into platinum?', cid)
Topic[cid] = 15
elseif Topic[cid] == 15 then
if getCount(msg) == -1 or getCount(msg) == 0 then
npcHandler:say('Hmm, can I help you with something else?', cid)
Topic[cid] = nil
else
count[cid] = math.min(500, getCount(msg))
npcHandler:say('So you would like me to change ' .. count[cid] .. ' of your crystal coins into ' .. count[cid] * 100 .. ' platinum coins for you?', cid)
Topic[cid] = 16
end
elseif Topic[cid] == 16 then
if msgcontains(msg, 'yes') then
if doPlayerRemoveItem(cid, 2160, count[cid]) then
npcHandler:say('Here you are.', cid)
doPlayerAddItem(cid, 2152, count[cid] * 100)
else
npcHandler:say('Sorry, you do not have enough crystal coins.', cid)
end
else
npcHandler:say('Well, can I help you with something else?', cid)
end
Topic[cid] = nil
elseif msgcontains(msg, 'change') then
npcHandler:say('There are three different coin types in Tibia: 100 gold coins equal 1 platinum coin, 100 platinum coins equal 1 crystal coin. So if you\'d like to change 100 gold into 1 platinum, simply say \'{change gold}\' and then \'1 platinum\'.', cid)
Topic[cid] = nil
elseif msgcontains(msg, 'bank') then
npcHandler:say('We can change money for you. You can also access your bank account.', cid)
Topic[cid] = nil
end
return true
end

npcHandler:setCallback(CALLBACK_GREET, greet)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
i dont use ur server version but should work
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local Topic, count, transfer = {}, {}, {}

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 getCount(s)
    local b, e = s:find('%d+')
    return b and e and math.min(4294967295, tonumber(s:sub(b, e))) or -1
end

local function findPlayer(name)
    local resultId = db.storeQuery('SELECT name FROM players WHERE name=' .. db.escapeString(name) .. ' LIMIT 1'), nil
    if resultId == false then
        return
    end
    local r = result.getDataString(resultId, "name")
    result.free(resultId)
    return r
end

local function vocation(name)
    local resultId = db.storeQuery('SELECT vocation FROM players WHERE name=' .. db.escapeString(name) .. ' LIMIT 1'), nil
    if resultId == false then
        return
    end
    local r = result.getDataInt(resultId, "vocation")
    result.free(resultId)
    return r
end

local function getPlayerBiddedMoney(cid)
    local resultId = db.storeQuery('SELECT `bid` FROM `houses` WHERE `highest_bidder`=' .. db.escapeString(getPlayerGUID(cid)) .. ' LIMIT 1')
    if resultId == false then
        return 0
    end
    local r = result.getDataInt(resultId, "bid")
    result.free(resultId)
    return r
end

local function updatePlayerBalance(name, value)
    db.query('UPDATE players SET balance=' .. value .. ' WHERE name=' .. db.escapeString(name) .. ' LIMIT 1')
end

function greet(cid)
    Topic[cid], count[cid], transfer[cid] = nil, nil, nil
    return true
end

function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    elseif msgcontains(msg, 'balance') then
        local bid = getPlayerBiddedMoney(cid)
        if(bid > 0) then
            npcHandler:say('Your account balance is ' .. getPlayerBalance(cid) .. ' gold, ' .. bid .. ' gold is blocked for house auctioned by you.', cid)
        else
            npcHandler:say('Your account balance is ' .. getPlayerBalance(cid) .. ' gold.', cid)
        end
        Topic[cid] = nil
    elseif msgcontains(msg, 'deposit') and msgcontains(msg, 'all') then
        if getPlayerMoney(cid) == 0 then
            npcHandler:say('You don\'t have any gold with you.', cid)
            Topic[cid] = nil
        else
            count[cid] = getPlayerMoney(cid)
            npcHandler:say('Would you really like to deposit ' .. count[cid] .. ' gold?', cid)
            Topic[cid] = 2
        end
    elseif msgcontains(msg, 'deposit') then
        if getCount(msg) == 0 then
            npcHandler:say('You are joking, aren\'t you??', cid)
            Topic[cid] = nil
        elseif getCount(msg) ~= -1 then
            if getPlayerMoney(cid) >= getCount(msg) then
                count[cid] = getCount(msg)
                npcHandler:say('Would you really like to deposit ' .. count[cid] .. ' gold?', cid)
                Topic[cid] = 2
            else
                npcHandler:say('You do not have enough gold.', cid)
                Topic[cid] = nil
            end
        elseif getPlayerMoney(cid) == 0 then
            npcHandler:say('You don\'t have any gold with you.', cid)
            Topic[cid] = nil
        else
            npcHandler:say('Please tell me how much gold it is you would like to deposit.', cid)
            Topic[cid] = 1
        end
    elseif Topic[cid] == 1 then
        if getCount(msg) == -1 then
            npcHandler:say('Please tell me how much gold it is you would like to deposit.', cid)
            Topic[cid] = 1
        elseif getPlayerMoney(cid) >= getCount(msg) then
            count[cid] = getCount(msg)
            npcHandler:say('Would you really like to deposit ' .. count[cid] .. ' gold?', cid)
            Topic[cid] = 2
        else
            npcHandler:say('You do not have enough gold.', cid)
            Topic[cid] = nil
        end
    elseif msgcontains(msg, 'yes') and Topic[cid] == 2 then
        if doPlayerRemoveMoney(cid, count[cid]) then
            doPlayerSetBalance(cid, getPlayerBalance(cid) + count[cid])
            updatePlayerBalance(getPlayerName(cid), getPlayerBalance(cid))
            npcHandler:say('Alright, we have added the amount of ' .. count[cid] .. ' gold to your balance. You can withdraw your money anytime you want to.', cid)
        else
            npcHandler:say('I am inconsolable, but it seems you have lost your gold. I hope you get it back.', cid)
        end
        Topic[cid] = nil
    elseif msgcontains(msg, 'no') and Topic[cid] == 2 then
        npcHandler:say('As you wish. Is there something else I can do for you?', cid)
        Topic[cid] = nil
    elseif msgcontains(msg, 'withdraw') then
        if getCount(msg) == 0 then
            npcHandler:say('Sure, you want nothing you get nothing!', cid)
            Topic[cid] = nil
        elseif getCount(msg) ~= -1 then
            if getPlayerBalance(cid) - getPlayerBiddedMoney(cid) >= getCount(msg) then
                count[cid] = getCount(msg)
                npcHandler:say('Are you sure you wish to withdraw ' .. count[cid] .. ' gold from your bank account?', cid)
                Topic[cid] = 4
            else
                npcHandler:say('There is not enough gold on your account.', cid)
                Topic[cid] = nil
            end
        elseif getPlayerBalance(cid) == 0 then
            npcHandler:say('You don\'t have any money on your bank account.', cid)
            Topic[cid] = nil
        else
            npcHandler:say('Please tell me how much gold you would like to withdraw.', cid)
            Topic[cid] = 3
        end
    elseif Topic[cid] == 3 then
        if getCount(msg) == -1 then
            npcHandler:say('Please tell me how much gold you would like to withdraw.', cid)
            Topic[cid] = 3
        elseif getPlayerBalance(cid) - getPlayerBiddedMoney(cid) >= getCount(msg) then
            count[cid] = getCount(msg)
            npcHandler:say('Are you sure you wish to withdraw ' .. count[cid] .. ' gold from your bank account?', cid)
            Topic[cid] = 4
        else
            npcHandler:say('There is not enough gold on your account.', cid)
            Topic[cid] = nil
        end
    elseif msgcontains(msg, 'yes') and Topic[cid] == 4 then
        if getPlayerBalance(cid) - getPlayerBiddedMoney(cid) >= count[cid] then
            doPlayerAddMoney(cid, count[cid])
            doPlayerSetBalance(cid, getPlayerBalance(cid) - count[cid])
            updatePlayerBalance(getPlayerName(cid), getPlayerBalance(cid))
            npcHandler:say('Here you are, ' .. count[cid] .. ' gold. Please let me know if there is something else I can do for you.', cid)
        else
            npcHandler:say('There is not enough gold on your account.', cid)
        end
        Topic[cid] = nil
    elseif msgcontains(msg, 'no') and Topic[cid] == 4 then
        npcHandler:say('The customer is king! Come back anytime you want to if you wish to withdraw your money.', cid)
        Topic[cid] = nil
    elseif msgcontains(msg, 'transfer') then
        if getCount(msg) == 0 then
            npcHandler:say('Please think about it. Okay?', cid)
            Topic[cid] = nil
        elseif getCount(msg) ~= -1 then
       
            count[cid] = getCount(msg)
            if getPlayerBalance(cid) - getPlayerBiddedMoney(cid) >= count[cid] then
                npcHandler:say('Who would you like to transfer ' .. count[cid] .. ' gold to?', cid)
                Topic[cid] = 6
            else
                npcHandler:say('There is not enough gold on your account.', cid)
                Topic[cid] = nil
            end

        else
            npcHandler:say('Please tell me the amount of gold you would like to transfer.', cid)
            Topic[cid] = 5
        end
    elseif Topic[cid] == 5 then
        if getCount(msg) == -1 then
            npcHandler:say('Please tell me the amount of gold you would like to transfer.', cid)
            Topic[cid] = 5
        else
            count[cid] = getCount(msg)
            if getPlayerBalance(cid) - getPlayerBiddedMoney(cid) >= count[cid] then
                npcHandler:say('Who would you like to transfer ' .. count[cid] .. ' gold to?', cid)
                Topic[cid] = 6
            else
                npcHandler:say('There is not enough gold on your account.', cid)
                Topic[cid] = nil
            end
        end
    elseif Topic[cid] == 6 then
        local v = getPlayerByName(msg)
        if getPlayerBalance(cid) - getPlayerBiddedMoney(cid) >= count[cid] then
            if v and Player(msg):getVocation():getId() > 0 and not isInArray({7, 10}, getPlayerTown(msg:lower)) then
                transfer[cid] = msg
                npcHandler:say('Would you really like to transfer ' .. count[cid] .. ' gold to ' .. getPlayerName(v) .. '?', cid)
                Topic[cid] = 7
            elseif getPlayerGUIDByName(msg:lower()) ~= 0  and vocation(msg:lower()) > 0 and not isInArray({7, 10}, getPlayerTown(msg:lower)) then
                transfer[cid] = msg
                npcHandler:say('Would you really like to transfer ' .. count[cid] .. ' gold to ' .. findPlayer(msg) .. '?', cid)
                Topic[cid] = 7               
            else
                npcHandler:say('This player does not exist on this world or have no vocation .', cid)
                Topic[cid] = nil
            end
        else
            npcHandler:say('There is not enough gold on your account.', cid)
            Topic[cid] = nil
        end
    elseif Topic[cid] == 7 and msgcontains(msg, 'yes') then
        if getPlayerBalance(cid) - getPlayerBiddedMoney(cid) >= count[cid] then
            local v = getPlayerByName(transfer[cid])
            if v then
                doPlayerSetBalance(cid, getPlayerBalance(cid) - count[cid])
                updatePlayerBalance(getPlayerName(cid), getPlayerBalance(cid))
                doPlayerSetBalance(v, getPlayerBalance(v) + count[cid])
                updatePlayerBalance(getPlayerName(v), getPlayerBalance(v))
                npcHandler:say('Very well. You have transferred ' .. count[cid] .. ' gold to ' .. getPlayerName(v) .. '.', cid)
            elseif findPlayer(transfer[cid]):lower() == transfer[cid]:lower() then
                doPlayerSetBalance(cid, getPlayerBalance(cid) - count[cid])
                updatePlayerBalance(getPlayerName(cid), getPlayerBalance(cid))
                db.query('UPDATE players SET balance=balance+' .. count[cid] .. ' WHERE name=' .. db.escapeString(transfer[cid]) .. ' LIMIT 1')
                npcHandler:say('Very well. You have transferred ' .. count[cid] .. ' gold to ' .. findPlayer(transfer[cid]) .. '.', cid)
            else
                npcHandler:say('This player does not exist.', cid)
            end
        else
            npcHandler:say('There is not enough gold on your account.', cid)
        end
        Topic[cid] = nil
    elseif Topic[cid] == 7 and msgcontains(msg, 'no') then
        npcHandler:say('Alright, is there something else I can do for you?', cid)
        Topic[cid] = nil
    elseif msgcontains(msg, 'change gold') then
        npcHandler:say('How many platinum coins would you like to get?', cid)
        Topic[cid] = 8
    elseif Topic[cid] == 8 then
        if getCount(msg) < 1 then
            npcHandler:say('Hmm, can I help you with something else?', cid)
            Topic[cid] = nil
        else
            count[cid] = math.min(500, getCount(msg))
            npcHandler:say('So you would like me to change ' .. count[cid] * 100 .. ' of your gold coins into ' .. count[cid] .. ' platinum coins?', cid)
            Topic[cid] = 9
        end
    elseif Topic[cid] == 9 then
        if msgcontains(msg, 'yes') then
            if doPlayerRemoveItem(cid, 2148, count[cid] * 100) then
                npcHandler:say('Here you are.', cid)
                doPlayerAddItem(cid, 2152, count[cid])
            else
                npcHandler:say('Sorry, you do not have enough gold coins.', cid)
            end
        else
            npcHandler:say('Well, can I help you with something else?', cid)
        end
        Topic[cid] = nil
    elseif msgcontains(msg, 'change platinum') then
        npcHandler:say('Would you like to change your platinum coins into gold or crystal?', cid)
        Topic[cid] = 10
    elseif Topic[cid] == 10 then
        if msgcontains(msg, 'gold') then
            npcHandler:say('How many platinum coins would you like to change into gold?', cid)
            Topic[cid] = 11
        elseif msgcontains(msg, 'crystal') then
            npcHandler:say('How many crystal coins would you like to get?', cid)
            Topic[cid] = 13
        else
            npcHandler:say('Well, can I help you with something else?', cid)
            Topic[cid] = nil
        end
    elseif Topic[cid] == 11 then
        if getCount(msg) < 1 then
            npcHandler:say('Hmm, can I help you with something else?', cid)
            Topic[cid] = nil
        else
            count[cid] = math.min(500, getCount(msg))
            npcHandler:say('So you would like me to change ' .. count[cid] .. ' of your platinum coins into ' .. count[cid] * 100 .. ' gold coins for you?', cid)
            Topic[cid] = 12
        end
    elseif Topic[cid] == 12 then
        if msgcontains(msg, 'yes') then
            if doPlayerRemoveItem(cid, 2152, count[cid]) then
                npcHandler:say('Here you are.', cid)
                doPlayerAddItem(cid, 2148, count[cid] * 100)
            else
                npcHandler:say('Sorry, you do not have enough platinum coins.', cid)
            end
        else
            npcHandler:say('Well, can I help you with something else?', cid)
        end
        Topic[cid] = nil
    elseif Topic[cid] == 13 then
        if getCount(msg) < 1 then
            npcHandler:say('Hmm, can I help you with something else?', cid)
            Topic[cid] = nil
        else
            count[cid] = math.min(500, getCount(msg))
            npcHandler:say('So you would like me to change ' .. count[cid] * 100 .. ' of your platinum coins into ' .. count[cid] .. ' crystal coins for you?', cid)
            Topic[cid] = 14
        end
    elseif Topic[cid] == 14 then
        if msgcontains(msg, 'yes') then
            if doPlayerRemoveItem(cid, 2152, count[cid] * 100) then
                npcHandler:say('Here you are.', cid)
                doPlayerAddItem(cid, 2160, count[cid])
            else
                npcHandler:say('Sorry, you do not have enough platinum coins.', cid)
            end
        else
            npcHandler:say('Well, can I help you with something else?', cid)
        end
        Topic[cid] = nil
    elseif msgcontains(msg, 'change crystal') then
        npcHandler:say('How many crystal coins would you like to change into platinum?', cid)
        Topic[cid] = 15
    elseif Topic[cid] == 15 then
        if getCount(msg) == -1 or getCount(msg) == 0 then
            npcHandler:say('Hmm, can I help you with something else?', cid)
            Topic[cid] = nil
        else
            count[cid] = math.min(500, getCount(msg))
            npcHandler:say('So you would like me to change ' .. count[cid] .. ' of your crystal coins into ' .. count[cid] * 100 .. ' platinum coins for you?', cid)
            Topic[cid] = 16
        end
    elseif Topic[cid] == 16 then
        if msgcontains(msg, 'yes') then
            if doPlayerRemoveItem(cid, 2160, count[cid]) then
                npcHandler:say('Here you are.', cid)
                doPlayerAddItem(cid, 2152, count[cid] * 100)
            else
                npcHandler:say('Sorry, you do not have enough crystal coins.', cid)
            end
        else
            npcHandler:say('Well, can I help you with something else?', cid)
        end
        Topic[cid] = nil
    elseif msgcontains(msg, 'change') then
        npcHandler:say('There are three different coin types in Tibia: 100 gold coins equal 1 platinum coin, 100 platinum coins equal 1 crystal coin. So if you\'d like to change 100 gold into 1 platinum, simply say \'{change gold}\' and then \'1 platinum\'.', cid)
        Topic[cid] = nil
    elseif msgcontains(msg, 'bank') then
        npcHandler:say('We can change money for you. You can also access your bank account.', cid)
        Topic[cid] = nil
    end
    return true
end

npcHandler:setCallback(CALLBACK_GREET, greet)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
i dont use ur server version but should work
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local Topic, count, transfer = {}, {}, {}

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 getCount(s)
    local b, e = s:find('%d+')
    return b and e and math.min(4294967295, tonumber(s:sub(b, e))) or -1
end

local function findPlayer(name)
    local resultId = db.storeQuery('SELECT name FROM players WHERE name=' .. db.escapeString(name) .. ' LIMIT 1'), nil
    if resultId == false then
        return
    end
    local r = result.getDataString(resultId, "name")
    result.free(resultId)
    return r
end

local function vocation(name)
    local resultId = db.storeQuery('SELECT vocation FROM players WHERE name=' .. db.escapeString(name) .. ' LIMIT 1'), nil
    if resultId == false then
        return
    end
    local r = result.getDataInt(resultId, "vocation")
    result.free(resultId)
    return r
end

local function getPlayerBiddedMoney(cid)
    local resultId = db.storeQuery('SELECT `bid` FROM `houses` WHERE `highest_bidder`=' .. db.escapeString(getPlayerGUID(cid)) .. ' LIMIT 1')
    if resultId == false then
        return 0
    end
    local r = result.getDataInt(resultId, "bid")
    result.free(resultId)
    return r
end

local function updatePlayerBalance(name, value)
    db.query('UPDATE players SET balance=' .. value .. ' WHERE name=' .. db.escapeString(name) .. ' LIMIT 1')
end

function greet(cid)
    Topic[cid], count[cid], transfer[cid] = nil, nil, nil
    return true
end

function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    elseif msgcontains(msg, 'balance') then
        local bid = getPlayerBiddedMoney(cid)
        if(bid > 0) then
            npcHandler:say('Your account balance is ' .. getPlayerBalance(cid) .. ' gold, ' .. bid .. ' gold is blocked for house auctioned by you.', cid)
        else
            npcHandler:say('Your account balance is ' .. getPlayerBalance(cid) .. ' gold.', cid)
        end
        Topic[cid] = nil
    elseif msgcontains(msg, 'deposit') and msgcontains(msg, 'all') then
        if getPlayerMoney(cid) == 0 then
            npcHandler:say('You don\'t have any gold with you.', cid)
            Topic[cid] = nil
        else
            count[cid] = getPlayerMoney(cid)
            npcHandler:say('Would you really like to deposit ' .. count[cid] .. ' gold?', cid)
            Topic[cid] = 2
        end
    elseif msgcontains(msg, 'deposit') then
        if getCount(msg) == 0 then
            npcHandler:say('You are joking, aren\'t you??', cid)
            Topic[cid] = nil
        elseif getCount(msg) ~= -1 then
            if getPlayerMoney(cid) >= getCount(msg) then
                count[cid] = getCount(msg)
                npcHandler:say('Would you really like to deposit ' .. count[cid] .. ' gold?', cid)
                Topic[cid] = 2
            else
                npcHandler:say('You do not have enough gold.', cid)
                Topic[cid] = nil
            end
        elseif getPlayerMoney(cid) == 0 then
            npcHandler:say('You don\'t have any gold with you.', cid)
            Topic[cid] = nil
        else
            npcHandler:say('Please tell me how much gold it is you would like to deposit.', cid)
            Topic[cid] = 1
        end
    elseif Topic[cid] == 1 then
        if getCount(msg) == -1 then
            npcHandler:say('Please tell me how much gold it is you would like to deposit.', cid)
            Topic[cid] = 1
        elseif getPlayerMoney(cid) >= getCount(msg) then
            count[cid] = getCount(msg)
            npcHandler:say('Would you really like to deposit ' .. count[cid] .. ' gold?', cid)
            Topic[cid] = 2
        else
            npcHandler:say('You do not have enough gold.', cid)
            Topic[cid] = nil
        end
    elseif msgcontains(msg, 'yes') and Topic[cid] == 2 then
        if doPlayerRemoveMoney(cid, count[cid]) then
            doPlayerSetBalance(cid, getPlayerBalance(cid) + count[cid])
            updatePlayerBalance(getPlayerName(cid), getPlayerBalance(cid))
            npcHandler:say('Alright, we have added the amount of ' .. count[cid] .. ' gold to your balance. You can withdraw your money anytime you want to.', cid)
        else
            npcHandler:say('I am inconsolable, but it seems you have lost your gold. I hope you get it back.', cid)
        end
        Topic[cid] = nil
    elseif msgcontains(msg, 'no') and Topic[cid] == 2 then
        npcHandler:say('As you wish. Is there something else I can do for you?', cid)
        Topic[cid] = nil
    elseif msgcontains(msg, 'withdraw') then
        if getCount(msg) == 0 then
            npcHandler:say('Sure, you want nothing you get nothing!', cid)
            Topic[cid] = nil
        elseif getCount(msg) ~= -1 then
            if getPlayerBalance(cid) - getPlayerBiddedMoney(cid) >= getCount(msg) then
                count[cid] = getCount(msg)
                npcHandler:say('Are you sure you wish to withdraw ' .. count[cid] .. ' gold from your bank account?', cid)
                Topic[cid] = 4
            else
                npcHandler:say('There is not enough gold on your account.', cid)
                Topic[cid] = nil
            end
        elseif getPlayerBalance(cid) == 0 then
            npcHandler:say('You don\'t have any money on your bank account.', cid)
            Topic[cid] = nil
        else
            npcHandler:say('Please tell me how much gold you would like to withdraw.', cid)
            Topic[cid] = 3
        end
    elseif Topic[cid] == 3 then
        if getCount(msg) == -1 then
            npcHandler:say('Please tell me how much gold you would like to withdraw.', cid)
            Topic[cid] = 3
        elseif getPlayerBalance(cid) - getPlayerBiddedMoney(cid) >= getCount(msg) then
            count[cid] = getCount(msg)
            npcHandler:say('Are you sure you wish to withdraw ' .. count[cid] .. ' gold from your bank account?', cid)
            Topic[cid] = 4
        else
            npcHandler:say('There is not enough gold on your account.', cid)
            Topic[cid] = nil
        end
    elseif msgcontains(msg, 'yes') and Topic[cid] == 4 then
        if getPlayerBalance(cid) - getPlayerBiddedMoney(cid) >= count[cid] then
            doPlayerAddMoney(cid, count[cid])
            doPlayerSetBalance(cid, getPlayerBalance(cid) - count[cid])
            updatePlayerBalance(getPlayerName(cid), getPlayerBalance(cid))
            npcHandler:say('Here you are, ' .. count[cid] .. ' gold. Please let me know if there is something else I can do for you.', cid)
        else
            npcHandler:say('There is not enough gold on your account.', cid)
        end
        Topic[cid] = nil
    elseif msgcontains(msg, 'no') and Topic[cid] == 4 then
        npcHandler:say('The customer is king! Come back anytime you want to if you wish to withdraw your money.', cid)
        Topic[cid] = nil
    elseif msgcontains(msg, 'transfer') then
        if getCount(msg) == 0 then
            npcHandler:say('Please think about it. Okay?', cid)
            Topic[cid] = nil
        elseif getCount(msg) ~= -1 then
     
            count[cid] = getCount(msg)
            if getPlayerBalance(cid) - getPlayerBiddedMoney(cid) >= count[cid] then
                npcHandler:say('Who would you like to transfer ' .. count[cid] .. ' gold to?', cid)
                Topic[cid] = 6
            else
                npcHandler:say('There is not enough gold on your account.', cid)
                Topic[cid] = nil
            end

        else
            npcHandler:say('Please tell me the amount of gold you would like to transfer.', cid)
            Topic[cid] = 5
        end
    elseif Topic[cid] == 5 then
        if getCount(msg) == -1 then
            npcHandler:say('Please tell me the amount of gold you would like to transfer.', cid)
            Topic[cid] = 5
        else
            count[cid] = getCount(msg)
            if getPlayerBalance(cid) - getPlayerBiddedMoney(cid) >= count[cid] then
                npcHandler:say('Who would you like to transfer ' .. count[cid] .. ' gold to?', cid)
                Topic[cid] = 6
            else
                npcHandler:say('There is not enough gold on your account.', cid)
                Topic[cid] = nil
            end
        end
    elseif Topic[cid] == 6 then
        local v = getPlayerByName(msg)
        if getPlayerBalance(cid) - getPlayerBiddedMoney(cid) >= count[cid] then
            if v and Player(msg):getVocation():getId() > 0 and not isInArray({7, 10}, getPlayerTown(msg:lower)) then
                transfer[cid] = msg
                npcHandler:say('Would you really like to transfer ' .. count[cid] .. ' gold to ' .. getPlayerName(v) .. '?', cid)
                Topic[cid] = 7
            elseif getPlayerGUIDByName(msg:lower()) ~= 0  and vocation(msg:lower()) > 0 and not isInArray({7, 10}, getPlayerTown(msg:lower)) then
                transfer[cid] = msg
                npcHandler:say('Would you really like to transfer ' .. count[cid] .. ' gold to ' .. findPlayer(msg) .. '?', cid)
                Topic[cid] = 7             
            else
                npcHandler:say('This player does not exist on this world or have no vocation .', cid)
                Topic[cid] = nil
            end
        else
            npcHandler:say('There is not enough gold on your account.', cid)
            Topic[cid] = nil
        end
    elseif Topic[cid] == 7 and msgcontains(msg, 'yes') then
        if getPlayerBalance(cid) - getPlayerBiddedMoney(cid) >= count[cid] then
            local v = getPlayerByName(transfer[cid])
            if v then
                doPlayerSetBalance(cid, getPlayerBalance(cid) - count[cid])
                updatePlayerBalance(getPlayerName(cid), getPlayerBalance(cid))
                doPlayerSetBalance(v, getPlayerBalance(v) + count[cid])
                updatePlayerBalance(getPlayerName(v), getPlayerBalance(v))
                npcHandler:say('Very well. You have transferred ' .. count[cid] .. ' gold to ' .. getPlayerName(v) .. '.', cid)
            elseif findPlayer(transfer[cid]):lower() == transfer[cid]:lower() then
                doPlayerSetBalance(cid, getPlayerBalance(cid) - count[cid])
                updatePlayerBalance(getPlayerName(cid), getPlayerBalance(cid))
                db.query('UPDATE players SET balance=balance+' .. count[cid] .. ' WHERE name=' .. db.escapeString(transfer[cid]) .. ' LIMIT 1')
                npcHandler:say('Very well. You have transferred ' .. count[cid] .. ' gold to ' .. findPlayer(transfer[cid]) .. '.', cid)
            else
                npcHandler:say('This player does not exist.', cid)
            end
        else
            npcHandler:say('There is not enough gold on your account.', cid)
        end
        Topic[cid] = nil
    elseif Topic[cid] == 7 and msgcontains(msg, 'no') then
        npcHandler:say('Alright, is there something else I can do for you?', cid)
        Topic[cid] = nil
    elseif msgcontains(msg, 'change gold') then
        npcHandler:say('How many platinum coins would you like to get?', cid)
        Topic[cid] = 8
    elseif Topic[cid] == 8 then
        if getCount(msg) < 1 then
            npcHandler:say('Hmm, can I help you with something else?', cid)
            Topic[cid] = nil
        else
            count[cid] = math.min(500, getCount(msg))
            npcHandler:say('So you would like me to change ' .. count[cid] * 100 .. ' of your gold coins into ' .. count[cid] .. ' platinum coins?', cid)
            Topic[cid] = 9
        end
    elseif Topic[cid] == 9 then
        if msgcontains(msg, 'yes') then
            if doPlayerRemoveItem(cid, 2148, count[cid] * 100) then
                npcHandler:say('Here you are.', cid)
                doPlayerAddItem(cid, 2152, count[cid])
            else
                npcHandler:say('Sorry, you do not have enough gold coins.', cid)
            end
        else
            npcHandler:say('Well, can I help you with something else?', cid)
        end
        Topic[cid] = nil
    elseif msgcontains(msg, 'change platinum') then
        npcHandler:say('Would you like to change your platinum coins into gold or crystal?', cid)
        Topic[cid] = 10
    elseif Topic[cid] == 10 then
        if msgcontains(msg, 'gold') then
            npcHandler:say('How many platinum coins would you like to change into gold?', cid)
            Topic[cid] = 11
        elseif msgcontains(msg, 'crystal') then
            npcHandler:say('How many crystal coins would you like to get?', cid)
            Topic[cid] = 13
        else
            npcHandler:say('Well, can I help you with something else?', cid)
            Topic[cid] = nil
        end
    elseif Topic[cid] == 11 then
        if getCount(msg) < 1 then
            npcHandler:say('Hmm, can I help you with something else?', cid)
            Topic[cid] = nil
        else
            count[cid] = math.min(500, getCount(msg))
            npcHandler:say('So you would like me to change ' .. count[cid] .. ' of your platinum coins into ' .. count[cid] * 100 .. ' gold coins for you?', cid)
            Topic[cid] = 12
        end
    elseif Topic[cid] == 12 then
        if msgcontains(msg, 'yes') then
            if doPlayerRemoveItem(cid, 2152, count[cid]) then
                npcHandler:say('Here you are.', cid)
                doPlayerAddItem(cid, 2148, count[cid] * 100)
            else
                npcHandler:say('Sorry, you do not have enough platinum coins.', cid)
            end
        else
            npcHandler:say('Well, can I help you with something else?', cid)
        end
        Topic[cid] = nil
    elseif Topic[cid] == 13 then
        if getCount(msg) < 1 then
            npcHandler:say('Hmm, can I help you with something else?', cid)
            Topic[cid] = nil
        else
            count[cid] = math.min(500, getCount(msg))
            npcHandler:say('So you would like me to change ' .. count[cid] * 100 .. ' of your platinum coins into ' .. count[cid] .. ' crystal coins for you?', cid)
            Topic[cid] = 14
        end
    elseif Topic[cid] == 14 then
        if msgcontains(msg, 'yes') then
            if doPlayerRemoveItem(cid, 2152, count[cid] * 100) then
                npcHandler:say('Here you are.', cid)
                doPlayerAddItem(cid, 2160, count[cid])
            else
                npcHandler:say('Sorry, you do not have enough platinum coins.', cid)
            end
        else
            npcHandler:say('Well, can I help you with something else?', cid)
        end
        Topic[cid] = nil
    elseif msgcontains(msg, 'change crystal') then
        npcHandler:say('How many crystal coins would you like to change into platinum?', cid)
        Topic[cid] = 15
    elseif Topic[cid] == 15 then
        if getCount(msg) == -1 or getCount(msg) == 0 then
            npcHandler:say('Hmm, can I help you with something else?', cid)
            Topic[cid] = nil
        else
            count[cid] = math.min(500, getCount(msg))
            npcHandler:say('So you would like me to change ' .. count[cid] .. ' of your crystal coins into ' .. count[cid] * 100 .. ' platinum coins for you?', cid)
            Topic[cid] = 16
        end
    elseif Topic[cid] == 16 then
        if msgcontains(msg, 'yes') then
            if doPlayerRemoveItem(cid, 2160, count[cid]) then
                npcHandler:say('Here you are.', cid)
                doPlayerAddItem(cid, 2152, count[cid] * 100)
            else
                npcHandler:say('Sorry, you do not have enough crystal coins.', cid)
            end
        else
            npcHandler:say('Well, can I help you with something else?', cid)
        end
        Topic[cid] = nil
    elseif msgcontains(msg, 'change') then
        npcHandler:say('There are three different coin types in Tibia: 100 gold coins equal 1 platinum coin, 100 platinum coins equal 1 crystal coin. So if you\'d like to change 100 gold into 1 platinum, simply say \'{change gold}\' and then \'1 platinum\'.', cid)
        Topic[cid] = nil
    elseif msgcontains(msg, 'bank') then
        npcHandler:say('We can change money for you. You can also access your bank account.', cid)
        Topic[cid] = nil
    end
    return true
end

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


I'm using 0.4

Ty to try bro, but not work

Error when start server on console
Code:
[15:5:39.169] [Error - LuaInterface::loadFile] data/npc/scripts/bank.lua:202: function arguments expected near ')'
[15:5:39.169] [Warning - NpcEvents::NpcEvents] Cannot load script: data/npc/scripts/bank.lua
[15:5:39.169] data/npc/scripts/bank.lua:202: function arguments expected near ')'
[15:5:39.319] [Error - LuaInterface::loadFile] data/npc/scripts/bank.lua:202: function arguments expected near ')'
[15:5:39.319] [Warning - NpcEvents::NpcEvents] Cannot load script: data/npc/scripts/bank.lua
[15:5:39.319] data/npc/scripts/bank.lua:202: function arguments expected near ')'
[15:5:39.605] [Error - LuaInterface::loadFile] data/npc/scripts/bank.lua:202: function arguments expected near ')'
[15:5:39.605] [Warning - NpcEvents::NpcEvents] Cannot load script: data/npc/scripts/bank.lua
[15:5:39.605] data/npc/scripts/bank.lua:202: function arguments expected near ')'
[15:5:39.653] [Error - LuaInterface::loadFile] data/npc/scripts/bank.lua:202: function arguments expected near ')'
[15:5:39.653] [Warning - NpcEvents::NpcEvents] Cannot load script: data/npc/scripts/bank.lua
[15:5:39.653] data/npc/scripts/bank.lua:202: function arguments expected near ')'
[15:5:39.655] [Error - LuaInterface::loadFile] data/npc/scripts/bank.lua:202: function arguments expected near ')'
[15:5:39.655] [Warning - NpcEvents::NpcEvents] Cannot load script: data/npc/scripts/bank.lua
[15:5:39.655] data/npc/scripts/bank.lua:202: function arguments expected near ')'
[15:5:39.693] [Error - LuaInterface::loadFile] data/npc/scripts/bank.lua:202: function arguments expected near ')'
[15:5:39.693] [Warning - NpcEvents::NpcEvents] Cannot load script: data/npc/scripts/bank.lua
[15:5:39.693] data/npc/scripts/bank.lua:202: function arguments expected near ')'
[15:5:39.848] [Error - LuaInterface::loadFile] data/npc/scripts/bank.lua:202: function arguments expected near ')'
[15:5:39.849] [Warning - NpcEvents::NpcEvents] Cannot load script: data/npc/scripts/bank.lua
[15:5:39.849] data/npc/scripts/bank.lua:202: function arguments expected near ')'
[15:5:39.855] [Error - LuaInterface::loadFile] data/npc/scripts/bank.lua:202: function arguments expected near ')'
[15:5:39.855] [Warning - NpcEvents::NpcEvents] Cannot load script: data/npc/scripts/bank.lua
[15:5:39.855] data/npc/scripts/bank.lua:202: function arguments expected near ')'
[15:5:39.990] [Error - LuaInterface::loadFile] data/npc/scripts/bank.lua:202: function arguments expected near ')'
[15:5:39.991] [Warning - NpcEvents::NpcEvents] Cannot load script: data/npc/scripts/bank.lua
[15:5:39.991] data/npc/scripts/bank.lua:202: function arguments expected near ')'
[15:5:40.024] [Error - LuaInterface::loadFile] data/npc/scripts/bank.lua:202: function arguments expected near ')'
[15:5:40.024] [Warning - NpcEvents::NpcEvents] Cannot load script: data/npc/scripts/bank.lua
[15:5:40.024] data/npc/scripts/bank.lua:202: function arguments expected near ')'

I think it's a ( no closed, im looking for it...
 
maybe it was my bad
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local Topic, count, transfer = {}, {}, {}

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 getCount(s)
    local b, e = s:find('%d+')
    return b and e and math.min(4294967295, tonumber(s:sub(b, e))) or -1
end

local function findPlayer(name)
    local resultId = db.storeQuery('SELECT name FROM players WHERE name=' .. db.escapeString(name) .. ' LIMIT 1'), nil
    if resultId == false then
        return
    end
    local r = result.getDataString(resultId, "name")
    result.free(resultId)
    return r
end

local function vocation(name)
    local resultId = db.storeQuery('SELECT vocation FROM players WHERE name=' .. db.escapeString(name) .. ' LIMIT 1'), nil
    if resultId == false then
        return
    end
    local r = result.getDataInt(resultId, "vocation")
    result.free(resultId)
    return r
end

local function getPlayerBiddedMoney(cid)
    local resultId = db.storeQuery('SELECT `bid` FROM `houses` WHERE `highest_bidder`=' .. db.escapeString(getPlayerGUID(cid)) .. ' LIMIT 1')
    if resultId == false then
        return 0
    end
    local r = result.getDataInt(resultId, "bid")
    result.free(resultId)
    return r
end

local function updatePlayerBalance(name, value)
    db.query('UPDATE players SET balance=' .. value .. ' WHERE name=' .. db.escapeString(name) .. ' LIMIT 1')
end

function greet(cid)
    Topic[cid], count[cid], transfer[cid] = nil, nil, nil
    return true
end

function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    elseif msgcontains(msg, 'balance') then
        local bid = getPlayerBiddedMoney(cid)
        if(bid > 0) then
            npcHandler:say('Your account balance is ' .. getPlayerBalance(cid) .. ' gold, ' .. bid .. ' gold is blocked for house auctioned by you.', cid)
        else
            npcHandler:say('Your account balance is ' .. getPlayerBalance(cid) .. ' gold.', cid)
        end
        Topic[cid] = nil
    elseif msgcontains(msg, 'deposit') and msgcontains(msg, 'all') then
        if getPlayerMoney(cid) == 0 then
            npcHandler:say('You don\'t have any gold with you.', cid)
            Topic[cid] = nil
        else
            count[cid] = getPlayerMoney(cid)
            npcHandler:say('Would you really like to deposit ' .. count[cid] .. ' gold?', cid)
            Topic[cid] = 2
        end
    elseif msgcontains(msg, 'deposit') then
        if getCount(msg) == 0 then
            npcHandler:say('You are joking, aren\'t you??', cid)
            Topic[cid] = nil
        elseif getCount(msg) ~= -1 then
            if getPlayerMoney(cid) >= getCount(msg) then
                count[cid] = getCount(msg)
                npcHandler:say('Would you really like to deposit ' .. count[cid] .. ' gold?', cid)
                Topic[cid] = 2
            else
                npcHandler:say('You do not have enough gold.', cid)
                Topic[cid] = nil
            end
        elseif getPlayerMoney(cid) == 0 then
            npcHandler:say('You don\'t have any gold with you.', cid)
            Topic[cid] = nil
        else
            npcHandler:say('Please tell me how much gold it is you would like to deposit.', cid)
            Topic[cid] = 1
        end
    elseif Topic[cid] == 1 then
        if getCount(msg) == -1 then
            npcHandler:say('Please tell me how much gold it is you would like to deposit.', cid)
            Topic[cid] = 1
        elseif getPlayerMoney(cid) >= getCount(msg) then
            count[cid] = getCount(msg)
            npcHandler:say('Would you really like to deposit ' .. count[cid] .. ' gold?', cid)
            Topic[cid] = 2
        else
            npcHandler:say('You do not have enough gold.', cid)
            Topic[cid] = nil
        end
    elseif msgcontains(msg, 'yes') and Topic[cid] == 2 then
        if doPlayerRemoveMoney(cid, count[cid]) then
            doPlayerSetBalance(cid, getPlayerBalance(cid) + count[cid])
            updatePlayerBalance(getPlayerName(cid), getPlayerBalance(cid))
            npcHandler:say('Alright, we have added the amount of ' .. count[cid] .. ' gold to your balance. You can withdraw your money anytime you want to.', cid)
        else
            npcHandler:say('I am inconsolable, but it seems you have lost your gold. I hope you get it back.', cid)
        end
        Topic[cid] = nil
    elseif msgcontains(msg, 'no') and Topic[cid] == 2 then
        npcHandler:say('As you wish. Is there something else I can do for you?', cid)
        Topic[cid] = nil
    elseif msgcontains(msg, 'withdraw') then
        if getCount(msg) == 0 then
            npcHandler:say('Sure, you want nothing you get nothing!', cid)
            Topic[cid] = nil
        elseif getCount(msg) ~= -1 then
            if getPlayerBalance(cid) - getPlayerBiddedMoney(cid) >= getCount(msg) then
                count[cid] = getCount(msg)
                npcHandler:say('Are you sure you wish to withdraw ' .. count[cid] .. ' gold from your bank account?', cid)
                Topic[cid] = 4
            else
                npcHandler:say('There is not enough gold on your account.', cid)
                Topic[cid] = nil
            end
        elseif getPlayerBalance(cid) == 0 then
            npcHandler:say('You don\'t have any money on your bank account.', cid)
            Topic[cid] = nil
        else
            npcHandler:say('Please tell me how much gold you would like to withdraw.', cid)
            Topic[cid] = 3
        end
    elseif Topic[cid] == 3 then
        if getCount(msg) == -1 then
            npcHandler:say('Please tell me how much gold you would like to withdraw.', cid)
            Topic[cid] = 3
        elseif getPlayerBalance(cid) - getPlayerBiddedMoney(cid) >= getCount(msg) then
            count[cid] = getCount(msg)
            npcHandler:say('Are you sure you wish to withdraw ' .. count[cid] .. ' gold from your bank account?', cid)
            Topic[cid] = 4
        else
            npcHandler:say('There is not enough gold on your account.', cid)
            Topic[cid] = nil
        end
    elseif msgcontains(msg, 'yes') and Topic[cid] == 4 then
        if getPlayerBalance(cid) - getPlayerBiddedMoney(cid) >= count[cid] then
            doPlayerAddMoney(cid, count[cid])
            doPlayerSetBalance(cid, getPlayerBalance(cid) - count[cid])
            updatePlayerBalance(getPlayerName(cid), getPlayerBalance(cid))
            npcHandler:say('Here you are, ' .. count[cid] .. ' gold. Please let me know if there is something else I can do for you.', cid)
        else
            npcHandler:say('There is not enough gold on your account.', cid)
        end
        Topic[cid] = nil
    elseif msgcontains(msg, 'no') and Topic[cid] == 4 then
        npcHandler:say('The customer is king! Come back anytime you want to if you wish to withdraw your money.', cid)
        Topic[cid] = nil
    elseif msgcontains(msg, 'transfer') then
        if getCount(msg) == 0 then
            npcHandler:say('Please think about it. Okay?', cid)
            Topic[cid] = nil
        elseif getCount(msg) ~= -1 then
       
            count[cid] = getCount(msg)
            if getPlayerBalance(cid) - getPlayerBiddedMoney(cid) >= count[cid] then
                npcHandler:say('Who would you like to transfer ' .. count[cid] .. ' gold to?', cid)
                Topic[cid] = 6
            else
                npcHandler:say('There is not enough gold on your account.', cid)
                Topic[cid] = nil
            end

        else
            npcHandler:say('Please tell me the amount of gold you would like to transfer.', cid)
            Topic[cid] = 5
        end
    elseif Topic[cid] == 5 then
        if getCount(msg) == -1 then
            npcHandler:say('Please tell me the amount of gold you would like to transfer.', cid)
            Topic[cid] = 5
        else
            count[cid] = getCount(msg)
            if getPlayerBalance(cid) - getPlayerBiddedMoney(cid) >= count[cid] then
                npcHandler:say('Who would you like to transfer ' .. count[cid] .. ' gold to?', cid)
                Topic[cid] = 6
            else
                npcHandler:say('There is not enough gold on your account.', cid)
                Topic[cid] = nil
            end
        end
    elseif Topic[cid] == 6 then
        local v = getPlayerByName(msg)
        if getPlayerBalance(cid) - getPlayerBiddedMoney(cid) >= count[cid] then
            if v and vocation(msg:lower()) > 0 and not isInArray({7, 10}, getPlayerTown(msg:lower)) then
                transfer[cid] = msg
                npcHandler:say('Would you really like to transfer ' .. count[cid] .. ' gold to ' .. getPlayerName(v) .. '?', cid)
                Topic[cid] = 7
            elseif getPlayerGUIDByName(msg:lower()) ~= 0  and vocation(msg:lower()) > 0 and not isInArray({7, 10}, getPlayerTown(msg:lower)) then
                transfer[cid] = msg
                npcHandler:say('Would you really like to transfer ' .. count[cid] .. ' gold to ' .. findPlayer(msg) .. '?', cid)
                Topic[cid] = 7               
            else
                npcHandler:say('This player does not exist on this world or have no vocation .', cid)
                Topic[cid] = nil
            end
        else
            npcHandler:say('There is not enough gold on your account.', cid)
            Topic[cid] = nil
        end
    elseif Topic[cid] == 7 and msgcontains(msg, 'yes') then
        if getPlayerBalance(cid) - getPlayerBiddedMoney(cid) >= count[cid] then
            local v = getPlayerByName(transfer[cid])
            if v then
                doPlayerSetBalance(cid, getPlayerBalance(cid) - count[cid])
                updatePlayerBalance(getPlayerName(cid), getPlayerBalance(cid))
                doPlayerSetBalance(v, getPlayerBalance(v) + count[cid])
                updatePlayerBalance(getPlayerName(v), getPlayerBalance(v))
                npcHandler:say('Very well. You have transferred ' .. count[cid] .. ' gold to ' .. getPlayerName(v) .. '.', cid)
            elseif findPlayer(transfer[cid]):lower() == transfer[cid]:lower() then
                doPlayerSetBalance(cid, getPlayerBalance(cid) - count[cid])
                updatePlayerBalance(getPlayerName(cid), getPlayerBalance(cid))
                db.query('UPDATE players SET balance=balance+' .. count[cid] .. ' WHERE name=' .. db.escapeString(transfer[cid]) .. ' LIMIT 1')
                npcHandler:say('Very well. You have transferred ' .. count[cid] .. ' gold to ' .. findPlayer(transfer[cid]) .. '.', cid)
            else
                npcHandler:say('This player does not exist.', cid)
            end
        else
            npcHandler:say('There is not enough gold on your account.', cid)
        end
        Topic[cid] = nil
    elseif Topic[cid] == 7 and msgcontains(msg, 'no') then
        npcHandler:say('Alright, is there something else I can do for you?', cid)
        Topic[cid] = nil
    elseif msgcontains(msg, 'change gold') then
        npcHandler:say('How many platinum coins would you like to get?', cid)
        Topic[cid] = 8
    elseif Topic[cid] == 8 then
        if getCount(msg) < 1 then
            npcHandler:say('Hmm, can I help you with something else?', cid)
            Topic[cid] = nil
        else
            count[cid] = math.min(500, getCount(msg))
            npcHandler:say('So you would like me to change ' .. count[cid] * 100 .. ' of your gold coins into ' .. count[cid] .. ' platinum coins?', cid)
            Topic[cid] = 9
        end
    elseif Topic[cid] == 9 then
        if msgcontains(msg, 'yes') then
            if doPlayerRemoveItem(cid, 2148, count[cid] * 100) then
                npcHandler:say('Here you are.', cid)
                doPlayerAddItem(cid, 2152, count[cid])
            else
                npcHandler:say('Sorry, you do not have enough gold coins.', cid)
            end
        else
            npcHandler:say('Well, can I help you with something else?', cid)
        end
        Topic[cid] = nil
    elseif msgcontains(msg, 'change platinum') then
        npcHandler:say('Would you like to change your platinum coins into gold or crystal?', cid)
        Topic[cid] = 10
    elseif Topic[cid] == 10 then
        if msgcontains(msg, 'gold') then
            npcHandler:say('How many platinum coins would you like to change into gold?', cid)
            Topic[cid] = 11
        elseif msgcontains(msg, 'crystal') then
            npcHandler:say('How many crystal coins would you like to get?', cid)
            Topic[cid] = 13
        else
            npcHandler:say('Well, can I help you with something else?', cid)
            Topic[cid] = nil
        end
    elseif Topic[cid] == 11 then
        if getCount(msg) < 1 then
            npcHandler:say('Hmm, can I help you with something else?', cid)
            Topic[cid] = nil
        else
            count[cid] = math.min(500, getCount(msg))
            npcHandler:say('So you would like me to change ' .. count[cid] .. ' of your platinum coins into ' .. count[cid] * 100 .. ' gold coins for you?', cid)
            Topic[cid] = 12
        end
    elseif Topic[cid] == 12 then
        if msgcontains(msg, 'yes') then
            if doPlayerRemoveItem(cid, 2152, count[cid]) then
                npcHandler:say('Here you are.', cid)
                doPlayerAddItem(cid, 2148, count[cid] * 100)
            else
                npcHandler:say('Sorry, you do not have enough platinum coins.', cid)
            end
        else
            npcHandler:say('Well, can I help you with something else?', cid)
        end
        Topic[cid] = nil
    elseif Topic[cid] == 13 then
        if getCount(msg) < 1 then
            npcHandler:say('Hmm, can I help you with something else?', cid)
            Topic[cid] = nil
        else
            count[cid] = math.min(500, getCount(msg))
            npcHandler:say('So you would like me to change ' .. count[cid] * 100 .. ' of your platinum coins into ' .. count[cid] .. ' crystal coins for you?', cid)
            Topic[cid] = 14
        end
    elseif Topic[cid] == 14 then
        if msgcontains(msg, 'yes') then
            if doPlayerRemoveItem(cid, 2152, count[cid] * 100) then
                npcHandler:say('Here you are.', cid)
                doPlayerAddItem(cid, 2160, count[cid])
            else
                npcHandler:say('Sorry, you do not have enough platinum coins.', cid)
            end
        else
            npcHandler:say('Well, can I help you with something else?', cid)
        end
        Topic[cid] = nil
    elseif msgcontains(msg, 'change crystal') then
        npcHandler:say('How many crystal coins would you like to change into platinum?', cid)
        Topic[cid] = 15
    elseif Topic[cid] == 15 then
        if getCount(msg) == -1 or getCount(msg) == 0 then
            npcHandler:say('Hmm, can I help you with something else?', cid)
            Topic[cid] = nil
        else
            count[cid] = math.min(500, getCount(msg))
            npcHandler:say('So you would like me to change ' .. count[cid] .. ' of your crystal coins into ' .. count[cid] * 100 .. ' platinum coins for you?', cid)
            Topic[cid] = 16
        end
    elseif Topic[cid] == 16 then
        if msgcontains(msg, 'yes') then
            if doPlayerRemoveItem(cid, 2160, count[cid]) then
                npcHandler:say('Here you are.', cid)
                doPlayerAddItem(cid, 2152, count[cid] * 100)
            else
                npcHandler:say('Sorry, you do not have enough crystal coins.', cid)
            end
        else
            npcHandler:say('Well, can I help you with something else?', cid)
        end
        Topic[cid] = nil
    elseif msgcontains(msg, 'change') then
        npcHandler:say('There are three different coin types in Tibia: 100 gold coins equal 1 platinum coin, 100 platinum coins equal 1 crystal coin. So if you\'d like to change 100 gold into 1 platinum, simply say \'{change gold}\' and then \'1 platinum\'.', cid)
        Topic[cid] = nil
    elseif msgcontains(msg, 'bank') then
        npcHandler:say('We can change money for you. You can also access your bank account.', cid)
        Topic[cid] = nil
    end
    return true
end

npcHandler:setCallback(CALLBACK_GREET, greet)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
maybe it was my bad
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local Topic, count, transfer = {}, {}, {}

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 getCount(s)
    local b, e = s:find('%d+')
    return b and e and math.min(4294967295, tonumber(s:sub(b, e))) or -1
end

local function findPlayer(name)
    local resultId = db.storeQuery('SELECT name FROM players WHERE name=' .. db.escapeString(name) .. ' LIMIT 1'), nil
    if resultId == false then
        return
    end
    local r = result.getDataString(resultId, "name")
    result.free(resultId)
    return r
end

local function vocation(name)
    local resultId = db.storeQuery('SELECT vocation FROM players WHERE name=' .. db.escapeString(name) .. ' LIMIT 1'), nil
    if resultId == false then
        return
    end
    local r = result.getDataInt(resultId, "vocation")
    result.free(resultId)
    return r
end

local function getPlayerBiddedMoney(cid)
    local resultId = db.storeQuery('SELECT `bid` FROM `houses` WHERE `highest_bidder`=' .. db.escapeString(getPlayerGUID(cid)) .. ' LIMIT 1')
    if resultId == false then
        return 0
    end
    local r = result.getDataInt(resultId, "bid")
    result.free(resultId)
    return r
end

local function updatePlayerBalance(name, value)
    db.query('UPDATE players SET balance=' .. value .. ' WHERE name=' .. db.escapeString(name) .. ' LIMIT 1')
end

function greet(cid)
    Topic[cid], count[cid], transfer[cid] = nil, nil, nil
    return true
end

function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    elseif msgcontains(msg, 'balance') then
        local bid = getPlayerBiddedMoney(cid)
        if(bid > 0) then
            npcHandler:say('Your account balance is ' .. getPlayerBalance(cid) .. ' gold, ' .. bid .. ' gold is blocked for house auctioned by you.', cid)
        else
            npcHandler:say('Your account balance is ' .. getPlayerBalance(cid) .. ' gold.', cid)
        end
        Topic[cid] = nil
    elseif msgcontains(msg, 'deposit') and msgcontains(msg, 'all') then
        if getPlayerMoney(cid) == 0 then
            npcHandler:say('You don\'t have any gold with you.', cid)
            Topic[cid] = nil
        else
            count[cid] = getPlayerMoney(cid)
            npcHandler:say('Would you really like to deposit ' .. count[cid] .. ' gold?', cid)
            Topic[cid] = 2
        end
    elseif msgcontains(msg, 'deposit') then
        if getCount(msg) == 0 then
            npcHandler:say('You are joking, aren\'t you??', cid)
            Topic[cid] = nil
        elseif getCount(msg) ~= -1 then
            if getPlayerMoney(cid) >= getCount(msg) then
                count[cid] = getCount(msg)
                npcHandler:say('Would you really like to deposit ' .. count[cid] .. ' gold?', cid)
                Topic[cid] = 2
            else
                npcHandler:say('You do not have enough gold.', cid)
                Topic[cid] = nil
            end
        elseif getPlayerMoney(cid) == 0 then
            npcHandler:say('You don\'t have any gold with you.', cid)
            Topic[cid] = nil
        else
            npcHandler:say('Please tell me how much gold it is you would like to deposit.', cid)
            Topic[cid] = 1
        end
    elseif Topic[cid] == 1 then
        if getCount(msg) == -1 then
            npcHandler:say('Please tell me how much gold it is you would like to deposit.', cid)
            Topic[cid] = 1
        elseif getPlayerMoney(cid) >= getCount(msg) then
            count[cid] = getCount(msg)
            npcHandler:say('Would you really like to deposit ' .. count[cid] .. ' gold?', cid)
            Topic[cid] = 2
        else
            npcHandler:say('You do not have enough gold.', cid)
            Topic[cid] = nil
        end
    elseif msgcontains(msg, 'yes') and Topic[cid] == 2 then
        if doPlayerRemoveMoney(cid, count[cid]) then
            doPlayerSetBalance(cid, getPlayerBalance(cid) + count[cid])
            updatePlayerBalance(getPlayerName(cid), getPlayerBalance(cid))
            npcHandler:say('Alright, we have added the amount of ' .. count[cid] .. ' gold to your balance. You can withdraw your money anytime you want to.', cid)
        else
            npcHandler:say('I am inconsolable, but it seems you have lost your gold. I hope you get it back.', cid)
        end
        Topic[cid] = nil
    elseif msgcontains(msg, 'no') and Topic[cid] == 2 then
        npcHandler:say('As you wish. Is there something else I can do for you?', cid)
        Topic[cid] = nil
    elseif msgcontains(msg, 'withdraw') then
        if getCount(msg) == 0 then
            npcHandler:say('Sure, you want nothing you get nothing!', cid)
            Topic[cid] = nil
        elseif getCount(msg) ~= -1 then
            if getPlayerBalance(cid) - getPlayerBiddedMoney(cid) >= getCount(msg) then
                count[cid] = getCount(msg)
                npcHandler:say('Are you sure you wish to withdraw ' .. count[cid] .. ' gold from your bank account?', cid)
                Topic[cid] = 4
            else
                npcHandler:say('There is not enough gold on your account.', cid)
                Topic[cid] = nil
            end
        elseif getPlayerBalance(cid) == 0 then
            npcHandler:say('You don\'t have any money on your bank account.', cid)
            Topic[cid] = nil
        else
            npcHandler:say('Please tell me how much gold you would like to withdraw.', cid)
            Topic[cid] = 3
        end
    elseif Topic[cid] == 3 then
        if getCount(msg) == -1 then
            npcHandler:say('Please tell me how much gold you would like to withdraw.', cid)
            Topic[cid] = 3
        elseif getPlayerBalance(cid) - getPlayerBiddedMoney(cid) >= getCount(msg) then
            count[cid] = getCount(msg)
            npcHandler:say('Are you sure you wish to withdraw ' .. count[cid] .. ' gold from your bank account?', cid)
            Topic[cid] = 4
        else
            npcHandler:say('There is not enough gold on your account.', cid)
            Topic[cid] = nil
        end
    elseif msgcontains(msg, 'yes') and Topic[cid] == 4 then
        if getPlayerBalance(cid) - getPlayerBiddedMoney(cid) >= count[cid] then
            doPlayerAddMoney(cid, count[cid])
            doPlayerSetBalance(cid, getPlayerBalance(cid) - count[cid])
            updatePlayerBalance(getPlayerName(cid), getPlayerBalance(cid))
            npcHandler:say('Here you are, ' .. count[cid] .. ' gold. Please let me know if there is something else I can do for you.', cid)
        else
            npcHandler:say('There is not enough gold on your account.', cid)
        end
        Topic[cid] = nil
    elseif msgcontains(msg, 'no') and Topic[cid] == 4 then
        npcHandler:say('The customer is king! Come back anytime you want to if you wish to withdraw your money.', cid)
        Topic[cid] = nil
    elseif msgcontains(msg, 'transfer') then
        if getCount(msg) == 0 then
            npcHandler:say('Please think about it. Okay?', cid)
            Topic[cid] = nil
        elseif getCount(msg) ~= -1 then
      
            count[cid] = getCount(msg)
            if getPlayerBalance(cid) - getPlayerBiddedMoney(cid) >= count[cid] then
                npcHandler:say('Who would you like to transfer ' .. count[cid] .. ' gold to?', cid)
                Topic[cid] = 6
            else
                npcHandler:say('There is not enough gold on your account.', cid)
                Topic[cid] = nil
            end

        else
            npcHandler:say('Please tell me the amount of gold you would like to transfer.', cid)
            Topic[cid] = 5
        end
    elseif Topic[cid] == 5 then
        if getCount(msg) == -1 then
            npcHandler:say('Please tell me the amount of gold you would like to transfer.', cid)
            Topic[cid] = 5
        else
            count[cid] = getCount(msg)
            if getPlayerBalance(cid) - getPlayerBiddedMoney(cid) >= count[cid] then
                npcHandler:say('Who would you like to transfer ' .. count[cid] .. ' gold to?', cid)
                Topic[cid] = 6
            else
                npcHandler:say('There is not enough gold on your account.', cid)
                Topic[cid] = nil
            end
        end
    elseif Topic[cid] == 6 then
        local v = getPlayerByName(msg)
        if getPlayerBalance(cid) - getPlayerBiddedMoney(cid) >= count[cid] then
            if v and vocation(msg:lower()) > 0 and not isInArray({7, 10}, getPlayerTown(msg:lower)) then
                transfer[cid] = msg
                npcHandler:say('Would you really like to transfer ' .. count[cid] .. ' gold to ' .. getPlayerName(v) .. '?', cid)
                Topic[cid] = 7
            elseif getPlayerGUIDByName(msg:lower()) ~= 0  and vocation(msg:lower()) > 0 and not isInArray({7, 10}, getPlayerTown(msg:lower)) then
                transfer[cid] = msg
                npcHandler:say('Would you really like to transfer ' .. count[cid] .. ' gold to ' .. findPlayer(msg) .. '?', cid)
                Topic[cid] = 7              
            else
                npcHandler:say('This player does not exist on this world or have no vocation .', cid)
                Topic[cid] = nil
            end
        else
            npcHandler:say('There is not enough gold on your account.', cid)
            Topic[cid] = nil
        end
    elseif Topic[cid] == 7 and msgcontains(msg, 'yes') then
        if getPlayerBalance(cid) - getPlayerBiddedMoney(cid) >= count[cid] then
            local v = getPlayerByName(transfer[cid])
            if v then
                doPlayerSetBalance(cid, getPlayerBalance(cid) - count[cid])
                updatePlayerBalance(getPlayerName(cid), getPlayerBalance(cid))
                doPlayerSetBalance(v, getPlayerBalance(v) + count[cid])
                updatePlayerBalance(getPlayerName(v), getPlayerBalance(v))
                npcHandler:say('Very well. You have transferred ' .. count[cid] .. ' gold to ' .. getPlayerName(v) .. '.', cid)
            elseif findPlayer(transfer[cid]):lower() == transfer[cid]:lower() then
                doPlayerSetBalance(cid, getPlayerBalance(cid) - count[cid])
                updatePlayerBalance(getPlayerName(cid), getPlayerBalance(cid))
                db.query('UPDATE players SET balance=balance+' .. count[cid] .. ' WHERE name=' .. db.escapeString(transfer[cid]) .. ' LIMIT 1')
                npcHandler:say('Very well. You have transferred ' .. count[cid] .. ' gold to ' .. findPlayer(transfer[cid]) .. '.', cid)
            else
                npcHandler:say('This player does not exist.', cid)
            end
        else
            npcHandler:say('There is not enough gold on your account.', cid)
        end
        Topic[cid] = nil
    elseif Topic[cid] == 7 and msgcontains(msg, 'no') then
        npcHandler:say('Alright, is there something else I can do for you?', cid)
        Topic[cid] = nil
    elseif msgcontains(msg, 'change gold') then
        npcHandler:say('How many platinum coins would you like to get?', cid)
        Topic[cid] = 8
    elseif Topic[cid] == 8 then
        if getCount(msg) < 1 then
            npcHandler:say('Hmm, can I help you with something else?', cid)
            Topic[cid] = nil
        else
            count[cid] = math.min(500, getCount(msg))
            npcHandler:say('So you would like me to change ' .. count[cid] * 100 .. ' of your gold coins into ' .. count[cid] .. ' platinum coins?', cid)
            Topic[cid] = 9
        end
    elseif Topic[cid] == 9 then
        if msgcontains(msg, 'yes') then
            if doPlayerRemoveItem(cid, 2148, count[cid] * 100) then
                npcHandler:say('Here you are.', cid)
                doPlayerAddItem(cid, 2152, count[cid])
            else
                npcHandler:say('Sorry, you do not have enough gold coins.', cid)
            end
        else
            npcHandler:say('Well, can I help you with something else?', cid)
        end
        Topic[cid] = nil
    elseif msgcontains(msg, 'change platinum') then
        npcHandler:say('Would you like to change your platinum coins into gold or crystal?', cid)
        Topic[cid] = 10
    elseif Topic[cid] == 10 then
        if msgcontains(msg, 'gold') then
            npcHandler:say('How many platinum coins would you like to change into gold?', cid)
            Topic[cid] = 11
        elseif msgcontains(msg, 'crystal') then
            npcHandler:say('How many crystal coins would you like to get?', cid)
            Topic[cid] = 13
        else
            npcHandler:say('Well, can I help you with something else?', cid)
            Topic[cid] = nil
        end
    elseif Topic[cid] == 11 then
        if getCount(msg) < 1 then
            npcHandler:say('Hmm, can I help you with something else?', cid)
            Topic[cid] = nil
        else
            count[cid] = math.min(500, getCount(msg))
            npcHandler:say('So you would like me to change ' .. count[cid] .. ' of your platinum coins into ' .. count[cid] * 100 .. ' gold coins for you?', cid)
            Topic[cid] = 12
        end
    elseif Topic[cid] == 12 then
        if msgcontains(msg, 'yes') then
            if doPlayerRemoveItem(cid, 2152, count[cid]) then
                npcHandler:say('Here you are.', cid)
                doPlayerAddItem(cid, 2148, count[cid] * 100)
            else
                npcHandler:say('Sorry, you do not have enough platinum coins.', cid)
            end
        else
            npcHandler:say('Well, can I help you with something else?', cid)
        end
        Topic[cid] = nil
    elseif Topic[cid] == 13 then
        if getCount(msg) < 1 then
            npcHandler:say('Hmm, can I help you with something else?', cid)
            Topic[cid] = nil
        else
            count[cid] = math.min(500, getCount(msg))
            npcHandler:say('So you would like me to change ' .. count[cid] * 100 .. ' of your platinum coins into ' .. count[cid] .. ' crystal coins for you?', cid)
            Topic[cid] = 14
        end
    elseif Topic[cid] == 14 then
        if msgcontains(msg, 'yes') then
            if doPlayerRemoveItem(cid, 2152, count[cid] * 100) then
                npcHandler:say('Here you are.', cid)
                doPlayerAddItem(cid, 2160, count[cid])
            else
                npcHandler:say('Sorry, you do not have enough platinum coins.', cid)
            end
        else
            npcHandler:say('Well, can I help you with something else?', cid)
        end
        Topic[cid] = nil
    elseif msgcontains(msg, 'change crystal') then
        npcHandler:say('How many crystal coins would you like to change into platinum?', cid)
        Topic[cid] = 15
    elseif Topic[cid] == 15 then
        if getCount(msg) == -1 or getCount(msg) == 0 then
            npcHandler:say('Hmm, can I help you with something else?', cid)
            Topic[cid] = nil
        else
            count[cid] = math.min(500, getCount(msg))
            npcHandler:say('So you would like me to change ' .. count[cid] .. ' of your crystal coins into ' .. count[cid] * 100 .. ' platinum coins for you?', cid)
            Topic[cid] = 16
        end
    elseif Topic[cid] == 16 then
        if msgcontains(msg, 'yes') then
            if doPlayerRemoveItem(cid, 2160, count[cid]) then
                npcHandler:say('Here you are.', cid)
                doPlayerAddItem(cid, 2152, count[cid] * 100)
            else
                npcHandler:say('Sorry, you do not have enough crystal coins.', cid)
            end
        else
            npcHandler:say('Well, can I help you with something else?', cid)
        end
        Topic[cid] = nil
    elseif msgcontains(msg, 'change') then
        npcHandler:say('There are three different coin types in Tibia: 100 gold coins equal 1 platinum coin, 100 platinum coins equal 1 crystal coin. So if you\'d like to change 100 gold into 1 platinum, simply say \'{change gold}\' and then \'1 platinum\'.', cid)
        Topic[cid] = nil
    elseif msgcontains(msg, 'bank') then
        npcHandler:say('We can change money for you. You can also access your bank account.', cid)
        Topic[cid] = nil
    end
    return true
end

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


Got errors too bro

Code:
[15:9:37.833] [Error - LuaInterface::loadFile] data/npc/scripts/bank.lua:202: function arguments expected near ')'
[15:9:37.833] [Warning - NpcEvents::NpcEvents] Cannot load script: data/npc/scripts/bank.lua
[15:9:37.833] data/npc/scripts/bank.lua:202: function arguments expected near ')'
[15:9:37.858] [Error - LuaInterface::loadFile] data/npc/scripts/bank.lua:202: function arguments expected near ')'
[15:9:37.858] [Warning - NpcEvents::NpcEvents] Cannot load script: data/npc/scripts/bank.lua
[15:9:37.858] data/npc/scripts/bank.lua:202: function arguments expected near ')'
[15:9:37.916] [Error - LuaInterface::loadFile] data/npc/scripts/bank.lua:202: function arguments expected near ')'
[15:9:37.916] [Warning - NpcEvents::NpcEvents] Cannot load script: data/npc/scripts/bank.lua
[15:9:37.916] data/npc/scripts/bank.lua:202: function arguments expected near ')'
[15:9:37.938] [Error - LuaInterface::loadFile] data/npc/scripts/bank.lua:202: function arguments expected near ')'
[15:9:37.938] [Warning - NpcEvents::NpcEvents] Cannot load script: data/npc/scripts/bank.lua
[15:9:37.938] data/npc/scripts/bank.lua:202: function arguments expected near ')'
[15:9:37.939] [Error - LuaInterface::loadFile] data/npc/scripts/bank.lua:202: function arguments expected near ')'
[15:9:37.939] [Warning - NpcEvents::NpcEvents] Cannot load script: data/npc/scripts/bank.lua
[15:9:37.940] data/npc/scripts/bank.lua:202: function arguments expected near ')'
[15:9:37.942] [Error - LuaInterface::loadFile] data/npc/scripts/bank.lua:202: function arguments expected near ')'
[15:9:37.942] [Warning - NpcEvents::NpcEvents] Cannot load script: data/npc/scripts/bank.lua
[15:9:37.942] data/npc/scripts/bank.lua:202: function arguments expected near ')'
[15:9:37.988] [Error - LuaInterface::loadFile] data/npc/scripts/bank.lua:202: function arguments expected near ')'
[15:9:37.988] [Warning - NpcEvents::NpcEvents] Cannot load script: data/npc/scripts/bank.lua
[15:9:37.988] data/npc/scripts/bank.lua:202: function arguments expected near ')'
[15:9:37.992] [Error - LuaInterface::loadFile] data/npc/scripts/bank.lua:202: function arguments expected near ')'
[15:9:37.992] [Warning - NpcEvents::NpcEvents] Cannot load script: data/npc/scripts/bank.lua
[15:9:37.992] data/npc/scripts/bank.lua:202: function arguments expected near ')'
[15:9:38.014] [Error - LuaInterface::loadFile] data/npc/scripts/bank.lua:202: function arguments expected near ')'
[15:9:38.014] [Warning - NpcEvents::NpcEvents] Cannot load script: data/npc/scripts/bank.lua
[15:9:38.014] data/npc/scripts/bank.lua:202: function arguments expected near ')'
[15:9:38.030] [Error - LuaInterface::loadFile] data/npc/scripts/bank.lua:202: function arguments expected near ')'
[15:9:38.030] [Warning - NpcEvents::NpcEvents] Cannot load script: data/npc/scripts/bank.lua
[15:9:38.030] data/npc/scripts/bank.lua:202: function arguments expected near ')'
 
Learn to read errors.
Line 202:
if v and vocation(msg:lower()) > 0 and not isInArray({7, 10}, getPlayerTown(msg:lower)) then
msg:lower is not a function
msg:lower() is a function.

I've tried, your was right...

But could you guys help me?

Idk, but just townid 7 is work... Id 9 is not...
If player is from townid 7 its block, if is from town id 9 no block transfer

Why?

Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local Topic, count, transfer = {}, {}, {}

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 getCount(s)
  local b, e = s:find('%d+')
  return b and e and math.min(4294967295, tonumber(s:sub(b, e))) or -1
end

local function findPlayer(name)
  local resultId = db.storeQuery('SELECT name FROM players WHERE name=' .. db.escapeString(name) .. ' LIMIT 1'), nil
  if resultId == false then
  return
  end
  local r = result.getDataString(resultId, "name")
  result.free(resultId)
  return r
end

local function vocation(name)
  local resultId = db.storeQuery('SELECT vocation FROM players WHERE name=' .. db.escapeString(name) .. ' LIMIT 1'), nil
  if resultId == false then
  return
  end
  local r = result.getDataInt(resultId, "vocation")
  result.free(resultId)
  return r
end

local function getPlayerBiddedMoney(cid)
  local resultId = db.storeQuery('SELECT `bid` FROM `houses` WHERE `highest_bidder`=' .. db.escapeString(getPlayerGUID(cid)) .. ' LIMIT 1')
  if resultId == false then
  return 0
  end
  local r = result.getDataInt(resultId, "bid")
  result.free(resultId)
  return r
end

local function updatePlayerBalance(name, value)
  db.query('UPDATE players SET balance=' .. value .. ' WHERE name=' .. db.escapeString(name) .. ' LIMIT 1')
end

function greet(cid)
  Topic[cid], count[cid], transfer[cid] = nil, nil, nil
  return true
end

function creatureSayCallback(cid, type, msg)
  if not npcHandler:isFocused(cid) then
  return false
  elseif msgcontains(msg, 'balance') then
  local bid = getPlayerBiddedMoney(cid)
  if(bid > 0) then
  npcHandler:say('Your account balance is ' .. getPlayerBalance(cid) .. ' gold, ' .. bid .. ' gold is blocked for house auctioned by you.', cid)
  else
  npcHandler:say('Your account balance is ' .. getPlayerBalance(cid) .. ' gold.', cid)
  end
  Topic[cid] = nil
  elseif msgcontains(msg, 'deposit') and msgcontains(msg, 'all') then
  if getPlayerMoney(cid) == 0 then
  npcHandler:say('You don\'t have any gold with you.', cid)
  Topic[cid] = nil
  else
  count[cid] = getPlayerMoney(cid)
  npcHandler:say('Would you really like to deposit ' .. count[cid] .. ' gold?', cid)
  Topic[cid] = 2
  end
  elseif msgcontains(msg, 'deposit') then
  if getCount(msg) == 0 then
  npcHandler:say('You are joking, aren\'t you??', cid)
  Topic[cid] = nil
  elseif getCount(msg) ~= -1 then
  if getPlayerMoney(cid) >= getCount(msg) then
  count[cid] = getCount(msg)
  npcHandler:say('Would you really like to deposit ' .. count[cid] .. ' gold?', cid)
  Topic[cid] = 2
  else
  npcHandler:say('You do not have enough gold.', cid)
  Topic[cid] = nil
  end
  elseif getPlayerMoney(cid) == 0 then
  npcHandler:say('You don\'t have any gold with you.', cid)
  Topic[cid] = nil
  else
  npcHandler:say('Please tell me how much gold it is you would like to deposit.', cid)
  Topic[cid] = 1
  end
  elseif Topic[cid] == 1 then
  if getCount(msg) == -1 then
  npcHandler:say('Please tell me how much gold it is you would like to deposit.', cid)
  Topic[cid] = 1
  elseif getPlayerMoney(cid) >= getCount(msg) then
  count[cid] = getCount(msg)
  npcHandler:say('Would you really like to deposit ' .. count[cid] .. ' gold?', cid)
  Topic[cid] = 2
  else
  npcHandler:say('You do not have enough gold.', cid)
  Topic[cid] = nil
  end
  elseif msgcontains(msg, 'yes') and Topic[cid] == 2 then
  if doPlayerRemoveMoney(cid, count[cid]) then
  doPlayerSetBalance(cid, getPlayerBalance(cid) + count[cid])
  updatePlayerBalance(getPlayerName(cid), getPlayerBalance(cid))
  npcHandler:say('Alright, we have added the amount of ' .. count[cid] .. ' gold to your balance. You can withdraw your money anytime you want to.', cid)
  else
  npcHandler:say('I am inconsolable, but it seems you have lost your gold. I hope you get it back.', cid)
  end
  Topic[cid] = nil
  elseif msgcontains(msg, 'no') and Topic[cid] == 2 then
  npcHandler:say('As you wish. Is there something else I can do for you?', cid)
  Topic[cid] = nil
  elseif msgcontains(msg, 'withdraw') then
  if getCount(msg) == 0 then
  npcHandler:say('Sure, you want nothing you get nothing!', cid)
  Topic[cid] = nil
  elseif getCount(msg) ~= -1 then
  if getPlayerBalance(cid) - getPlayerBiddedMoney(cid) >= getCount(msg) then
  count[cid] = getCount(msg)
  npcHandler:say('Are you sure you wish to withdraw ' .. count[cid] .. ' gold from your bank account?', cid)
  Topic[cid] = 4
  else
  npcHandler:say('There is not enough gold on your account.', cid)
  Topic[cid] = nil
  end
  elseif getPlayerBalance(cid) == 0 then
  npcHandler:say('You don\'t have any money on your bank account.', cid)
  Topic[cid] = nil
  else
  npcHandler:say('Please tell me how much gold you would like to withdraw.', cid)
  Topic[cid] = 3
  end
  elseif Topic[cid] == 3 then
  if getCount(msg) == -1 then
  npcHandler:say('Please tell me how much gold you would like to withdraw.', cid)
  Topic[cid] = 3
  elseif getPlayerBalance(cid) - getPlayerBiddedMoney(cid) >= getCount(msg) then
  count[cid] = getCount(msg)
  npcHandler:say('Are you sure you wish to withdraw ' .. count[cid] .. ' gold from your bank account?', cid)
  Topic[cid] = 4
  else
  npcHandler:say('There is not enough gold on your account.', cid)
  Topic[cid] = nil
  end
  elseif msgcontains(msg, 'yes') and Topic[cid] == 4 then
  if getPlayerBalance(cid) - getPlayerBiddedMoney(cid) >= count[cid] then
  doPlayerAddMoney(cid, count[cid])
  doPlayerSetBalance(cid, getPlayerBalance(cid) - count[cid])
  updatePlayerBalance(getPlayerName(cid), getPlayerBalance(cid))
  npcHandler:say('Here you are, ' .. count[cid] .. ' gold. Please let me know if there is something else I can do for you.', cid)
  else
  npcHandler:say('There is not enough gold on your account.', cid)
  end
  Topic[cid] = nil
  elseif msgcontains(msg, 'no') and Topic[cid] == 4 then
  npcHandler:say('The customer is king! Come back anytime you want to if you wish to withdraw your money.', cid)
  Topic[cid] = nil
  elseif msgcontains(msg, 'transfer') then
  if getCount(msg) == 0 then
  npcHandler:say('Please think about it. Okay?', cid)
  Topic[cid] = nil
  elseif getCount(msg) ~= -1 then
  
  count[cid] = getCount(msg)
  if getPlayerBalance(cid) - getPlayerBiddedMoney(cid) >= count[cid] then
  npcHandler:say('Who would you like to transfer ' .. count[cid] .. ' gold to?', cid)
  Topic[cid] = 6
  else
  npcHandler:say('There is not enough gold on your account.', cid)
  Topic[cid] = nil
  end

  else
  npcHandler:say('Please tell me the amount of gold you would like to transfer.', cid)
  Topic[cid] = 5
  end
  elseif Topic[cid] == 5 then
  if getCount(msg) == -1 then
  npcHandler:say('Please tell me the amount of gold you would like to transfer.', cid)
  Topic[cid] = 5
  else
  count[cid] = getCount(msg)
  if getPlayerBalance(cid) - getPlayerBiddedMoney(cid) >= count[cid] then
  npcHandler:say('Who would you like to transfer ' .. count[cid] .. ' gold to?', cid)
  Topic[cid] = 6
  else
  npcHandler:say('There is not enough gold on your account.', cid)
  Topic[cid] = nil
  end
  end
  elseif Topic[cid] == 6 then
  local v = getPlayerByName(msg)
  if getPlayerBalance(cid) - getPlayerBiddedMoney(cid) >= count[cid] then
  if v and vocation(msg:lower()) > 0 and not isInArray({7, 9}, getPlayerTown(msg:lower())) then
  transfer[cid] = msg
  npcHandler:say('Would you really like to transfer ' .. count[cid] .. ' gold to ' .. getPlayerName(v) .. '?', cid)
  Topic[cid] = 7
  elseif getPlayerGUIDByName(msg:lower()) ~= 0  and vocation(msg:lower()) > 0 and not isInArray({7, 9}, getPlayerTown(msg:lower())) then
  transfer[cid] = msg
  npcHandler:say('Would you really like to transfer ' .. count[cid] .. ' gold to ' .. findPlayer(msg) .. '?', cid)
  Topic[cid] = 7  
  else
  npcHandler:say('This player does not exist on this world or is from Rookgaardia/Dawn Hills.', cid)
  Topic[cid] = nil
  end
  else
  npcHandler:say('There is not enough gold on your account.', cid)
  Topic[cid] = nil
  end
  elseif Topic[cid] == 7 and msgcontains(msg, 'yes') then
  if getPlayerBalance(cid) - getPlayerBiddedMoney(cid) >= count[cid] then
  local v = getPlayerByName(transfer[cid])
  if v then
  doPlayerSetBalance(cid, getPlayerBalance(cid) - count[cid])
  updatePlayerBalance(getPlayerName(cid), getPlayerBalance(cid))
  doPlayerSetBalance(v, getPlayerBalance(v) + count[cid])
  updatePlayerBalance(getPlayerName(v), getPlayerBalance(v))
  npcHandler:say('Very well. You have transferred ' .. count[cid] .. ' gold to ' .. getPlayerName(v) .. '.', cid)
  elseif findPlayer(transfer[cid]):lower() == transfer[cid]:lower() then
  doPlayerSetBalance(cid, getPlayerBalance(cid) - count[cid])
  updatePlayerBalance(getPlayerName(cid), getPlayerBalance(cid))
  db.query('UPDATE players SET balance=balance+' .. count[cid] .. ' WHERE name=' .. db.escapeString(transfer[cid]) .. ' LIMIT 1')
  npcHandler:say('Very well. You have transferred ' .. count[cid] .. ' gold to ' .. findPlayer(transfer[cid]) .. '.', cid)
  else
  npcHandler:say('This player does not exist.', cid)
  end
  else
  npcHandler:say('There is not enough gold on your account.', cid)
  end
  Topic[cid] = nil
  elseif Topic[cid] == 7 and msgcontains(msg, 'no') then
  npcHandler:say('Alright, is there something else I can do for you?', cid)
  Topic[cid] = nil
  elseif msgcontains(msg, 'change gold') then
  npcHandler:say('How many platinum coins would you like to get?', cid)
  Topic[cid] = 8
  elseif Topic[cid] == 8 then
  if getCount(msg) < 1 then
  npcHandler:say('Hmm, can I help you with something else?', cid)
  Topic[cid] = nil
  else
  count[cid] = math.min(500, getCount(msg))
  npcHandler:say('So you would like me to change ' .. count[cid] * 100 .. ' of your gold coins into ' .. count[cid] .. ' platinum coins?', cid)
  Topic[cid] = 9
  end
  elseif Topic[cid] == 9 then
  if msgcontains(msg, 'yes') then
  if doPlayerRemoveItem(cid, 2148, count[cid] * 100) then
  npcHandler:say('Here you are.', cid)
  doPlayerAddItem(cid, 2152, count[cid])
  else
  npcHandler:say('Sorry, you do not have enough gold coins.', cid)
  end
  else
  npcHandler:say('Well, can I help you with something else?', cid)
  end
  Topic[cid] = nil
  elseif msgcontains(msg, 'change platinum') then
  npcHandler:say('Would you like to change your platinum coins into gold or crystal?', cid)
  Topic[cid] = 10
  elseif Topic[cid] == 10 then
  if msgcontains(msg, 'gold') then
  npcHandler:say('How many platinum coins would you like to change into gold?', cid)
  Topic[cid] = 11
  elseif msgcontains(msg, 'crystal') then
  npcHandler:say('How many crystal coins would you like to get?', cid)
  Topic[cid] = 13
  else
  npcHandler:say('Well, can I help you with something else?', cid)
  Topic[cid] = nil
  end
  elseif Topic[cid] == 11 then
  if getCount(msg) < 1 then
  npcHandler:say('Hmm, can I help you with something else?', cid)
  Topic[cid] = nil
  else
  count[cid] = math.min(500, getCount(msg))
  npcHandler:say('So you would like me to change ' .. count[cid] .. ' of your platinum coins into ' .. count[cid] * 100 .. ' gold coins for you?', cid)
  Topic[cid] = 12
  end
  elseif Topic[cid] == 12 then
  if msgcontains(msg, 'yes') then
  if doPlayerRemoveItem(cid, 2152, count[cid]) then
  npcHandler:say('Here you are.', cid)
  doPlayerAddItem(cid, 2148, count[cid] * 100)
  else
  npcHandler:say('Sorry, you do not have enough platinum coins.', cid)
  end
  else
  npcHandler:say('Well, can I help you with something else?', cid)
  end
  Topic[cid] = nil
  elseif Topic[cid] == 13 then
  if getCount(msg) < 1 then
  npcHandler:say('Hmm, can I help you with something else?', cid)
  Topic[cid] = nil
  else
  count[cid] = math.min(500, getCount(msg))
  npcHandler:say('So you would like me to change ' .. count[cid] * 100 .. ' of your platinum coins into ' .. count[cid] .. ' crystal coins for you?', cid)
  Topic[cid] = 14
  end
  elseif Topic[cid] == 14 then
  if msgcontains(msg, 'yes') then
  if doPlayerRemoveItem(cid, 2152, count[cid] * 100) then
  npcHandler:say('Here you are.', cid)
  doPlayerAddItem(cid, 2160, count[cid])
  else
  npcHandler:say('Sorry, you do not have enough platinum coins.', cid)
  end
  else
  npcHandler:say('Well, can I help you with something else?', cid)
  end
  Topic[cid] = nil
  elseif msgcontains(msg, 'change crystal') then
  npcHandler:say('How many crystal coins would you like to change into platinum?', cid)
  Topic[cid] = 15
  elseif Topic[cid] == 15 then
  if getCount(msg) == -1 or getCount(msg) == 0 then
  npcHandler:say('Hmm, can I help you with something else?', cid)
  Topic[cid] = nil
  else
  count[cid] = math.min(500, getCount(msg))
  npcHandler:say('So you would like me to change ' .. count[cid] .. ' of your crystal coins into ' .. count[cid] * 100 .. ' platinum coins for you?', cid)
  Topic[cid] = 16
  end
  elseif Topic[cid] == 16 then
  if msgcontains(msg, 'yes') then
  if doPlayerRemoveItem(cid, 2160, count[cid]) then
  npcHandler:say('Here you are.', cid)
  doPlayerAddItem(cid, 2152, count[cid] * 100)
  else
  npcHandler:say('Sorry, you do not have enough crystal coins.', cid)
  end
  else
  npcHandler:say('Well, can I help you with something else?', cid)
  end
  Topic[cid] = nil
  elseif msgcontains(msg, 'change') then
  npcHandler:say('There are three different coin types in Tibia: 100 gold coins equal 1 platinum coin, 100 platinum coins equal 1 crystal coin. So if you\'d like to change 100 gold into 1 platinum, simply say \'{change gold}\' and then \'1 platinum\'.', cid)
  Topic[cid] = nil
  elseif msgcontains(msg, 'bank') then
  npcHandler:say('We can change money for you. You can also access your bank account.', cid)
  Topic[cid] = nil
  end
  return true
end

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

And show me this errors:
Code:
[12:7:51.002] Silvio has logged in.
[12:7:56.661] Luiz Ricardo has logged in.
[12:8:00.613] mysql_real_query(): SELECT `bid` FROM `houses` WHERE `highest_bidder`='12' LIMIT 1 - MYSQL ERROR: Unknown column 'bid' in 'field list' (1054)
[12:8:03.877] mysql_real_query(): SELECT `bid` FROM `houses` WHERE `highest_bidder`='12' LIMIT 1 - MYSQL ERROR: Unknown column 'bid' in 'field list' (1054)
[12:8:08.773] mysql_real_query(): SELECT `bid` FROM `houses` WHERE `highest_bidder`='12' LIMIT 1 - MYSQL ERROR: Unknown column 'bid' in 'field list' (1054)
[12:8:30.203] Cabrito has logged in.
[12:9:22.408] mysql_real_query(): SELECT `bid` FROM `houses` WHERE `highest_bidder`='12' LIMIT 1 - MYSQL ERROR: Unknown column 'bid' in 'field list' (1054)
[12:9:23.655] mysql_real_query(): SELECT `bid` FROM `houses` WHERE `highest_bidder`='12' LIMIT 1 - MYSQL ERROR: Unknown column 'bid' in 'field list' (1054)
[12:9:28.163] Silvio has logged out.
[12:9:34.788] mysql_real_query(): SELECT `bid` FROM `houses` WHERE `highest_bidder`='12' LIMIT 1 - MYSQL ERROR: Unknown column 'bid' in 'field list' (1054)
[12:9:35.866] mysql_real_query(): SELECT `bid` FROM `houses` WHERE `highest_bidder`='12' LIMIT 1 - MYSQL ERROR: Unknown column 'bid' in 'field list' (1054)

[12:9:35.866] [Error - NpcScript Interface]
[12:9:35.866] data/npc/scripts/bank.lua:onCreatureSay
[12:9:35.866] Description:
[12:9:35.866] (internalGetPlayerInfo) Player not found when requesting player info #7
[12:9:37.954] mysql_real_query(): SELECT `bid` FROM `houses` WHERE `highest_bidder`='12' LIMIT 1 - MYSQL ERROR: Unknown column 'bid' in 'field list' (1054)
[12:9:47.323] Silvio has logged in.
[12:9:54.371] mysql_real_query(): SELECT `bid` FROM `houses` WHERE `highest_bidder`='12' LIMIT 1 - MYSQL ERROR: Unknown column 'bid' in 'field list' (1054)
[12:9:55.523] mysql_real_query(): SELECT `bid` FROM `houses` WHERE `highest_bidder`='12' LIMIT 1 - MYSQL ERROR: Unknown column 'bid' in 'field list' (1054)

[12:9:55.524] [Error - NpcScript Interface]
[12:9:55.524] data/npc/scripts/bank.lua:onCreatureSay
[12:9:55.525] Description:
[12:9:55.525] (internalGetPlayerInfo) Player not found when requesting player info #7
[12:9:56.776] mysql_real_query(): SELECT `bid` FROM `houses` WHERE `highest_bidder`='12' LIMIT 1 - MYSQL ERROR: Unknown column 'bid' in 'field list' (1054)
[12:10:23.368] mysql_real_query(): SELECT `bid` FROM `houses` WHERE `highest_bidder`='12' LIMIT 1 - MYSQL ERROR: Unknown column 'bid' in 'field list' (1054)
[12:10:26.935] mysql_real_query(): SELECT `bid` FROM `houses` WHERE `highest_bidder`='12' LIMIT 1 - MYSQL ERROR: Unknown column 'bid' in 'field list' (1054)
[12:11:07.024] Silvio has logged out.
[12:11:13.236] Patricia has logged in.
[12:11:19.045] mysql_real_query(): SELECT `bid` FROM `houses` WHERE `highest_bidder`='12' LIMIT 1 - MYSQL ERROR: Unknown column 'bid' in 'field list' (1054)
[12:11:21.542] mysql_real_query(): SELECT `bid` FROM `houses` WHERE `highest_bidder`='12' LIMIT 1 - MYSQL ERROR: Unknown column 'bid' in 'field list' (1054)
[12:11:24.162] Patricia has logged out.
[12:11:27.780] mysql_real_query(): SELECT `bid` FROM `houses` WHERE `highest_bidder`='12' LIMIT 1 - MYSQL ERROR: Unknown column 'bid' in 'field list' (1054)
[12:11:29.004] mysql_real_query(): SELECT `bid` FROM `houses` WHERE `highest_bidder`='12' LIMIT 1 - MYSQL ERROR: Unknown column 'bid' in 'field list' (1054)
[12:11:34.577] Patricia has logged in.
[12:12:16.712] Patricia has logged out.
[12:12:18.791] Patricia has logged in.
[12:12:26.058] mysql_real_query(): SELECT `bid` FROM `houses` WHERE `highest_bidder`='12' LIMIT 1 - MYSQL ERROR: Unknown column 'bid' in 'field list' (1054)
[12:12:27.200] mysql_real_query(): SELECT `bid` FROM `houses` WHERE `highest_bidder`='12' LIMIT 1 - MYSQL ERROR: Unknown column 'bid' in 'field list' (1054)

[12:12:27.201] [Error - NpcScript Interface]
[12:12:27.201] data/npc/scripts/bank.lua:onCreatureSay
[12:12:27.201] Description:
[12:12:27.201] (internalGetPlayerInfo) Player not found when requesting player info #7
[12:12:28.735] mysql_real_query(): SELECT `bid` FROM `houses` WHERE `highest_bidder`='12' LIMIT 1 - MYSQL ERROR: Unknown column 'bid' in 'field list' (1054)
[12:15:36.680] Cabrito has logged out.
 
Last edited:
I've tried, your was right...

But could you guys help me?

Idk, but just townid 7 is work... Id 9 is not...
If player is from townid 7 its block, if is from town id 9 no block transfer

Why?

Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local Topic, count, transfer = {}, {}, {}

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 getCount(s)
  local b, e = s:find('%d+')
  return b and e and math.min(4294967295, tonumber(s:sub(b, e))) or -1
end

local function findPlayer(name)
  local resultId = db.storeQuery('SELECT name FROM players WHERE name=' .. db.escapeString(name) .. ' LIMIT 1'), nil
  if resultId == false then
  return
  end
  local r = result.getDataString(resultId, "name")
  result.free(resultId)
  return r
end

local function vocation(name)
  local resultId = db.storeQuery('SELECT vocation FROM players WHERE name=' .. db.escapeString(name) .. ' LIMIT 1'), nil
  if resultId == false then
  return
  end
  local r = result.getDataInt(resultId, "vocation")
  result.free(resultId)
  return r
end

local function getPlayerBiddedMoney(cid)
  local resultId = db.storeQuery('SELECT `bid` FROM `houses` WHERE `highest_bidder`=' .. db.escapeString(getPlayerGUID(cid)) .. ' LIMIT 1')
  if resultId == false then
  return 0
  end
  local r = result.getDataInt(resultId, "bid")
  result.free(resultId)
  return r
end

local function updatePlayerBalance(name, value)
  db.query('UPDATE players SET balance=' .. value .. ' WHERE name=' .. db.escapeString(name) .. ' LIMIT 1')
end

function greet(cid)
  Topic[cid], count[cid], transfer[cid] = nil, nil, nil
  return true
end

function creatureSayCallback(cid, type, msg)
  if not npcHandler:isFocused(cid) then
  return false
  elseif msgcontains(msg, 'balance') then
  local bid = getPlayerBiddedMoney(cid)
  if(bid > 0) then
  npcHandler:say('Your account balance is ' .. getPlayerBalance(cid) .. ' gold, ' .. bid .. ' gold is blocked for house auctioned by you.', cid)
  else
  npcHandler:say('Your account balance is ' .. getPlayerBalance(cid) .. ' gold.', cid)
  end
  Topic[cid] = nil
  elseif msgcontains(msg, 'deposit') and msgcontains(msg, 'all') then
  if getPlayerMoney(cid) == 0 then
  npcHandler:say('You don\'t have any gold with you.', cid)
  Topic[cid] = nil
  else
  count[cid] = getPlayerMoney(cid)
  npcHandler:say('Would you really like to deposit ' .. count[cid] .. ' gold?', cid)
  Topic[cid] = 2
  end
  elseif msgcontains(msg, 'deposit') then
  if getCount(msg) == 0 then
  npcHandler:say('You are joking, aren\'t you??', cid)
  Topic[cid] = nil
  elseif getCount(msg) ~= -1 then
  if getPlayerMoney(cid) >= getCount(msg) then
  count[cid] = getCount(msg)
  npcHandler:say('Would you really like to deposit ' .. count[cid] .. ' gold?', cid)
  Topic[cid] = 2
  else
  npcHandler:say('You do not have enough gold.', cid)
  Topic[cid] = nil
  end
  elseif getPlayerMoney(cid) == 0 then
  npcHandler:say('You don\'t have any gold with you.', cid)
  Topic[cid] = nil
  else
  npcHandler:say('Please tell me how much gold it is you would like to deposit.', cid)
  Topic[cid] = 1
  end
  elseif Topic[cid] == 1 then
  if getCount(msg) == -1 then
  npcHandler:say('Please tell me how much gold it is you would like to deposit.', cid)
  Topic[cid] = 1
  elseif getPlayerMoney(cid) >= getCount(msg) then
  count[cid] = getCount(msg)
  npcHandler:say('Would you really like to deposit ' .. count[cid] .. ' gold?', cid)
  Topic[cid] = 2
  else
  npcHandler:say('You do not have enough gold.', cid)
  Topic[cid] = nil
  end
  elseif msgcontains(msg, 'yes') and Topic[cid] == 2 then
  if doPlayerRemoveMoney(cid, count[cid]) then
  doPlayerSetBalance(cid, getPlayerBalance(cid) + count[cid])
  updatePlayerBalance(getPlayerName(cid), getPlayerBalance(cid))
  npcHandler:say('Alright, we have added the amount of ' .. count[cid] .. ' gold to your balance. You can withdraw your money anytime you want to.', cid)
  else
  npcHandler:say('I am inconsolable, but it seems you have lost your gold. I hope you get it back.', cid)
  end
  Topic[cid] = nil
  elseif msgcontains(msg, 'no') and Topic[cid] == 2 then
  npcHandler:say('As you wish. Is there something else I can do for you?', cid)
  Topic[cid] = nil
  elseif msgcontains(msg, 'withdraw') then
  if getCount(msg) == 0 then
  npcHandler:say('Sure, you want nothing you get nothing!', cid)
  Topic[cid] = nil
  elseif getCount(msg) ~= -1 then
  if getPlayerBalance(cid) - getPlayerBiddedMoney(cid) >= getCount(msg) then
  count[cid] = getCount(msg)
  npcHandler:say('Are you sure you wish to withdraw ' .. count[cid] .. ' gold from your bank account?', cid)
  Topic[cid] = 4
  else
  npcHandler:say('There is not enough gold on your account.', cid)
  Topic[cid] = nil
  end
  elseif getPlayerBalance(cid) == 0 then
  npcHandler:say('You don\'t have any money on your bank account.', cid)
  Topic[cid] = nil
  else
  npcHandler:say('Please tell me how much gold you would like to withdraw.', cid)
  Topic[cid] = 3
  end
  elseif Topic[cid] == 3 then
  if getCount(msg) == -1 then
  npcHandler:say('Please tell me how much gold you would like to withdraw.', cid)
  Topic[cid] = 3
  elseif getPlayerBalance(cid) - getPlayerBiddedMoney(cid) >= getCount(msg) then
  count[cid] = getCount(msg)
  npcHandler:say('Are you sure you wish to withdraw ' .. count[cid] .. ' gold from your bank account?', cid)
  Topic[cid] = 4
  else
  npcHandler:say('There is not enough gold on your account.', cid)
  Topic[cid] = nil
  end
  elseif msgcontains(msg, 'yes') and Topic[cid] == 4 then
  if getPlayerBalance(cid) - getPlayerBiddedMoney(cid) >= count[cid] then
  doPlayerAddMoney(cid, count[cid])
  doPlayerSetBalance(cid, getPlayerBalance(cid) - count[cid])
  updatePlayerBalance(getPlayerName(cid), getPlayerBalance(cid))
  npcHandler:say('Here you are, ' .. count[cid] .. ' gold. Please let me know if there is something else I can do for you.', cid)
  else
  npcHandler:say('There is not enough gold on your account.', cid)
  end
  Topic[cid] = nil
  elseif msgcontains(msg, 'no') and Topic[cid] == 4 then
  npcHandler:say('The customer is king! Come back anytime you want to if you wish to withdraw your money.', cid)
  Topic[cid] = nil
  elseif msgcontains(msg, 'transfer') then
  if getCount(msg) == 0 then
  npcHandler:say('Please think about it. Okay?', cid)
  Topic[cid] = nil
  elseif getCount(msg) ~= -1 then
 
  count[cid] = getCount(msg)
  if getPlayerBalance(cid) - getPlayerBiddedMoney(cid) >= count[cid] then
  npcHandler:say('Who would you like to transfer ' .. count[cid] .. ' gold to?', cid)
  Topic[cid] = 6
  else
  npcHandler:say('There is not enough gold on your account.', cid)
  Topic[cid] = nil
  end

  else
  npcHandler:say('Please tell me the amount of gold you would like to transfer.', cid)
  Topic[cid] = 5
  end
  elseif Topic[cid] == 5 then
  if getCount(msg) == -1 then
  npcHandler:say('Please tell me the amount of gold you would like to transfer.', cid)
  Topic[cid] = 5
  else
  count[cid] = getCount(msg)
  if getPlayerBalance(cid) - getPlayerBiddedMoney(cid) >= count[cid] then
  npcHandler:say('Who would you like to transfer ' .. count[cid] .. ' gold to?', cid)
  Topic[cid] = 6
  else
  npcHandler:say('There is not enough gold on your account.', cid)
  Topic[cid] = nil
  end
  end
  elseif Topic[cid] == 6 then
  local v = getPlayerByName(msg)
  if getPlayerBalance(cid) - getPlayerBiddedMoney(cid) >= count[cid] then
  if v and vocation(msg:lower()) > 0 and not isInArray({7, 9}, getPlayerTown(msg:lower())) then
  transfer[cid] = msg
  npcHandler:say('Would you really like to transfer ' .. count[cid] .. ' gold to ' .. getPlayerName(v) .. '?', cid)
  Topic[cid] = 7
  elseif getPlayerGUIDByName(msg:lower()) ~= 0  and vocation(msg:lower()) > 0 and not isInArray({7, 9}, getPlayerTown(msg:lower())) then
  transfer[cid] = msg
  npcHandler:say('Would you really like to transfer ' .. count[cid] .. ' gold to ' .. findPlayer(msg) .. '?', cid)
  Topic[cid] = 7 
  else
  npcHandler:say('This player does not exist on this world or is from Rookgaardia/Dawn Hills.', cid)
  Topic[cid] = nil
  end
  else
  npcHandler:say('There is not enough gold on your account.', cid)
  Topic[cid] = nil
  end
  elseif Topic[cid] == 7 and msgcontains(msg, 'yes') then
  if getPlayerBalance(cid) - getPlayerBiddedMoney(cid) >= count[cid] then
  local v = getPlayerByName(transfer[cid])
  if v then
  doPlayerSetBalance(cid, getPlayerBalance(cid) - count[cid])
  updatePlayerBalance(getPlayerName(cid), getPlayerBalance(cid))
  doPlayerSetBalance(v, getPlayerBalance(v) + count[cid])
  updatePlayerBalance(getPlayerName(v), getPlayerBalance(v))
  npcHandler:say('Very well. You have transferred ' .. count[cid] .. ' gold to ' .. getPlayerName(v) .. '.', cid)
  elseif findPlayer(transfer[cid]):lower() == transfer[cid]:lower() then
  doPlayerSetBalance(cid, getPlayerBalance(cid) - count[cid])
  updatePlayerBalance(getPlayerName(cid), getPlayerBalance(cid))
  db.query('UPDATE players SET balance=balance+' .. count[cid] .. ' WHERE name=' .. db.escapeString(transfer[cid]) .. ' LIMIT 1')
  npcHandler:say('Very well. You have transferred ' .. count[cid] .. ' gold to ' .. findPlayer(transfer[cid]) .. '.', cid)
  else
  npcHandler:say('This player does not exist.', cid)
  end
  else
  npcHandler:say('There is not enough gold on your account.', cid)
  end
  Topic[cid] = nil
  elseif Topic[cid] == 7 and msgcontains(msg, 'no') then
  npcHandler:say('Alright, is there something else I can do for you?', cid)
  Topic[cid] = nil
  elseif msgcontains(msg, 'change gold') then
  npcHandler:say('How many platinum coins would you like to get?', cid)
  Topic[cid] = 8
  elseif Topic[cid] == 8 then
  if getCount(msg) < 1 then
  npcHandler:say('Hmm, can I help you with something else?', cid)
  Topic[cid] = nil
  else
  count[cid] = math.min(500, getCount(msg))
  npcHandler:say('So you would like me to change ' .. count[cid] * 100 .. ' of your gold coins into ' .. count[cid] .. ' platinum coins?', cid)
  Topic[cid] = 9
  end
  elseif Topic[cid] == 9 then
  if msgcontains(msg, 'yes') then
  if doPlayerRemoveItem(cid, 2148, count[cid] * 100) then
  npcHandler:say('Here you are.', cid)
  doPlayerAddItem(cid, 2152, count[cid])
  else
  npcHandler:say('Sorry, you do not have enough gold coins.', cid)
  end
  else
  npcHandler:say('Well, can I help you with something else?', cid)
  end
  Topic[cid] = nil
  elseif msgcontains(msg, 'change platinum') then
  npcHandler:say('Would you like to change your platinum coins into gold or crystal?', cid)
  Topic[cid] = 10
  elseif Topic[cid] == 10 then
  if msgcontains(msg, 'gold') then
  npcHandler:say('How many platinum coins would you like to change into gold?', cid)
  Topic[cid] = 11
  elseif msgcontains(msg, 'crystal') then
  npcHandler:say('How many crystal coins would you like to get?', cid)
  Topic[cid] = 13
  else
  npcHandler:say('Well, can I help you with something else?', cid)
  Topic[cid] = nil
  end
  elseif Topic[cid] == 11 then
  if getCount(msg) < 1 then
  npcHandler:say('Hmm, can I help you with something else?', cid)
  Topic[cid] = nil
  else
  count[cid] = math.min(500, getCount(msg))
  npcHandler:say('So you would like me to change ' .. count[cid] .. ' of your platinum coins into ' .. count[cid] * 100 .. ' gold coins for you?', cid)
  Topic[cid] = 12
  end
  elseif Topic[cid] == 12 then
  if msgcontains(msg, 'yes') then
  if doPlayerRemoveItem(cid, 2152, count[cid]) then
  npcHandler:say('Here you are.', cid)
  doPlayerAddItem(cid, 2148, count[cid] * 100)
  else
  npcHandler:say('Sorry, you do not have enough platinum coins.', cid)
  end
  else
  npcHandler:say('Well, can I help you with something else?', cid)
  end
  Topic[cid] = nil
  elseif Topic[cid] == 13 then
  if getCount(msg) < 1 then
  npcHandler:say('Hmm, can I help you with something else?', cid)
  Topic[cid] = nil
  else
  count[cid] = math.min(500, getCount(msg))
  npcHandler:say('So you would like me to change ' .. count[cid] * 100 .. ' of your platinum coins into ' .. count[cid] .. ' crystal coins for you?', cid)
  Topic[cid] = 14
  end
  elseif Topic[cid] == 14 then
  if msgcontains(msg, 'yes') then
  if doPlayerRemoveItem(cid, 2152, count[cid] * 100) then
  npcHandler:say('Here you are.', cid)
  doPlayerAddItem(cid, 2160, count[cid])
  else
  npcHandler:say('Sorry, you do not have enough platinum coins.', cid)
  end
  else
  npcHandler:say('Well, can I help you with something else?', cid)
  end
  Topic[cid] = nil
  elseif msgcontains(msg, 'change crystal') then
  npcHandler:say('How many crystal coins would you like to change into platinum?', cid)
  Topic[cid] = 15
  elseif Topic[cid] == 15 then
  if getCount(msg) == -1 or getCount(msg) == 0 then
  npcHandler:say('Hmm, can I help you with something else?', cid)
  Topic[cid] = nil
  else
  count[cid] = math.min(500, getCount(msg))
  npcHandler:say('So you would like me to change ' .. count[cid] .. ' of your crystal coins into ' .. count[cid] * 100 .. ' platinum coins for you?', cid)
  Topic[cid] = 16
  end
  elseif Topic[cid] == 16 then
  if msgcontains(msg, 'yes') then
  if doPlayerRemoveItem(cid, 2160, count[cid]) then
  npcHandler:say('Here you are.', cid)
  doPlayerAddItem(cid, 2152, count[cid] * 100)
  else
  npcHandler:say('Sorry, you do not have enough crystal coins.', cid)
  end
  else
  npcHandler:say('Well, can I help you with something else?', cid)
  end
  Topic[cid] = nil
  elseif msgcontains(msg, 'change') then
  npcHandler:say('There are three different coin types in Tibia: 100 gold coins equal 1 platinum coin, 100 platinum coins equal 1 crystal coin. So if you\'d like to change 100 gold into 1 platinum, simply say \'{change gold}\' and then \'1 platinum\'.', cid)
  Topic[cid] = nil
  elseif msgcontains(msg, 'bank') then
  npcHandler:say('We can change money for you. You can also access your bank account.', cid)
  Topic[cid] = nil
  end
  return true
end

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

And show me this errors:
Code:
[12:7:51.002] Silvio has logged in.
[12:7:56.661] Luiz Ricardo has logged in.
[12:8:00.613] mysql_real_query(): SELECT `bid` FROM `houses` WHERE `highest_bidder`='12' LIMIT 1 - MYSQL ERROR: Unknown column 'bid' in 'field list' (1054)
[12:8:03.877] mysql_real_query(): SELECT `bid` FROM `houses` WHERE `highest_bidder`='12' LIMIT 1 - MYSQL ERROR: Unknown column 'bid' in 'field list' (1054)
[12:8:08.773] mysql_real_query(): SELECT `bid` FROM `houses` WHERE `highest_bidder`='12' LIMIT 1 - MYSQL ERROR: Unknown column 'bid' in 'field list' (1054)
[12:8:30.203] Cabrito has logged in.
[12:9:22.408] mysql_real_query(): SELECT `bid` FROM `houses` WHERE `highest_bidder`='12' LIMIT 1 - MYSQL ERROR: Unknown column 'bid' in 'field list' (1054)
[12:9:23.655] mysql_real_query(): SELECT `bid` FROM `houses` WHERE `highest_bidder`='12' LIMIT 1 - MYSQL ERROR: Unknown column 'bid' in 'field list' (1054)
[12:9:28.163] Silvio has logged out.
[12:9:34.788] mysql_real_query(): SELECT `bid` FROM `houses` WHERE `highest_bidder`='12' LIMIT 1 - MYSQL ERROR: Unknown column 'bid' in 'field list' (1054)
[12:9:35.866] mysql_real_query(): SELECT `bid` FROM `houses` WHERE `highest_bidder`='12' LIMIT 1 - MYSQL ERROR: Unknown column 'bid' in 'field list' (1054)

[12:9:35.866] [Error - NpcScript Interface]
[12:9:35.866] data/npc/scripts/bank.lua:onCreatureSay
[12:9:35.866] Description:
[12:9:35.866] (internalGetPlayerInfo) Player not found when requesting player info #7
[12:9:37.954] mysql_real_query(): SELECT `bid` FROM `houses` WHERE `highest_bidder`='12' LIMIT 1 - MYSQL ERROR: Unknown column 'bid' in 'field list' (1054)
[12:9:47.323] Silvio has logged in.
[12:9:54.371] mysql_real_query(): SELECT `bid` FROM `houses` WHERE `highest_bidder`='12' LIMIT 1 - MYSQL ERROR: Unknown column 'bid' in 'field list' (1054)
[12:9:55.523] mysql_real_query(): SELECT `bid` FROM `houses` WHERE `highest_bidder`='12' LIMIT 1 - MYSQL ERROR: Unknown column 'bid' in 'field list' (1054)

[12:9:55.524] [Error - NpcScript Interface]
[12:9:55.524] data/npc/scripts/bank.lua:onCreatureSay
[12:9:55.525] Description:
[12:9:55.525] (internalGetPlayerInfo) Player not found when requesting player info #7
[12:9:56.776] mysql_real_query(): SELECT `bid` FROM `houses` WHERE `highest_bidder`='12' LIMIT 1 - MYSQL ERROR: Unknown column 'bid' in 'field list' (1054)
[12:10:23.368] mysql_real_query(): SELECT `bid` FROM `houses` WHERE `highest_bidder`='12' LIMIT 1 - MYSQL ERROR: Unknown column 'bid' in 'field list' (1054)
[12:10:26.935] mysql_real_query(): SELECT `bid` FROM `houses` WHERE `highest_bidder`='12' LIMIT 1 - MYSQL ERROR: Unknown column 'bid' in 'field list' (1054)
[12:11:07.024] Silvio has logged out.
[12:11:13.236] Patricia has logged in.
[12:11:19.045] mysql_real_query(): SELECT `bid` FROM `houses` WHERE `highest_bidder`='12' LIMIT 1 - MYSQL ERROR: Unknown column 'bid' in 'field list' (1054)
[12:11:21.542] mysql_real_query(): SELECT `bid` FROM `houses` WHERE `highest_bidder`='12' LIMIT 1 - MYSQL ERROR: Unknown column 'bid' in 'field list' (1054)
[12:11:24.162] Patricia has logged out.
[12:11:27.780] mysql_real_query(): SELECT `bid` FROM `houses` WHERE `highest_bidder`='12' LIMIT 1 - MYSQL ERROR: Unknown column 'bid' in 'field list' (1054)
[12:11:29.004] mysql_real_query(): SELECT `bid` FROM `houses` WHERE `highest_bidder`='12' LIMIT 1 - MYSQL ERROR: Unknown column 'bid' in 'field list' (1054)
[12:11:34.577] Patricia has logged in.
[12:12:16.712] Patricia has logged out.
[12:12:18.791] Patricia has logged in.
[12:12:26.058] mysql_real_query(): SELECT `bid` FROM `houses` WHERE `highest_bidder`='12' LIMIT 1 - MYSQL ERROR: Unknown column 'bid' in 'field list' (1054)
[12:12:27.200] mysql_real_query(): SELECT `bid` FROM `houses` WHERE `highest_bidder`='12' LIMIT 1 - MYSQL ERROR: Unknown column 'bid' in 'field list' (1054)

[12:12:27.201] [Error - NpcScript Interface]
[12:12:27.201] data/npc/scripts/bank.lua:onCreatureSay
[12:12:27.201] Description:
[12:12:27.201] (internalGetPlayerInfo) Player not found when requesting player info #7
[12:12:28.735] mysql_real_query(): SELECT `bid` FROM `houses` WHERE `highest_bidder`='12' LIMIT 1 - MYSQL ERROR: Unknown column 'bid' in 'field list' (1054)
[12:15:36.680] Cabrito has logged out.
remove the bid part cus couldnt find the original banker code
 
remove the bid part cus couldnt find the original banker code

Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local Topic, count, transfer = {}, {}, {}

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 getCount(s)
  local b, e = s:find('%d+')
  return b and e and math.min(4294967295, tonumber(s:sub(b, e))) or -1
end

local function findPlayer(name)
  local resultId = db.storeQuery('SELECT name FROM players WHERE name=' .. db.escapeString(name) .. ' LIMIT 1'), nil
  if resultId == false then
  return
  end
  local r = result.getDataString(resultId, "name")
  result.free(resultId)
  return r
end

local function vocation(name)
  local resultId = db.storeQuery('SELECT vocation FROM players WHERE name=' .. db.escapeString(name) .. ' LIMIT 1'), nil
  if resultId == false then
  return
  end
  local r = result.getDataInt(resultId, "vocation")
  result.free(resultId)
  return r
end

local function updatePlayerBalance(name, value)
  db.query('UPDATE players SET balance=' .. value .. ' WHERE name=' .. db.escapeString(name) .. ' LIMIT 1')
end

function greet(cid)
  Topic[cid], count[cid], transfer[cid] = nil, nil, nil
  return true
end

function creatureSayCallback(cid, type, msg)
  if not npcHandler:isFocused(cid) then
  return false
  elseif msgcontains(msg, 'balance') then
  npcHandler:say('Your account balance is ' .. getPlayerBalance(cid) .. ' gold.', cid)
  Topic[cid] = nil
  elseif msgcontains(msg, 'deposit') and msgcontains(msg, 'all') then
  if getPlayerMoney(cid) == 0 then
  npcHandler:say('You don\'t have any gold with you.', cid)
  Topic[cid] = nil
  else
  count[cid] = getPlayerMoney(cid)
  npcHandler:say('Would you really like to deposit ' .. count[cid] .. ' gold?', cid)
  Topic[cid] = 2
  end
  elseif msgcontains(msg, 'deposit') then
  if getCount(msg) == 0 then
  npcHandler:say('You are joking, aren\'t you??', cid)
  Topic[cid] = nil
  elseif getCount(msg) ~= -1 then
  if getPlayerMoney(cid) >= getCount(msg) then
  count[cid] = getCount(msg)
  npcHandler:say('Would you really like to deposit ' .. count[cid] .. ' gold?', cid)
  Topic[cid] = 2
  else
  npcHandler:say('You do not have enough gold.', cid)
  Topic[cid] = nil
  end
  elseif getPlayerMoney(cid) == 0 then
  npcHandler:say('You don\'t have any gold with you.', cid)
  Topic[cid] = nil
  else
  npcHandler:say('Please tell me how much gold it is you would like to deposit.', cid)
  Topic[cid] = 1
  end
  elseif Topic[cid] == 1 then
  if getCount(msg) == -1 then
  npcHandler:say('Please tell me how much gold it is you would like to deposit.', cid)
  Topic[cid] = 1
  elseif getPlayerMoney(cid) >= getCount(msg) then
  count[cid] = getCount(msg)
  npcHandler:say('Would you really like to deposit ' .. count[cid] .. ' gold?', cid)
  Topic[cid] = 2
  else
  npcHandler:say('You do not have enough gold.', cid)
  Topic[cid] = nil
  end
  elseif msgcontains(msg, 'yes') and Topic[cid] == 2 then
  if doPlayerRemoveMoney(cid, count[cid]) then
  doPlayerSetBalance(cid, getPlayerBalance(cid) + count[cid])
  updatePlayerBalance(getPlayerName(cid), getPlayerBalance(cid))
  npcHandler:say('Alright, we have added the amount of ' .. count[cid] .. ' gold to your balance. You can withdraw your money anytime you want to.', cid)
  else
  npcHandler:say('I am inconsolable, but it seems you have lost your gold. I hope you get it back.', cid)
  end
  Topic[cid] = nil
  elseif msgcontains(msg, 'no') and Topic[cid] == 2 then
  npcHandler:say('As you wish. Is there something else I can do for you?', cid)
  Topic[cid] = nil
  elseif msgcontains(msg, 'withdraw') then
  if getCount(msg) == 0 then
  npcHandler:say('Sure, you want nothing you get nothing!', cid)
  Topic[cid] = nil
  elseif getCount(msg) ~= -1 then
  if getPlayerBalance(cid) >= getCount(msg) then
  count[cid] = getCount(msg)
  npcHandler:say('Are you sure you wish to withdraw ' .. count[cid] .. ' gold from your bank account?', cid)
  Topic[cid] = 4
  else
  npcHandler:say('There is not enough gold on your account.', cid)
  Topic[cid] = nil
  end
  elseif getPlayerBalance(cid) == 0 then
  npcHandler:say('You don\'t have any money on your bank account.', cid)
  Topic[cid] = nil
  else
  npcHandler:say('Please tell me how much gold you would like to withdraw.', cid)
  Topic[cid] = 3
  end
  elseif Topic[cid] == 3 then
  if getCount(msg) == -1 then
  npcHandler:say('Please tell me how much gold you would like to withdraw.', cid)
  Topic[cid] = 3
  elseif getPlayerBalance(cid) >= getCount(msg) then
  count[cid] = getCount(msg)
  npcHandler:say('Are you sure you wish to withdraw ' .. count[cid] .. ' gold from your bank account?', cid)
  Topic[cid] = 4
  else
  npcHandler:say('There is not enough gold on your account.', cid)
  Topic[cid] = nil
  end
  elseif msgcontains(msg, 'yes') and Topic[cid] == 4 then
  if getPlayerBalance(cid) >= count[cid] then
  doPlayerAddMoney(cid, count[cid])
  doPlayerSetBalance(cid, getPlayerBalance(cid) - count[cid])
  updatePlayerBalance(getPlayerName(cid), getPlayerBalance(cid))
  npcHandler:say('Here you are, ' .. count[cid] .. ' gold. Please let me know if there is something else I can do for you.', cid)
  else
  npcHandler:say('There is not enough gold on your account.', cid)
  end
  Topic[cid] = nil
  elseif msgcontains(msg, 'no') and Topic[cid] == 4 then
  npcHandler:say('The customer is king! Come back anytime you want to if you wish to withdraw your money.', cid)
  Topic[cid] = nil
  elseif msgcontains(msg, 'transfer') then
  if getCount(msg) == 0 then
  npcHandler:say('Please think about it. Okay?', cid)
  Topic[cid] = nil
  elseif getCount(msg) ~= -1 then
   
  count[cid] = getCount(msg)
  if getPlayerBalance(cid) >= count[cid] then
  npcHandler:say('Who would you like to transfer ' .. count[cid] .. ' gold to?', cid)
  Topic[cid] = 6
  else
  npcHandler:say('There is not enough gold on your account.', cid)
  Topic[cid] = nil
  end

  else
  npcHandler:say('Please tell me the amount of gold you would like to transfer.', cid)
  Topic[cid] = 5
  end
  elseif Topic[cid] == 5 then
  if getCount(msg) == -1 then
  npcHandler:say('Please tell me the amount of gold you would like to transfer.', cid)
  Topic[cid] = 5
  else
  count[cid] = getCount(msg)
  if getPlayerBalance(cid) >= count[cid] then
  npcHandler:say('Who would you like to transfer ' .. count[cid] .. ' gold to?', cid)
  Topic[cid] = 6
  else
  npcHandler:say('There is not enough gold on your account.', cid)
  Topic[cid] = nil
  end
  end
  elseif Topic[cid] == 6 then
  local v = getPlayerByName(msg)
  if getPlayerBalance(cid) >= count[cid] then
  if v and vocation(msg:lower()) > 0 and not isInArray({7, 9}, getPlayerTown(msg:lower())) then
  transfer[cid] = msg
  npcHandler:say('Would you really like to transfer ' .. count[cid] .. ' gold to ' .. getPlayerName(v) .. '?', cid)
  Topic[cid] = 7
  elseif getPlayerGUIDByName(msg:lower()) ~= 0  and vocation(msg:lower()) > 0 and not isInArray({7, 9}, getPlayerTown(msg:lower())) then
  transfer[cid] = msg
  npcHandler:say('Would you really like to transfer ' .. count[cid] .. ' gold to ' .. findPlayer(msg) .. '?', cid)
  Topic[cid] = 7   
  else
  npcHandler:say('This player does not exist on this world or is from Rookgaardia/Dawn Hills.', cid)
  Topic[cid] = nil
  end
  else
  npcHandler:say('There is not enough gold on your account.', cid)
  Topic[cid] = nil
  end
  elseif Topic[cid] == 7 and msgcontains(msg, 'yes') then
  if getPlayerBalance(cid) >= count[cid] then
  local v = getPlayerByName(transfer[cid])
  if v then
  doPlayerSetBalance(cid, getPlayerBalance(cid) - count[cid])
  updatePlayerBalance(getPlayerName(cid), getPlayerBalance(cid))
  doPlayerSetBalance(v, getPlayerBalance(v) + count[cid])
  updatePlayerBalance(getPlayerName(v), getPlayerBalance(v))
  npcHandler:say('Very well. You have transferred ' .. count[cid] .. ' gold to ' .. getPlayerName(v) .. '.', cid)
  elseif findPlayer(transfer[cid]):lower() == transfer[cid]:lower() then
  doPlayerSetBalance(cid, getPlayerBalance(cid) - count[cid])
  updatePlayerBalance(getPlayerName(cid), getPlayerBalance(cid))
  db.query('UPDATE players SET balance=balance+' .. count[cid] .. ' WHERE name=' .. db.escapeString(transfer[cid]) .. ' LIMIT 1')
  npcHandler:say('Very well. You have transferred ' .. count[cid] .. ' gold to ' .. findPlayer(transfer[cid]) .. '.', cid)
  else
  npcHandler:say('This player does not exist.', cid)
  end
  else
  npcHandler:say('There is not enough gold on your account.', cid)
  end
  Topic[cid] = nil
  elseif Topic[cid] == 7 and msgcontains(msg, 'no') then
  npcHandler:say('Alright, is there something else I can do for you?', cid)
  Topic[cid] = nil
  elseif msgcontains(msg, 'change gold') then
  npcHandler:say('How many platinum coins would you like to get?', cid)
  Topic[cid] = 8
  elseif Topic[cid] == 8 then
  if getCount(msg) < 1 then
  npcHandler:say('Hmm, can I help you with something else?', cid)
  Topic[cid] = nil
  else
  count[cid] = math.min(500, getCount(msg))
  npcHandler:say('So you would like me to change ' .. count[cid] * 100 .. ' of your gold coins into ' .. count[cid] .. ' platinum coins?', cid)
  Topic[cid] = 9
  end
  elseif Topic[cid] == 9 then
  if msgcontains(msg, 'yes') then
  if doPlayerRemoveItem(cid, 2148, count[cid] * 100) then
  npcHandler:say('Here you are.', cid)
  doPlayerAddItem(cid, 2152, count[cid])
  else
  npcHandler:say('Sorry, you do not have enough gold coins.', cid)
  end
  else
  npcHandler:say('Well, can I help you with something else?', cid)
  end
  Topic[cid] = nil
  elseif msgcontains(msg, 'change platinum') then
  npcHandler:say('Would you like to change your platinum coins into gold or crystal?', cid)
  Topic[cid] = 10
  elseif Topic[cid] == 10 then
  if msgcontains(msg, 'gold') then
  npcHandler:say('How many platinum coins would you like to change into gold?', cid)
  Topic[cid] = 11
  elseif msgcontains(msg, 'crystal') then
  npcHandler:say('How many crystal coins would you like to get?', cid)
  Topic[cid] = 13
  else
  npcHandler:say('Well, can I help you with something else?', cid)
  Topic[cid] = nil
  end
  elseif Topic[cid] == 11 then
  if getCount(msg) < 1 then
  npcHandler:say('Hmm, can I help you with something else?', cid)
  Topic[cid] = nil
  else
  count[cid] = math.min(500, getCount(msg))
  npcHandler:say('So you would like me to change ' .. count[cid] .. ' of your platinum coins into ' .. count[cid] * 100 .. ' gold coins for you?', cid)
  Topic[cid] = 12
  end
  elseif Topic[cid] == 12 then
  if msgcontains(msg, 'yes') then
  if doPlayerRemoveItem(cid, 2152, count[cid]) then
  npcHandler:say('Here you are.', cid)
  doPlayerAddItem(cid, 2148, count[cid] * 100)
  else
  npcHandler:say('Sorry, you do not have enough platinum coins.', cid)
  end
  else
  npcHandler:say('Well, can I help you with something else?', cid)
  end
  Topic[cid] = nil
  elseif Topic[cid] == 13 then
  if getCount(msg) < 1 then
  npcHandler:say('Hmm, can I help you with something else?', cid)
  Topic[cid] = nil
  else
  count[cid] = math.min(500, getCount(msg))
  npcHandler:say('So you would like me to change ' .. count[cid] * 100 .. ' of your platinum coins into ' .. count[cid] .. ' crystal coins for you?', cid)
  Topic[cid] = 14
  end
  elseif Topic[cid] == 14 then
  if msgcontains(msg, 'yes') then
  if doPlayerRemoveItem(cid, 2152, count[cid] * 100) then
  npcHandler:say('Here you are.', cid)
  doPlayerAddItem(cid, 2160, count[cid])
  else
  npcHandler:say('Sorry, you do not have enough platinum coins.', cid)
  end
  else
  npcHandler:say('Well, can I help you with something else?', cid)
  end
  Topic[cid] = nil
  elseif msgcontains(msg, 'change crystal') then
  npcHandler:say('How many crystal coins would you like to change into platinum?', cid)
  Topic[cid] = 15
  elseif Topic[cid] == 15 then
  if getCount(msg) == -1 or getCount(msg) == 0 then
  npcHandler:say('Hmm, can I help you with something else?', cid)
  Topic[cid] = nil
  else
  count[cid] = math.min(500, getCount(msg))
  npcHandler:say('So you would like me to change ' .. count[cid] .. ' of your crystal coins into ' .. count[cid] * 100 .. ' platinum coins for you?', cid)
  Topic[cid] = 16
  end
  elseif Topic[cid] == 16 then
  if msgcontains(msg, 'yes') then
  if doPlayerRemoveItem(cid, 2160, count[cid]) then
  npcHandler:say('Here you are.', cid)
  doPlayerAddItem(cid, 2152, count[cid] * 100)
  else
  npcHandler:say('Sorry, you do not have enough crystal coins.', cid)
  end
  else
  npcHandler:say('Well, can I help you with something else?', cid)
  end
  Topic[cid] = nil
  elseif msgcontains(msg, 'change') then
  npcHandler:say('There are three different coin types in Tibia: 100 gold coins equal 1 platinum coin, 100 platinum coins equal 1 crystal coin. So if you\'d like to change 100 gold into 1 platinum, simply say \'{change gold}\' and then \'1 platinum\'.', cid)
  Topic[cid] = nil
  elseif msgcontains(msg, 'bank') then
  npcHandler:say('We can change money for you. You can also access your bank account.', cid)
  Topic[cid] = nil
  end
  return true
end

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

Before first login i tried to transfer to 'Luiz Ricardo'
Code:
[14:41:13.359] [Error - NpcScript Interface]
[14:41:13.359] data/npc/scripts/bank.lua:onCreatureSay
[14:41:13.359] Description:
[14:41:13.359] (internalGetPlayerInfo) Player not found when requesting player info #7
[14:42:09.442] Luiz Ricardo has logged in.
[14:42:24.423] Luiz Ricardo has logged out.

After no errors...

Just idk why, but dawnport (townid 9) is not blocking and rookgaard (town id 7) is blocking...
 
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local Topic, count, transfer = {}, {}, {}

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 getCount(s)
  local b, e = s:find('%d+')
  return b and e and math.min(4294967295, tonumber(s:sub(b, e))) or -1
end

local function findPlayer(name)
  local resultId = db.storeQuery('SELECT name FROM players WHERE name=' .. db.escapeString(name) .. ' LIMIT 1'), nil
  if resultId == false then
  return
  end
  local r = result.getDataString(resultId, "name")
  result.free(resultId)
  return r
end

local function vocation(name)
  local resultId = db.storeQuery('SELECT vocation FROM players WHERE name=' .. db.escapeString(name) .. ' LIMIT 1'), nil
  if resultId == false then
  return
  end
  local r = result.getDataInt(resultId, "vocation")
  result.free(resultId)
  return r
end

local function updatePlayerBalance(name, value)
  db.query('UPDATE players SET balance=' .. value .. ' WHERE name=' .. db.escapeString(name) .. ' LIMIT 1')
end

function greet(cid)
  Topic[cid], count[cid], transfer[cid] = nil, nil, nil
  return true
end

function creatureSayCallback(cid, type, msg)
  if not npcHandler:isFocused(cid) then
  return false
  elseif msgcontains(msg, 'balance') then
  npcHandler:say('Your account balance is ' .. getPlayerBalance(cid) .. ' gold.', cid)
  Topic[cid] = nil
  elseif msgcontains(msg, 'deposit') and msgcontains(msg, 'all') then
  if getPlayerMoney(cid) == 0 then
  npcHandler:say('You don\'t have any gold with you.', cid)
  Topic[cid] = nil
  else
  count[cid] = getPlayerMoney(cid)
  npcHandler:say('Would you really like to deposit ' .. count[cid] .. ' gold?', cid)
  Topic[cid] = 2
  end
  elseif msgcontains(msg, 'deposit') then
  if getCount(msg) == 0 then
  npcHandler:say('You are joking, aren\'t you??', cid)
  Topic[cid] = nil
  elseif getCount(msg) ~= -1 then
  if getPlayerMoney(cid) >= getCount(msg) then
  count[cid] = getCount(msg)
  npcHandler:say('Would you really like to deposit ' .. count[cid] .. ' gold?', cid)
  Topic[cid] = 2
  else
  npcHandler:say('You do not have enough gold.', cid)
  Topic[cid] = nil
  end
  elseif getPlayerMoney(cid) == 0 then
  npcHandler:say('You don\'t have any gold with you.', cid)
  Topic[cid] = nil
  else
  npcHandler:say('Please tell me how much gold it is you would like to deposit.', cid)
  Topic[cid] = 1
  end
  elseif Topic[cid] == 1 then
  if getCount(msg) == -1 then
  npcHandler:say('Please tell me how much gold it is you would like to deposit.', cid)
  Topic[cid] = 1
  elseif getPlayerMoney(cid) >= getCount(msg) then
  count[cid] = getCount(msg)
  npcHandler:say('Would you really like to deposit ' .. count[cid] .. ' gold?', cid)
  Topic[cid] = 2
  else
  npcHandler:say('You do not have enough gold.', cid)
  Topic[cid] = nil
  end
  elseif msgcontains(msg, 'yes') and Topic[cid] == 2 then
  if doPlayerRemoveMoney(cid, count[cid]) then
  doPlayerSetBalance(cid, getPlayerBalance(cid) + count[cid])
  updatePlayerBalance(getPlayerName(cid), getPlayerBalance(cid))
  npcHandler:say('Alright, we have added the amount of ' .. count[cid] .. ' gold to your balance. You can withdraw your money anytime you want to.', cid)
  else
  npcHandler:say('I am inconsolable, but it seems you have lost your gold. I hope you get it back.', cid)
  end
  Topic[cid] = nil
  elseif msgcontains(msg, 'no') and Topic[cid] == 2 then
  npcHandler:say('As you wish. Is there something else I can do for you?', cid)
  Topic[cid] = nil
  elseif msgcontains(msg, 'withdraw') then
  if getCount(msg) == 0 then
  npcHandler:say('Sure, you want nothing you get nothing!', cid)
  Topic[cid] = nil
  elseif getCount(msg) ~= -1 then
  if getPlayerBalance(cid) >= getCount(msg) then
  count[cid] = getCount(msg)
  npcHandler:say('Are you sure you wish to withdraw ' .. count[cid] .. ' gold from your bank account?', cid)
  Topic[cid] = 4
  else
  npcHandler:say('There is not enough gold on your account.', cid)
  Topic[cid] = nil
  end
  elseif getPlayerBalance(cid) == 0 then
  npcHandler:say('You don\'t have any money on your bank account.', cid)
  Topic[cid] = nil
  else
  npcHandler:say('Please tell me how much gold you would like to withdraw.', cid)
  Topic[cid] = 3
  end
  elseif Topic[cid] == 3 then
  if getCount(msg) == -1 then
  npcHandler:say('Please tell me how much gold you would like to withdraw.', cid)
  Topic[cid] = 3
  elseif getPlayerBalance(cid) >= getCount(msg) then
  count[cid] = getCount(msg)
  npcHandler:say('Are you sure you wish to withdraw ' .. count[cid] .. ' gold from your bank account?', cid)
  Topic[cid] = 4
  else
  npcHandler:say('There is not enough gold on your account.', cid)
  Topic[cid] = nil
  end
  elseif msgcontains(msg, 'yes') and Topic[cid] == 4 then
  if getPlayerBalance(cid) >= count[cid] then
  doPlayerAddMoney(cid, count[cid])
  doPlayerSetBalance(cid, getPlayerBalance(cid) - count[cid])
  updatePlayerBalance(getPlayerName(cid), getPlayerBalance(cid))
  npcHandler:say('Here you are, ' .. count[cid] .. ' gold. Please let me know if there is something else I can do for you.', cid)
  else
  npcHandler:say('There is not enough gold on your account.', cid)
  end
  Topic[cid] = nil
  elseif msgcontains(msg, 'no') and Topic[cid] == 4 then
  npcHandler:say('The customer is king! Come back anytime you want to if you wish to withdraw your money.', cid)
  Topic[cid] = nil
  elseif msgcontains(msg, 'transfer') then
  if getCount(msg) == 0 then
  npcHandler:say('Please think about it. Okay?', cid)
  Topic[cid] = nil
  elseif getCount(msg) ~= -1 then
  
  count[cid] = getCount(msg)
  if getPlayerBalance(cid) >= count[cid] then
  npcHandler:say('Who would you like to transfer ' .. count[cid] .. ' gold to?', cid)
  Topic[cid] = 6
  else
  npcHandler:say('There is not enough gold on your account.', cid)
  Topic[cid] = nil
  end

  else
  npcHandler:say('Please tell me the amount of gold you would like to transfer.', cid)
  Topic[cid] = 5
  end
  elseif Topic[cid] == 5 then
  if getCount(msg) == -1 then
  npcHandler:say('Please tell me the amount of gold you would like to transfer.', cid)
  Topic[cid] = 5
  else
  count[cid] = getCount(msg)
  if getPlayerBalance(cid) >= count[cid] then
  npcHandler:say('Who would you like to transfer ' .. count[cid] .. ' gold to?', cid)
  Topic[cid] = 6
  else
  npcHandler:say('There is not enough gold on your account.', cid)
  Topic[cid] = nil
  end
  end
  elseif Topic[cid] == 6 then
  local v = getPlayerByName(msg)
  if getPlayerBalance(cid) >= count[cid] then
  if v and vocation(msg:lower()) > 0 and not isInArray({7, 9}, getPlayerTown(msg:lower())) then
  transfer[cid] = msg
  npcHandler:say('Would you really like to transfer ' .. count[cid] .. ' gold to ' .. getPlayerName(v) .. '?', cid)
  Topic[cid] = 7
  elseif getPlayerGUIDByName(msg:lower()) ~= 0  and vocation(msg:lower()) > 0 and not isInArray({7, 9}, getPlayerTown(msg:lower())) then
  transfer[cid] = msg
  npcHandler:say('Would you really like to transfer ' .. count[cid] .. ' gold to ' .. findPlayer(msg) .. '?', cid)
  Topic[cid] = 7  
  else
  npcHandler:say('This player does not exist on this world or is from Rookgaardia/Dawn Hills.', cid)
  Topic[cid] = nil
  end
  else
  npcHandler:say('There is not enough gold on your account.', cid)
  Topic[cid] = nil
  end
  elseif Topic[cid] == 7 and msgcontains(msg, 'yes') then
  if getPlayerBalance(cid) >= count[cid] then
  local v = getPlayerByName(transfer[cid])
  if v then
  doPlayerSetBalance(cid, getPlayerBalance(cid) - count[cid])
  updatePlayerBalance(getPlayerName(cid), getPlayerBalance(cid))
  doPlayerSetBalance(v, getPlayerBalance(v) + count[cid])
  updatePlayerBalance(getPlayerName(v), getPlayerBalance(v))
  npcHandler:say('Very well. You have transferred ' .. count[cid] .. ' gold to ' .. getPlayerName(v) .. '.', cid)
  elseif findPlayer(transfer[cid]):lower() == transfer[cid]:lower() then
  doPlayerSetBalance(cid, getPlayerBalance(cid) - count[cid])
  updatePlayerBalance(getPlayerName(cid), getPlayerBalance(cid))
  db.query('UPDATE players SET balance=balance+' .. count[cid] .. ' WHERE name=' .. db.escapeString(transfer[cid]) .. ' LIMIT 1')
  npcHandler:say('Very well. You have transferred ' .. count[cid] .. ' gold to ' .. findPlayer(transfer[cid]) .. '.', cid)
  else
  npcHandler:say('This player does not exist.', cid)
  end
  else
  npcHandler:say('There is not enough gold on your account.', cid)
  end
  Topic[cid] = nil
  elseif Topic[cid] == 7 and msgcontains(msg, 'no') then
  npcHandler:say('Alright, is there something else I can do for you?', cid)
  Topic[cid] = nil
  elseif msgcontains(msg, 'change gold') then
  npcHandler:say('How many platinum coins would you like to get?', cid)
  Topic[cid] = 8
  elseif Topic[cid] == 8 then
  if getCount(msg) < 1 then
  npcHandler:say('Hmm, can I help you with something else?', cid)
  Topic[cid] = nil
  else
  count[cid] = math.min(500, getCount(msg))
  npcHandler:say('So you would like me to change ' .. count[cid] * 100 .. ' of your gold coins into ' .. count[cid] .. ' platinum coins?', cid)
  Topic[cid] = 9
  end
  elseif Topic[cid] == 9 then
  if msgcontains(msg, 'yes') then
  if doPlayerRemoveItem(cid, 2148, count[cid] * 100) then
  npcHandler:say('Here you are.', cid)
  doPlayerAddItem(cid, 2152, count[cid])
  else
  npcHandler:say('Sorry, you do not have enough gold coins.', cid)
  end
  else
  npcHandler:say('Well, can I help you with something else?', cid)
  end
  Topic[cid] = nil
  elseif msgcontains(msg, 'change platinum') then
  npcHandler:say('Would you like to change your platinum coins into gold or crystal?', cid)
  Topic[cid] = 10
  elseif Topic[cid] == 10 then
  if msgcontains(msg, 'gold') then
  npcHandler:say('How many platinum coins would you like to change into gold?', cid)
  Topic[cid] = 11
  elseif msgcontains(msg, 'crystal') then
  npcHandler:say('How many crystal coins would you like to get?', cid)
  Topic[cid] = 13
  else
  npcHandler:say('Well, can I help you with something else?', cid)
  Topic[cid] = nil
  end
  elseif Topic[cid] == 11 then
  if getCount(msg) < 1 then
  npcHandler:say('Hmm, can I help you with something else?', cid)
  Topic[cid] = nil
  else
  count[cid] = math.min(500, getCount(msg))
  npcHandler:say('So you would like me to change ' .. count[cid] .. ' of your platinum coins into ' .. count[cid] * 100 .. ' gold coins for you?', cid)
  Topic[cid] = 12
  end
  elseif Topic[cid] == 12 then
  if msgcontains(msg, 'yes') then
  if doPlayerRemoveItem(cid, 2152, count[cid]) then
  npcHandler:say('Here you are.', cid)
  doPlayerAddItem(cid, 2148, count[cid] * 100)
  else
  npcHandler:say('Sorry, you do not have enough platinum coins.', cid)
  end
  else
  npcHandler:say('Well, can I help you with something else?', cid)
  end
  Topic[cid] = nil
  elseif Topic[cid] == 13 then
  if getCount(msg) < 1 then
  npcHandler:say('Hmm, can I help you with something else?', cid)
  Topic[cid] = nil
  else
  count[cid] = math.min(500, getCount(msg))
  npcHandler:say('So you would like me to change ' .. count[cid] * 100 .. ' of your platinum coins into ' .. count[cid] .. ' crystal coins for you?', cid)
  Topic[cid] = 14
  end
  elseif Topic[cid] == 14 then
  if msgcontains(msg, 'yes') then
  if doPlayerRemoveItem(cid, 2152, count[cid] * 100) then
  npcHandler:say('Here you are.', cid)
  doPlayerAddItem(cid, 2160, count[cid])
  else
  npcHandler:say('Sorry, you do not have enough platinum coins.', cid)
  end
  else
  npcHandler:say('Well, can I help you with something else?', cid)
  end
  Topic[cid] = nil
  elseif msgcontains(msg, 'change crystal') then
  npcHandler:say('How many crystal coins would you like to change into platinum?', cid)
  Topic[cid] = 15
  elseif Topic[cid] == 15 then
  if getCount(msg) == -1 or getCount(msg) == 0 then
  npcHandler:say('Hmm, can I help you with something else?', cid)
  Topic[cid] = nil
  else
  count[cid] = math.min(500, getCount(msg))
  npcHandler:say('So you would like me to change ' .. count[cid] .. ' of your crystal coins into ' .. count[cid] * 100 .. ' platinum coins for you?', cid)
  Topic[cid] = 16
  end
  elseif Topic[cid] == 16 then
  if msgcontains(msg, 'yes') then
  if doPlayerRemoveItem(cid, 2160, count[cid]) then
  npcHandler:say('Here you are.', cid)
  doPlayerAddItem(cid, 2152, count[cid] * 100)
  else
  npcHandler:say('Sorry, you do not have enough crystal coins.', cid)
  end
  else
  npcHandler:say('Well, can I help you with something else?', cid)
  end
  Topic[cid] = nil
  elseif msgcontains(msg, 'change') then
  npcHandler:say('There are three different coin types in Tibia: 100 gold coins equal 1 platinum coin, 100 platinum coins equal 1 crystal coin. So if you\'d like to change 100 gold into 1 platinum, simply say \'{change gold}\' and then \'1 platinum\'.', cid)
  Topic[cid] = nil
  elseif msgcontains(msg, 'bank') then
  npcHandler:say('We can change money for you. You can also access your bank account.', cid)
  Topic[cid] = nil
  end
  return true
end

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

Before first login i tried to transfer to 'Luiz Ricardo'
Code:
[14:41:13.359] [Error - NpcScript Interface]
[14:41:13.359] data/npc/scripts/bank.lua:onCreatureSay
[14:41:13.359] Description:
[14:41:13.359] (internalGetPlayerInfo) Player not found when requesting player info #7
[14:42:09.442] Luiz Ricardo has logged in.
[14:42:24.423] Luiz Ricardo has logged out.

After no errors...

Just idk why, but dawnport (townid 9) is not blocking and rookgaard (town id 7) is blocking...
i dont want to download a shitty 0.4 server so not gonna help anymore, it is almost done and im too lazy cus you guys do not want to learn or to change ur engine, good bye.
 
i dont want to download a shitty 0.4 server so not gonna help anymore, it is almost done and im too lazy cus you guys do not want to learn or to change ur engine, good bye.

I'm not you...
I'm doing my best...
You don't need to download anything, you are free to don't help no one
You've been here since 2007, I started to learn this month (join here this week)

Good Bye!

---

To problem....
I tried to change somethings, but i got some errors when i tried to transfer
I changed:
Code:
  elseif Topic[cid] == 6 then
  local v = getPlayerByName(msg)
  if getPlayerBalance(cid) >= count[cid] then
  if v and getPlayerTown(msg:lower()) ~= 7 and getPlayerTown(msg:lower()) ~= 9 then
  transfer[cid] = msg
  npcHandler:say('Would you really like to transfer ' .. count[cid] .. ' gold to ' .. getPlayerName(v) .. '?', cid)
  Topic[cid] = 7
  elseif getPlayerGUIDByName(msg:lower()) ~= 0 and getPlayerTown(msg:lower()) ~= 7 and getPlayerTown(msg:lower()) ~= 9 then
  transfer[cid] = msg
  npcHandler:say('Would you really like to transfer ' .. count[cid] .. ' gold to ' .. findPlayer(msg) .. '?', cid)
  Topic[cid] = 7  
  else
  npcHandler:say('This player does not exist on this world or is from Rookgaardia/Dawn Hills.', cid)
  Topic[cid] = nil
  end
  else
  npcHandler:say('There is not enough gold on your account.', cid)
  Topic[cid] = nil
  end

Errors:
Code:
[16:53:00.166] [Error - NpcScript Interface]
[16:53:00.166] data/npc/scripts/bank.lua:onCreatureSay
[16:53:00.166] Description:
[16:53:00.166] (internalGetPlayerInfo) Player not found when requesting player info #7

[16:53:00.166] [Error - NpcScript Interface]
[16:53:00.166] data/npc/scripts/bank.lua:onCreatureSay
[16:53:00.166] Description:
[16:53:00.166] (internalGetPlayerInfo) Player not found when requesting player info #7

Full code:
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local Topic, count, transfer = {}, {}, {}

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 getCount(s)
  local b, e = s:find('%d+')
  return b and e and math.min(4294967295, tonumber(s:sub(b, e))) or -1
end

local function findPlayer(name)
  local resultId = db.storeQuery('SELECT name FROM players WHERE name=' .. db.escapeString(name) .. ' LIMIT 1'), nil
  if resultId == false then
  return
  end
  local r = result.getDataString(resultId, "name")
  result.free(resultId)
  return r
end

local function vocation(name)
  local resultId = db.storeQuery('SELECT vocation FROM players WHERE name=' .. db.escapeString(name) .. ' LIMIT 1'), nil
  if resultId == false then
  return
  end
  local r = result.getDataInt(resultId, "vocation")
  result.free(resultId)
  return r
end

local function updatePlayerBalance(name, value)
  db.query('UPDATE players SET balance=' .. value .. ' WHERE name=' .. db.escapeString(name) .. ' LIMIT 1')
end

function greet(cid)
  Topic[cid], count[cid], transfer[cid] = nil, nil, nil
  return true
end

function creatureSayCallback(cid, type, msg)
  if not npcHandler:isFocused(cid) then
  return false
  elseif msgcontains(msg, 'balance') then
  npcHandler:say('Your account balance is ' .. getPlayerBalance(cid) .. ' gold.', cid)
  Topic[cid] = nil
  elseif msgcontains(msg, 'deposit') and msgcontains(msg, 'all') then
  if getPlayerMoney(cid) == 0 then
  npcHandler:say('You don\'t have any gold with you.', cid)
  Topic[cid] = nil
  else
  count[cid] = getPlayerMoney(cid)
  npcHandler:say('Would you really like to deposit ' .. count[cid] .. ' gold?', cid)
  Topic[cid] = 2
  end
  elseif msgcontains(msg, 'deposit') then
  if getCount(msg) == 0 then
  npcHandler:say('You are joking, aren\'t you??', cid)
  Topic[cid] = nil
  elseif getCount(msg) ~= -1 then
  if getPlayerMoney(cid) >= getCount(msg) then
  count[cid] = getCount(msg)
  npcHandler:say('Would you really like to deposit ' .. count[cid] .. ' gold?', cid)
  Topic[cid] = 2
  else
  npcHandler:say('You do not have enough gold.', cid)
  Topic[cid] = nil
  end
  elseif getPlayerMoney(cid) == 0 then
  npcHandler:say('You don\'t have any gold with you.', cid)
  Topic[cid] = nil
  else
  npcHandler:say('Please tell me how much gold it is you would like to deposit.', cid)
  Topic[cid] = 1
  end
  elseif Topic[cid] == 1 then
  if getCount(msg) == -1 then
  npcHandler:say('Please tell me how much gold it is you would like to deposit.', cid)
  Topic[cid] = 1
  elseif getPlayerMoney(cid) >= getCount(msg) then
  count[cid] = getCount(msg)
  npcHandler:say('Would you really like to deposit ' .. count[cid] .. ' gold?', cid)
  Topic[cid] = 2
  else
  npcHandler:say('You do not have enough gold.', cid)
  Topic[cid] = nil
  end
  elseif msgcontains(msg, 'yes') and Topic[cid] == 2 then
  if doPlayerRemoveMoney(cid, count[cid]) then
  doPlayerSetBalance(cid, getPlayerBalance(cid) + count[cid])
  updatePlayerBalance(getPlayerName(cid), getPlayerBalance(cid))
  npcHandler:say('Alright, we have added the amount of ' .. count[cid] .. ' gold to your balance. You can withdraw your money anytime you want to.', cid)
  else
  npcHandler:say('I am inconsolable, but it seems you have lost your gold. I hope you get it back.', cid)
  end
  Topic[cid] = nil
  elseif msgcontains(msg, 'no') and Topic[cid] == 2 then
  npcHandler:say('As you wish. Is there something else I can do for you?', cid)
  Topic[cid] = nil
  elseif msgcontains(msg, 'withdraw') then
  if getCount(msg) == 0 then
  npcHandler:say('Sure, you want nothing you get nothing!', cid)
  Topic[cid] = nil
  elseif getCount(msg) ~= -1 then
  if getPlayerBalance(cid) >= getCount(msg) then
  count[cid] = getCount(msg)
  npcHandler:say('Are you sure you wish to withdraw ' .. count[cid] .. ' gold from your bank account?', cid)
  Topic[cid] = 4
  else
  npcHandler:say('There is not enough gold on your account.', cid)
  Topic[cid] = nil
  end
  elseif getPlayerBalance(cid) == 0 then
  npcHandler:say('You don\'t have any money on your bank account.', cid)
  Topic[cid] = nil
  else
  npcHandler:say('Please tell me how much gold you would like to withdraw.', cid)
  Topic[cid] = 3
  end
  elseif Topic[cid] == 3 then
  if getCount(msg) == -1 then
  npcHandler:say('Please tell me how much gold you would like to withdraw.', cid)
  Topic[cid] = 3
  elseif getPlayerBalance(cid) >= getCount(msg) then
  count[cid] = getCount(msg)
  npcHandler:say('Are you sure you wish to withdraw ' .. count[cid] .. ' gold from your bank account?', cid)
  Topic[cid] = 4
  else
  npcHandler:say('There is not enough gold on your account.', cid)
  Topic[cid] = nil
  end
  elseif msgcontains(msg, 'yes') and Topic[cid] == 4 then
  if getPlayerBalance(cid) >= count[cid] then
  doPlayerAddMoney(cid, count[cid])
  doPlayerSetBalance(cid, getPlayerBalance(cid) - count[cid])
  updatePlayerBalance(getPlayerName(cid), getPlayerBalance(cid))
  npcHandler:say('Here you are, ' .. count[cid] .. ' gold. Please let me know if there is something else I can do for you.', cid)
  else
  npcHandler:say('There is not enough gold on your account.', cid)
  end
  Topic[cid] = nil
  elseif msgcontains(msg, 'no') and Topic[cid] == 4 then
  npcHandler:say('The customer is king! Come back anytime you want to if you wish to withdraw your money.', cid)
  Topic[cid] = nil
  elseif msgcontains(msg, 'transfer') then
  if getCount(msg) == 0 then
  npcHandler:say('Please think about it. Okay?', cid)
  Topic[cid] = nil
  elseif getCount(msg) ~= -1 then
  
  count[cid] = getCount(msg)
  if getPlayerBalance(cid) >= count[cid] then
  npcHandler:say('Who would you like to transfer ' .. count[cid] .. ' gold to?', cid)
  Topic[cid] = 6
  else
  npcHandler:say('There is not enough gold on your account.', cid)
  Topic[cid] = nil
  end

  else
  npcHandler:say('Please tell me the amount of gold you would like to transfer.', cid)
  Topic[cid] = 5
  end
  elseif Topic[cid] == 5 then
  if getCount(msg) == -1 then
  npcHandler:say('Please tell me the amount of gold you would like to transfer.', cid)
  Topic[cid] = 5
  else
  count[cid] = getCount(msg)
  if getPlayerBalance(cid) >= count[cid] then
  npcHandler:say('Who would you like to transfer ' .. count[cid] .. ' gold to?', cid)
  Topic[cid] = 6
  else
  npcHandler:say('There is not enough gold on your account.', cid)
  Topic[cid] = nil
  end
  end
  elseif Topic[cid] == 6 then
  local v = getPlayerByName(msg)
  if getPlayerBalance(cid) >= count[cid] then
  if v and getPlayerTown(msg:lower()) ~= 7 and getPlayerTown(msg:lower()) ~= 9 then
  transfer[cid] = msg
  npcHandler:say('Would you really like to transfer ' .. count[cid] .. ' gold to ' .. getPlayerName(v) .. '?', cid)
  Topic[cid] = 7
  elseif getPlayerGUIDByName(msg:lower()) ~= 0 and getPlayerTown(msg:lower()) ~= 7 and getPlayerTown(msg:lower()) ~= 9 then
  transfer[cid] = msg
  npcHandler:say('Would you really like to transfer ' .. count[cid] .. ' gold to ' .. findPlayer(msg) .. '?', cid)
  Topic[cid] = 7  
  else
  npcHandler:say('This player does not exist on this world or is from Rookgaardia/Dawn Hills.', cid)
  Topic[cid] = nil
  end
  else
  npcHandler:say('There is not enough gold on your account.', cid)
  Topic[cid] = nil
  end
  elseif Topic[cid] == 7 and msgcontains(msg, 'yes') then
  if getPlayerBalance(cid) >= count[cid] then
  local v = getPlayerByName(transfer[cid])
  if v then
  doPlayerSetBalance(cid, getPlayerBalance(cid) - count[cid])
  updatePlayerBalance(getPlayerName(cid), getPlayerBalance(cid))
  doPlayerSetBalance(v, getPlayerBalance(v) + count[cid])
  updatePlayerBalance(getPlayerName(v), getPlayerBalance(v))
  npcHandler:say('Very well. You have transferred ' .. count[cid] .. ' gold to ' .. getPlayerName(v) .. '.', cid)
  elseif findPlayer(transfer[cid]):lower() == transfer[cid]:lower() then
  doPlayerSetBalance(cid, getPlayerBalance(cid) - count[cid])
  updatePlayerBalance(getPlayerName(cid), getPlayerBalance(cid))
  db.query('UPDATE players SET balance=balance+' .. count[cid] .. ' WHERE name=' .. db.escapeString(transfer[cid]) .. ' LIMIT 1')
  npcHandler:say('Very well. You have transferred ' .. count[cid] .. ' gold to ' .. findPlayer(transfer[cid]) .. '.', cid)
  else
  npcHandler:say('This player does not exist.', cid)
  end
  else
  npcHandler:say('There is not enough gold on your account.', cid)
  end
  Topic[cid] = nil
  elseif Topic[cid] == 7 and msgcontains(msg, 'no') then
  npcHandler:say('Alright, is there something else I can do for you?', cid)
  Topic[cid] = nil
  elseif msgcontains(msg, 'change gold') then
  npcHandler:say('How many platinum coins would you like to get?', cid)
  Topic[cid] = 8
  elseif Topic[cid] == 8 then
  if getCount(msg) < 1 then
  npcHandler:say('Hmm, can I help you with something else?', cid)
  Topic[cid] = nil
  else
  count[cid] = math.min(500, getCount(msg))
  npcHandler:say('So you would like me to change ' .. count[cid] * 100 .. ' of your gold coins into ' .. count[cid] .. ' platinum coins?', cid)
  Topic[cid] = 9
  end
  elseif Topic[cid] == 9 then
  if msgcontains(msg, 'yes') then
  if doPlayerRemoveItem(cid, 2148, count[cid] * 100) then
  npcHandler:say('Here you are.', cid)
  doPlayerAddItem(cid, 2152, count[cid])
  else
  npcHandler:say('Sorry, you do not have enough gold coins.', cid)
  end
  else
  npcHandler:say('Well, can I help you with something else?', cid)
  end
  Topic[cid] = nil
  elseif msgcontains(msg, 'change platinum') then
  npcHandler:say('Would you like to change your platinum coins into gold or crystal?', cid)
  Topic[cid] = 10
  elseif Topic[cid] == 10 then
  if msgcontains(msg, 'gold') then
  npcHandler:say('How many platinum coins would you like to change into gold?', cid)
  Topic[cid] = 11
  elseif msgcontains(msg, 'crystal') then
  npcHandler:say('How many crystal coins would you like to get?', cid)
  Topic[cid] = 13
  else
  npcHandler:say('Well, can I help you with something else?', cid)
  Topic[cid] = nil
  end
  elseif Topic[cid] == 11 then
  if getCount(msg) < 1 then
  npcHandler:say('Hmm, can I help you with something else?', cid)
  Topic[cid] = nil
  else
  count[cid] = math.min(500, getCount(msg))
  npcHandler:say('So you would like me to change ' .. count[cid] .. ' of your platinum coins into ' .. count[cid] * 100 .. ' gold coins for you?', cid)
  Topic[cid] = 12
  end
  elseif Topic[cid] == 12 then
  if msgcontains(msg, 'yes') then
  if doPlayerRemoveItem(cid, 2152, count[cid]) then
  npcHandler:say('Here you are.', cid)
  doPlayerAddItem(cid, 2148, count[cid] * 100)
  else
  npcHandler:say('Sorry, you do not have enough platinum coins.', cid)
  end
  else
  npcHandler:say('Well, can I help you with something else?', cid)
  end
  Topic[cid] = nil
  elseif Topic[cid] == 13 then
  if getCount(msg) < 1 then
  npcHandler:say('Hmm, can I help you with something else?', cid)
  Topic[cid] = nil
  else
  count[cid] = math.min(500, getCount(msg))
  npcHandler:say('So you would like me to change ' .. count[cid] * 100 .. ' of your platinum coins into ' .. count[cid] .. ' crystal coins for you?', cid)
  Topic[cid] = 14
  end
  elseif Topic[cid] == 14 then
  if msgcontains(msg, 'yes') then
  if doPlayerRemoveItem(cid, 2152, count[cid] * 100) then
  npcHandler:say('Here you are.', cid)
  doPlayerAddItem(cid, 2160, count[cid])
  else
  npcHandler:say('Sorry, you do not have enough platinum coins.', cid)
  end
  else
  npcHandler:say('Well, can I help you with something else?', cid)
  end
  Topic[cid] = nil
  elseif msgcontains(msg, 'change crystal') then
  npcHandler:say('How many crystal coins would you like to change into platinum?', cid)
  Topic[cid] = 15
  elseif Topic[cid] == 15 then
  if getCount(msg) == -1 or getCount(msg) == 0 then
  npcHandler:say('Hmm, can I help you with something else?', cid)
  Topic[cid] = nil
  else
  count[cid] = math.min(500, getCount(msg))
  npcHandler:say('So you would like me to change ' .. count[cid] .. ' of your crystal coins into ' .. count[cid] * 100 .. ' platinum coins for you?', cid)
  Topic[cid] = 16
  end
  elseif Topic[cid] == 16 then
  if msgcontains(msg, 'yes') then
  if doPlayerRemoveItem(cid, 2160, count[cid]) then
  npcHandler:say('Here you are.', cid)
  doPlayerAddItem(cid, 2152, count[cid] * 100)
  else
  npcHandler:say('Sorry, you do not have enough crystal coins.', cid)
  end
  else
  npcHandler:say('Well, can I help you with something else?', cid)
  end
  Topic[cid] = nil
  elseif msgcontains(msg, 'change') then
  npcHandler:say('There are three different coin types in Tibia: 100 gold coins equal 1 platinum coin, 100 platinum coins equal 1 crystal coin. So if you\'d like to change 100 gold into 1 platinum, simply say \'{change gold}\' and then \'1 platinum\'.', cid)
  Topic[cid] = nil
  elseif msgcontains(msg, 'bank') then
  npcHandler:say('We can change money for you. You can also access your bank account.', cid)
  Topic[cid] = nil
  end
  return true
end

npcHandler:setCallback(CALLBACK_GREET, greet)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
i dont want to download a shitty 0.4 server so not gonna help anymore, it is almost done and im too lazy cus you guys do not want to learn or to change ur engine, good bye.

Lol why you get so angry?
How could i study my engine?
I just need to finish it '-'
 
Again:

I tried to change somethings, but i got some errors when i tried to transfer
I changed:
Code:
  elseif Topic[cid] == 6 then
  local v = getPlayerByName(msg)
  if getPlayerBalance(cid) >= count[cid] then
  if v and getPlayerTown(msg:lower()) ~= 7 and getPlayerTown(msg:lower()) ~= 9 then
  transfer[cid] = msg
  npcHandler:say('Would you really like to transfer ' .. count[cid] .. ' gold to ' .. getPlayerName(v) .. '?', cid)
  Topic[cid] = 7
  elseif getPlayerGUIDByName(msg:lower()) ~= 0 and getPlayerTown(msg:lower()) ~= 7 and getPlayerTown(msg:lower()) ~= 9 then
  transfer[cid] = msg
  npcHandler:say('Would you really like to transfer ' .. count[cid] .. ' gold to ' .. findPlayer(msg) .. '?', cid)
  Topic[cid] = 7
  else
  npcHandler:say('This player does not exist on this world or is from Rookgaardia/Dawn Hills.', cid)
  Topic[cid] = nil
  end
  else
  npcHandler:say('There is not enough gold on your account.', cid)
  Topic[cid] = nil
  end

Errors:
Code:
[16:53:00.166] [Error - NpcScript Interface]
[16:53:00.166] data/npc/scripts/bank.lua:onCreatureSay
[16:53:00.166] Description:
[16:53:00.166] (internalGetPlayerInfo) Player not found when requesting player info #7

[16:53:00.166] [Error - NpcScript Interface]
[16:53:00.166] data/npc/scripts/bank.lua:onCreatureSay
[16:53:00.166] Description:
[16:53:00.166] (internalGetPlayerInfo) Player not found when requesting player info #7

Full code:
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local Topic, count, transfer = {}, {}, {}

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 getCount(s)
  local b, e = s:find('%d+')
  return b and e and math.min(4294967295, tonumber(s:sub(b, e))) or -1
end

local function findPlayer(name)
  local resultId = db.storeQuery('SELECT name FROM players WHERE name=' .. db.escapeString(name) .. ' LIMIT 1'), nil
  if resultId == false then
  return
  end
  local r = result.getDataString(resultId, "name")
  result.free(resultId)
  return r
end

local function vocation(name)
  local resultId = db.storeQuery('SELECT vocation FROM players WHERE name=' .. db.escapeString(name) .. ' LIMIT 1'), nil
  if resultId == false then
  return
  end
  local r = result.getDataInt(resultId, "vocation")
  result.free(resultId)
  return r
end

local function updatePlayerBalance(name, value)
  db.query('UPDATE players SET balance=' .. value .. ' WHERE name=' .. db.escapeString(name) .. ' LIMIT 1')
end

function greet(cid)
  Topic[cid], count[cid], transfer[cid] = nil, nil, nil
  return true
end

function creatureSayCallback(cid, type, msg)
  if not npcHandler:isFocused(cid) then
  return false
  elseif msgcontains(msg, 'balance') then
  npcHandler:say('Your account balance is ' .. getPlayerBalance(cid) .. ' gold.', cid)
  Topic[cid] = nil
  elseif msgcontains(msg, 'deposit') and msgcontains(msg, 'all') then
  if getPlayerMoney(cid) == 0 then
  npcHandler:say('You don\'t have any gold with you.', cid)
  Topic[cid] = nil
  else
  count[cid] = getPlayerMoney(cid)
  npcHandler:say('Would you really like to deposit ' .. count[cid] .. ' gold?', cid)
  Topic[cid] = 2
  end
  elseif msgcontains(msg, 'deposit') then
  if getCount(msg) == 0 then
  npcHandler:say('You are joking, aren\'t you??', cid)
  Topic[cid] = nil
  elseif getCount(msg) ~= -1 then
  if getPlayerMoney(cid) >= getCount(msg) then
  count[cid] = getCount(msg)
  npcHandler:say('Would you really like to deposit ' .. count[cid] .. ' gold?', cid)
  Topic[cid] = 2
  else
  npcHandler:say('You do not have enough gold.', cid)
  Topic[cid] = nil
  end
  elseif getPlayerMoney(cid) == 0 then
  npcHandler:say('You don\'t have any gold with you.', cid)
  Topic[cid] = nil
  else
  npcHandler:say('Please tell me how much gold it is you would like to deposit.', cid)
  Topic[cid] = 1
  end
  elseif Topic[cid] == 1 then
  if getCount(msg) == -1 then
  npcHandler:say('Please tell me how much gold it is you would like to deposit.', cid)
  Topic[cid] = 1
  elseif getPlayerMoney(cid) >= getCount(msg) then
  count[cid] = getCount(msg)
  npcHandler:say('Would you really like to deposit ' .. count[cid] .. ' gold?', cid)
  Topic[cid] = 2
  else
  npcHandler:say('You do not have enough gold.', cid)
  Topic[cid] = nil
  end
  elseif msgcontains(msg, 'yes') and Topic[cid] == 2 then
  if doPlayerRemoveMoney(cid, count[cid]) then
  doPlayerSetBalance(cid, getPlayerBalance(cid) + count[cid])
  updatePlayerBalance(getPlayerName(cid), getPlayerBalance(cid))
  npcHandler:say('Alright, we have added the amount of ' .. count[cid] .. ' gold to your balance. You can withdraw your money anytime you want to.', cid)
  else
  npcHandler:say('I am inconsolable, but it seems you have lost your gold. I hope you get it back.', cid)
  end
  Topic[cid] = nil
  elseif msgcontains(msg, 'no') and Topic[cid] == 2 then
  npcHandler:say('As you wish. Is there something else I can do for you?', cid)
  Topic[cid] = nil
  elseif msgcontains(msg, 'withdraw') then
  if getCount(msg) == 0 then
  npcHandler:say('Sure, you want nothing you get nothing!', cid)
  Topic[cid] = nil
  elseif getCount(msg) ~= -1 then
  if getPlayerBalance(cid) >= getCount(msg) then
  count[cid] = getCount(msg)
  npcHandler:say('Are you sure you wish to withdraw ' .. count[cid] .. ' gold from your bank account?', cid)
  Topic[cid] = 4
  else
  npcHandler:say('There is not enough gold on your account.', cid)
  Topic[cid] = nil
  end
  elseif getPlayerBalance(cid) == 0 then
  npcHandler:say('You don\'t have any money on your bank account.', cid)
  Topic[cid] = nil
  else
  npcHandler:say('Please tell me how much gold you would like to withdraw.', cid)
  Topic[cid] = 3
  end
  elseif Topic[cid] == 3 then
  if getCount(msg) == -1 then
  npcHandler:say('Please tell me how much gold you would like to withdraw.', cid)
  Topic[cid] = 3
  elseif getPlayerBalance(cid) >= getCount(msg) then
  count[cid] = getCount(msg)
  npcHandler:say('Are you sure you wish to withdraw ' .. count[cid] .. ' gold from your bank account?', cid)
  Topic[cid] = 4
  else
  npcHandler:say('There is not enough gold on your account.', cid)
  Topic[cid] = nil
  end
  elseif msgcontains(msg, 'yes') and Topic[cid] == 4 then
  if getPlayerBalance(cid) >= count[cid] then
  doPlayerAddMoney(cid, count[cid])
  doPlayerSetBalance(cid, getPlayerBalance(cid) - count[cid])
  updatePlayerBalance(getPlayerName(cid), getPlayerBalance(cid))
  npcHandler:say('Here you are, ' .. count[cid] .. ' gold. Please let me know if there is something else I can do for you.', cid)
  else
  npcHandler:say('There is not enough gold on your account.', cid)
  end
  Topic[cid] = nil
  elseif msgcontains(msg, 'no') and Topic[cid] == 4 then
  npcHandler:say('The customer is king! Come back anytime you want to if you wish to withdraw your money.', cid)
  Topic[cid] = nil
  elseif msgcontains(msg, 'transfer') then
  if getCount(msg) == 0 then
  npcHandler:say('Please think about it. Okay?', cid)
  Topic[cid] = nil
  elseif getCount(msg) ~= -1 then

  count[cid] = getCount(msg)
  if getPlayerBalance(cid) >= count[cid] then
  npcHandler:say('Who would you like to transfer ' .. count[cid] .. ' gold to?', cid)
  Topic[cid] = 6
  else
  npcHandler:say('There is not enough gold on your account.', cid)
  Topic[cid] = nil
  end

  else
  npcHandler:say('Please tell me the amount of gold you would like to transfer.', cid)
  Topic[cid] = 5
  end
  elseif Topic[cid] == 5 then
  if getCount(msg) == -1 then
  npcHandler:say('Please tell me the amount of gold you would like to transfer.', cid)
  Topic[cid] = 5
  else
  count[cid] = getCount(msg)
  if getPlayerBalance(cid) >= count[cid] then
  npcHandler:say('Who would you like to transfer ' .. count[cid] .. ' gold to?', cid)
  Topic[cid] = 6
  else
  npcHandler:say('There is not enough gold on your account.', cid)
  Topic[cid] = nil
  end
  end
  elseif Topic[cid] == 6 then
  local v = getPlayerByName(msg)
  if getPlayerBalance(cid) >= count[cid] then
  if v and getPlayerTown(msg:lower()) ~= 7 and getPlayerTown(msg:lower()) ~= 9 then
  transfer[cid] = msg
  npcHandler:say('Would you really like to transfer ' .. count[cid] .. ' gold to ' .. getPlayerName(v) .. '?', cid)
  Topic[cid] = 7
  elseif getPlayerGUIDByName(msg:lower()) ~= 0 and getPlayerTown(msg:lower()) ~= 7 and getPlayerTown(msg:lower()) ~= 9 then
  transfer[cid] = msg
  npcHandler:say('Would you really like to transfer ' .. count[cid] .. ' gold to ' .. findPlayer(msg) .. '?', cid)
  Topic[cid] = 7
  else
  npcHandler:say('This player does not exist on this world or is from Rookgaardia/Dawn Hills.', cid)
  Topic[cid] = nil
  end
  else
  npcHandler:say('There is not enough gold on your account.', cid)
  Topic[cid] = nil
  end
  elseif Topic[cid] == 7 and msgcontains(msg, 'yes') then
  if getPlayerBalance(cid) >= count[cid] then
  local v = getPlayerByName(transfer[cid])
  if v then
  doPlayerSetBalance(cid, getPlayerBalance(cid) - count[cid])
  updatePlayerBalance(getPlayerName(cid), getPlayerBalance(cid))
  doPlayerSetBalance(v, getPlayerBalance(v) + count[cid])
  updatePlayerBalance(getPlayerName(v), getPlayerBalance(v))
  npcHandler:say('Very well. You have transferred ' .. count[cid] .. ' gold to ' .. getPlayerName(v) .. '.', cid)
  elseif findPlayer(transfer[cid]):lower() == transfer[cid]:lower() then
  doPlayerSetBalance(cid, getPlayerBalance(cid) - count[cid])
  updatePlayerBalance(getPlayerName(cid), getPlayerBalance(cid))
  db.query('UPDATE players SET balance=balance+' .. count[cid] .. ' WHERE name=' .. db.escapeString(transfer[cid]) .. ' LIMIT 1')
  npcHandler:say('Very well. You have transferred ' .. count[cid] .. ' gold to ' .. findPlayer(transfer[cid]) .. '.', cid)
  else
  npcHandler:say('This player does not exist.', cid)
  end
  else
  npcHandler:say('There is not enough gold on your account.', cid)
  end
  Topic[cid] = nil
  elseif Topic[cid] == 7 and msgcontains(msg, 'no') then
  npcHandler:say('Alright, is there something else I can do for you?', cid)
  Topic[cid] = nil
  elseif msgcontains(msg, 'change gold') then
  npcHandler:say('How many platinum coins would you like to get?', cid)
  Topic[cid] = 8
  elseif Topic[cid] == 8 then
  if getCount(msg) < 1 then
  npcHandler:say('Hmm, can I help you with something else?', cid)
  Topic[cid] = nil
  else
  count[cid] = math.min(500, getCount(msg))
  npcHandler:say('So you would like me to change ' .. count[cid] * 100 .. ' of your gold coins into ' .. count[cid] .. ' platinum coins?', cid)
  Topic[cid] = 9
  end
  elseif Topic[cid] == 9 then
  if msgcontains(msg, 'yes') then
  if doPlayerRemoveItem(cid, 2148, count[cid] * 100) then
  npcHandler:say('Here you are.', cid)
  doPlayerAddItem(cid, 2152, count[cid])
  else
  npcHandler:say('Sorry, you do not have enough gold coins.', cid)
  end
  else
  npcHandler:say('Well, can I help you with something else?', cid)
  end
  Topic[cid] = nil
  elseif msgcontains(msg, 'change platinum') then
  npcHandler:say('Would you like to change your platinum coins into gold or crystal?', cid)
  Topic[cid] = 10
  elseif Topic[cid] == 10 then
  if msgcontains(msg, 'gold') then
  npcHandler:say('How many platinum coins would you like to change into gold?', cid)
  Topic[cid] = 11
  elseif msgcontains(msg, 'crystal') then
  npcHandler:say('How many crystal coins would you like to get?', cid)
  Topic[cid] = 13
  else
  npcHandler:say('Well, can I help you with something else?', cid)
  Topic[cid] = nil
  end
  elseif Topic[cid] == 11 then
  if getCount(msg) < 1 then
  npcHandler:say('Hmm, can I help you with something else?', cid)
  Topic[cid] = nil
  else
  count[cid] = math.min(500, getCount(msg))
  npcHandler:say('So you would like me to change ' .. count[cid] .. ' of your platinum coins into ' .. count[cid] * 100 .. ' gold coins for you?', cid)
  Topic[cid] = 12
  end
  elseif Topic[cid] == 12 then
  if msgcontains(msg, 'yes') then
  if doPlayerRemoveItem(cid, 2152, count[cid]) then
  npcHandler:say('Here you are.', cid)
  doPlayerAddItem(cid, 2148, count[cid] * 100)
  else
  npcHandler:say('Sorry, you do not have enough platinum coins.', cid)
  end
  else
  npcHandler:say('Well, can I help you with something else?', cid)
  end
  Topic[cid] = nil
  elseif Topic[cid] == 13 then
  if getCount(msg) < 1 then
  npcHandler:say('Hmm, can I help you with something else?', cid)
  Topic[cid] = nil
  else
  count[cid] = math.min(500, getCount(msg))
  npcHandler:say('So you would like me to change ' .. count[cid] * 100 .. ' of your platinum coins into ' .. count[cid] .. ' crystal coins for you?', cid)
  Topic[cid] = 14
  end
  elseif Topic[cid] == 14 then
  if msgcontains(msg, 'yes') then
  if doPlayerRemoveItem(cid, 2152, count[cid] * 100) then
  npcHandler:say('Here you are.', cid)
  doPlayerAddItem(cid, 2160, count[cid])
  else
  npcHandler:say('Sorry, you do not have enough platinum coins.', cid)
  end
  else
  npcHandler:say('Well, can I help you with something else?', cid)
  end
  Topic[cid] = nil
  elseif msgcontains(msg, 'change crystal') then
  npcHandler:say('How many crystal coins would you like to change into platinum?', cid)
  Topic[cid] = 15
  elseif Topic[cid] == 15 then
  if getCount(msg) == -1 or getCount(msg) == 0 then
  npcHandler:say('Hmm, can I help you with something else?', cid)
  Topic[cid] = nil
  else
  count[cid] = math.min(500, getCount(msg))
  npcHandler:say('So you would like me to change ' .. count[cid] .. ' of your crystal coins into ' .. count[cid] * 100 .. ' platinum coins for you?', cid)
  Topic[cid] = 16
  end
  elseif Topic[cid] == 16 then
  if msgcontains(msg, 'yes') then
  if doPlayerRemoveItem(cid, 2160, count[cid]) then
  npcHandler:say('Here you are.', cid)
  doPlayerAddItem(cid, 2152, count[cid] * 100)
  else
  npcHandler:say('Sorry, you do not have enough crystal coins.', cid)
  end
  else
  npcHandler:say('Well, can I help you with something else?', cid)
  end
  Topic[cid] = nil
  elseif msgcontains(msg, 'change') then
  npcHandler:say('There are three different coin types in Tibia: 100 gold coins equal 1 platinum coin, 100 platinum coins equal 1 crystal coin. So if you\'d like to change 100 gold into 1 platinum, simply say \'{change gold}\' and then \'1 platinum\'.', cid)
  Topic[cid] = nil
  elseif msgcontains(msg, 'bank') then
  npcHandler:say('We can change money for you. You can also access your bank account.', cid)
  Topic[cid] = nil
  end
  return true
end

npcHandler:setCallback(CALLBACK_GREET, greet)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Again:

I tried to change somethings, but i got some errors when i tried to transfer
I changed:
Code:
  elseif Topic[cid] == 6 then
  local v = getPlayerByName(msg)
  if getPlayerBalance(cid) >= count[cid] then
  if v and getPlayerTown(msg:lower()) ~= 7 and getPlayerTown(msg:lower()) ~= 9 then
  transfer[cid] = msg
  npcHandler:say('Would you really like to transfer ' .. count[cid] .. ' gold to ' .. getPlayerName(v) .. '?', cid)
  Topic[cid] = 7
  elseif getPlayerGUIDByName(msg:lower()) ~= 0 and getPlayerTown(msg:lower()) ~= 7 and getPlayerTown(msg:lower()) ~= 9 then
  transfer[cid] = msg
  npcHandler:say('Would you really like to transfer ' .. count[cid] .. ' gold to ' .. findPlayer(msg) .. '?', cid)
  Topic[cid] = 7
  else
  npcHandler:say('This player does not exist on this world or is from Rookgaardia/Dawn Hills.', cid)
  Topic[cid] = nil
  end
  else
  npcHandler:say('There is not enough gold on your account.', cid)
  Topic[cid] = nil
  end

Errors:
Code:
[16:53:00.166] [Error - NpcScript Interface]
[16:53:00.166] data/npc/scripts/bank.lua:onCreatureSay
[16:53:00.166] Description:
[16:53:00.166] (internalGetPlayerInfo) Player not found when requesting player info #7

[16:53:00.166] [Error - NpcScript Interface]
[16:53:00.166] data/npc/scripts/bank.lua:onCreatureSay
[16:53:00.166] Description:
[16:53:00.166] (internalGetPlayerInfo) Player not found when requesting player info #7

Full code:
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local Topic, count, transfer = {}, {}, {}

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 getCount(s)
  local b, e = s:find('%d+')
  return b and e and math.min(4294967295, tonumber(s:sub(b, e))) or -1
end

local function findPlayer(name)
  local resultId = db.storeQuery('SELECT name FROM players WHERE name=' .. db.escapeString(name) .. ' LIMIT 1'), nil
  if resultId == false then
  return
  end
  local r = result.getDataString(resultId, "name")
  result.free(resultId)
  return r
end

local function vocation(name)
  local resultId = db.storeQuery('SELECT vocation FROM players WHERE name=' .. db.escapeString(name) .. ' LIMIT 1'), nil
  if resultId == false then
  return
  end
  local r = result.getDataInt(resultId, "vocation")
  result.free(resultId)
  return r
end

local function updatePlayerBalance(name, value)
  db.query('UPDATE players SET balance=' .. value .. ' WHERE name=' .. db.escapeString(name) .. ' LIMIT 1')
end

function greet(cid)
  Topic[cid], count[cid], transfer[cid] = nil, nil, nil
  return true
end

function creatureSayCallback(cid, type, msg)
  if not npcHandler:isFocused(cid) then
  return false
  elseif msgcontains(msg, 'balance') then
  npcHandler:say('Your account balance is ' .. getPlayerBalance(cid) .. ' gold.', cid)
  Topic[cid] = nil
  elseif msgcontains(msg, 'deposit') and msgcontains(msg, 'all') then
  if getPlayerMoney(cid) == 0 then
  npcHandler:say('You don\'t have any gold with you.', cid)
  Topic[cid] = nil
  else
  count[cid] = getPlayerMoney(cid)
  npcHandler:say('Would you really like to deposit ' .. count[cid] .. ' gold?', cid)
  Topic[cid] = 2
  end
  elseif msgcontains(msg, 'deposit') then
  if getCount(msg) == 0 then
  npcHandler:say('You are joking, aren\'t you??', cid)
  Topic[cid] = nil
  elseif getCount(msg) ~= -1 then
  if getPlayerMoney(cid) >= getCount(msg) then
  count[cid] = getCount(msg)
  npcHandler:say('Would you really like to deposit ' .. count[cid] .. ' gold?', cid)
  Topic[cid] = 2
  else
  npcHandler:say('You do not have enough gold.', cid)
  Topic[cid] = nil
  end
  elseif getPlayerMoney(cid) == 0 then
  npcHandler:say('You don\'t have any gold with you.', cid)
  Topic[cid] = nil
  else
  npcHandler:say('Please tell me how much gold it is you would like to deposit.', cid)
  Topic[cid] = 1
  end
  elseif Topic[cid] == 1 then
  if getCount(msg) == -1 then
  npcHandler:say('Please tell me how much gold it is you would like to deposit.', cid)
  Topic[cid] = 1
  elseif getPlayerMoney(cid) >= getCount(msg) then
  count[cid] = getCount(msg)
  npcHandler:say('Would you really like to deposit ' .. count[cid] .. ' gold?', cid)
  Topic[cid] = 2
  else
  npcHandler:say('You do not have enough gold.', cid)
  Topic[cid] = nil
  end
  elseif msgcontains(msg, 'yes') and Topic[cid] == 2 then
  if doPlayerRemoveMoney(cid, count[cid]) then
  doPlayerSetBalance(cid, getPlayerBalance(cid) + count[cid])
  updatePlayerBalance(getPlayerName(cid), getPlayerBalance(cid))
  npcHandler:say('Alright, we have added the amount of ' .. count[cid] .. ' gold to your balance. You can withdraw your money anytime you want to.', cid)
  else
  npcHandler:say('I am inconsolable, but it seems you have lost your gold. I hope you get it back.', cid)
  end
  Topic[cid] = nil
  elseif msgcontains(msg, 'no') and Topic[cid] == 2 then
  npcHandler:say('As you wish. Is there something else I can do for you?', cid)
  Topic[cid] = nil
  elseif msgcontains(msg, 'withdraw') then
  if getCount(msg) == 0 then
  npcHandler:say('Sure, you want nothing you get nothing!', cid)
  Topic[cid] = nil
  elseif getCount(msg) ~= -1 then
  if getPlayerBalance(cid) >= getCount(msg) then
  count[cid] = getCount(msg)
  npcHandler:say('Are you sure you wish to withdraw ' .. count[cid] .. ' gold from your bank account?', cid)
  Topic[cid] = 4
  else
  npcHandler:say('There is not enough gold on your account.', cid)
  Topic[cid] = nil
  end
  elseif getPlayerBalance(cid) == 0 then
  npcHandler:say('You don\'t have any money on your bank account.', cid)
  Topic[cid] = nil
  else
  npcHandler:say('Please tell me how much gold you would like to withdraw.', cid)
  Topic[cid] = 3
  end
  elseif Topic[cid] == 3 then
  if getCount(msg) == -1 then
  npcHandler:say('Please tell me how much gold you would like to withdraw.', cid)
  Topic[cid] = 3
  elseif getPlayerBalance(cid) >= getCount(msg) then
  count[cid] = getCount(msg)
  npcHandler:say('Are you sure you wish to withdraw ' .. count[cid] .. ' gold from your bank account?', cid)
  Topic[cid] = 4
  else
  npcHandler:say('There is not enough gold on your account.', cid)
  Topic[cid] = nil
  end
  elseif msgcontains(msg, 'yes') and Topic[cid] == 4 then
  if getPlayerBalance(cid) >= count[cid] then
  doPlayerAddMoney(cid, count[cid])
  doPlayerSetBalance(cid, getPlayerBalance(cid) - count[cid])
  updatePlayerBalance(getPlayerName(cid), getPlayerBalance(cid))
  npcHandler:say('Here you are, ' .. count[cid] .. ' gold. Please let me know if there is something else I can do for you.', cid)
  else
  npcHandler:say('There is not enough gold on your account.', cid)
  end
  Topic[cid] = nil
  elseif msgcontains(msg, 'no') and Topic[cid] == 4 then
  npcHandler:say('The customer is king! Come back anytime you want to if you wish to withdraw your money.', cid)
  Topic[cid] = nil
  elseif msgcontains(msg, 'transfer') then
  if getCount(msg) == 0 then
  npcHandler:say('Please think about it. Okay?', cid)
  Topic[cid] = nil
  elseif getCount(msg) ~= -1 then

  count[cid] = getCount(msg)
  if getPlayerBalance(cid) >= count[cid] then
  npcHandler:say('Who would you like to transfer ' .. count[cid] .. ' gold to?', cid)
  Topic[cid] = 6
  else
  npcHandler:say('There is not enough gold on your account.', cid)
  Topic[cid] = nil
  end

  else
  npcHandler:say('Please tell me the amount of gold you would like to transfer.', cid)
  Topic[cid] = 5
  end
  elseif Topic[cid] == 5 then
  if getCount(msg) == -1 then
  npcHandler:say('Please tell me the amount of gold you would like to transfer.', cid)
  Topic[cid] = 5
  else
  count[cid] = getCount(msg)
  if getPlayerBalance(cid) >= count[cid] then
  npcHandler:say('Who would you like to transfer ' .. count[cid] .. ' gold to?', cid)
  Topic[cid] = 6
  else
  npcHandler:say('There is not enough gold on your account.', cid)
  Topic[cid] = nil
  end
  end
  elseif Topic[cid] == 6 then
  local v = getPlayerByName(msg)
  if getPlayerBalance(cid) >= count[cid] then
  if v and getPlayerTown(msg:lower()) ~= 7 and getPlayerTown(msg:lower()) ~= 9 then
  transfer[cid] = msg
  npcHandler:say('Would you really like to transfer ' .. count[cid] .. ' gold to ' .. getPlayerName(v) .. '?', cid)
  Topic[cid] = 7
  elseif getPlayerGUIDByName(msg:lower()) ~= 0 and getPlayerTown(msg:lower()) ~= 7 and getPlayerTown(msg:lower()) ~= 9 then
  transfer[cid] = msg
  npcHandler:say('Would you really like to transfer ' .. count[cid] .. ' gold to ' .. findPlayer(msg) .. '?', cid)
  Topic[cid] = 7
  else
  npcHandler:say('This player does not exist on this world or is from Rookgaardia/Dawn Hills.', cid)
  Topic[cid] = nil
  end
  else
  npcHandler:say('There is not enough gold on your account.', cid)
  Topic[cid] = nil
  end
  elseif Topic[cid] == 7 and msgcontains(msg, 'yes') then
  if getPlayerBalance(cid) >= count[cid] then
  local v = getPlayerByName(transfer[cid])
  if v then
  doPlayerSetBalance(cid, getPlayerBalance(cid) - count[cid])
  updatePlayerBalance(getPlayerName(cid), getPlayerBalance(cid))
  doPlayerSetBalance(v, getPlayerBalance(v) + count[cid])
  updatePlayerBalance(getPlayerName(v), getPlayerBalance(v))
  npcHandler:say('Very well. You have transferred ' .. count[cid] .. ' gold to ' .. getPlayerName(v) .. '.', cid)
  elseif findPlayer(transfer[cid]):lower() == transfer[cid]:lower() then
  doPlayerSetBalance(cid, getPlayerBalance(cid) - count[cid])
  updatePlayerBalance(getPlayerName(cid), getPlayerBalance(cid))
  db.query('UPDATE players SET balance=balance+' .. count[cid] .. ' WHERE name=' .. db.escapeString(transfer[cid]) .. ' LIMIT 1')
  npcHandler:say('Very well. You have transferred ' .. count[cid] .. ' gold to ' .. findPlayer(transfer[cid]) .. '.', cid)
  else
  npcHandler:say('This player does not exist.', cid)
  end
  else
  npcHandler:say('There is not enough gold on your account.', cid)
  end
  Topic[cid] = nil
  elseif Topic[cid] == 7 and msgcontains(msg, 'no') then
  npcHandler:say('Alright, is there something else I can do for you?', cid)
  Topic[cid] = nil
  elseif msgcontains(msg, 'change gold') then
  npcHandler:say('How many platinum coins would you like to get?', cid)
  Topic[cid] = 8
  elseif Topic[cid] == 8 then
  if getCount(msg) < 1 then
  npcHandler:say('Hmm, can I help you with something else?', cid)
  Topic[cid] = nil
  else
  count[cid] = math.min(500, getCount(msg))
  npcHandler:say('So you would like me to change ' .. count[cid] * 100 .. ' of your gold coins into ' .. count[cid] .. ' platinum coins?', cid)
  Topic[cid] = 9
  end
  elseif Topic[cid] == 9 then
  if msgcontains(msg, 'yes') then
  if doPlayerRemoveItem(cid, 2148, count[cid] * 100) then
  npcHandler:say('Here you are.', cid)
  doPlayerAddItem(cid, 2152, count[cid])
  else
  npcHandler:say('Sorry, you do not have enough gold coins.', cid)
  end
  else
  npcHandler:say('Well, can I help you with something else?', cid)
  end
  Topic[cid] = nil
  elseif msgcontains(msg, 'change platinum') then
  npcHandler:say('Would you like to change your platinum coins into gold or crystal?', cid)
  Topic[cid] = 10
  elseif Topic[cid] == 10 then
  if msgcontains(msg, 'gold') then
  npcHandler:say('How many platinum coins would you like to change into gold?', cid)
  Topic[cid] = 11
  elseif msgcontains(msg, 'crystal') then
  npcHandler:say('How many crystal coins would you like to get?', cid)
  Topic[cid] = 13
  else
  npcHandler:say('Well, can I help you with something else?', cid)
  Topic[cid] = nil
  end
  elseif Topic[cid] == 11 then
  if getCount(msg) < 1 then
  npcHandler:say('Hmm, can I help you with something else?', cid)
  Topic[cid] = nil
  else
  count[cid] = math.min(500, getCount(msg))
  npcHandler:say('So you would like me to change ' .. count[cid] .. ' of your platinum coins into ' .. count[cid] * 100 .. ' gold coins for you?', cid)
  Topic[cid] = 12
  end
  elseif Topic[cid] == 12 then
  if msgcontains(msg, 'yes') then
  if doPlayerRemoveItem(cid, 2152, count[cid]) then
  npcHandler:say('Here you are.', cid)
  doPlayerAddItem(cid, 2148, count[cid] * 100)
  else
  npcHandler:say('Sorry, you do not have enough platinum coins.', cid)
  end
  else
  npcHandler:say('Well, can I help you with something else?', cid)
  end
  Topic[cid] = nil
  elseif Topic[cid] == 13 then
  if getCount(msg) < 1 then
  npcHandler:say('Hmm, can I help you with something else?', cid)
  Topic[cid] = nil
  else
  count[cid] = math.min(500, getCount(msg))
  npcHandler:say('So you would like me to change ' .. count[cid] * 100 .. ' of your platinum coins into ' .. count[cid] .. ' crystal coins for you?', cid)
  Topic[cid] = 14
  end
  elseif Topic[cid] == 14 then
  if msgcontains(msg, 'yes') then
  if doPlayerRemoveItem(cid, 2152, count[cid] * 100) then
  npcHandler:say('Here you are.', cid)
  doPlayerAddItem(cid, 2160, count[cid])
  else
  npcHandler:say('Sorry, you do not have enough platinum coins.', cid)
  end
  else
  npcHandler:say('Well, can I help you with something else?', cid)
  end
  Topic[cid] = nil
  elseif msgcontains(msg, 'change crystal') then
  npcHandler:say('How many crystal coins would you like to change into platinum?', cid)
  Topic[cid] = 15
  elseif Topic[cid] == 15 then
  if getCount(msg) == -1 or getCount(msg) == 0 then
  npcHandler:say('Hmm, can I help you with something else?', cid)
  Topic[cid] = nil
  else
  count[cid] = math.min(500, getCount(msg))
  npcHandler:say('So you would like me to change ' .. count[cid] .. ' of your crystal coins into ' .. count[cid] * 100 .. ' platinum coins for you?', cid)
  Topic[cid] = 16
  end
  elseif Topic[cid] == 16 then
  if msgcontains(msg, 'yes') then
  if doPlayerRemoveItem(cid, 2160, count[cid]) then
  npcHandler:say('Here you are.', cid)
  doPlayerAddItem(cid, 2152, count[cid] * 100)
  else
  npcHandler:say('Sorry, you do not have enough crystal coins.', cid)
  end
  else
  npcHandler:say('Well, can I help you with something else?', cid)
  end
  Topic[cid] = nil
  elseif msgcontains(msg, 'change') then
  npcHandler:say('There are three different coin types in Tibia: 100 gold coins equal 1 platinum coin, 100 platinum coins equal 1 crystal coin. So if you\'d like to change 100 gold into 1 platinum, simply say \'{change gold}\' and then \'1 platinum\'.', cid)
  Topic[cid] = nil
  elseif msgcontains(msg, 'bank') then
  npcHandler:say('We can change money for you. You can also access your bank account.', cid)
  Topic[cid] = nil
  end
  return true
end

npcHandler:setCallback(CALLBACK_GREET, greet)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Back
Top