• 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!

[Request] Bank NPC for TFS 1.0

tarantonio

Old School Player
Joined
Jun 21, 2009
Messages
865
Solutions
1
Reaction score
274
There is no working Bank NPC for TFS 1.0. I almost tried all bank npcs on this forum, but all have the same error, when you want to deposit money for example, and you say "yes" after" Are you sure to deposit X gold..." It does nothing.

This is the tricky part of the lua code:

Code:
--deposit
    if talk_state[cid] == 20 and getCount(msg) > 0 then
        talk_state[cid] = 21
        last_count[cid] = getCount(msg)
        sayText = 'Would you really like to deposit ' .. last_count[cid] .. ' gold coins?'
    elseif talk_state[cid] == 20 and msgcontains(msg, 'all') then
        if getPlayerMoney(cid) <= 0 then
            talk_state[cid] = 0
            sayText = 'You don\'t have any money.'
        else
            talk_state[cid] = 21
            last_count[cid] = getPlayerMoney(cid)
            sayText = 'Would you really like to deposit all your money, ' .. last_count[cid] .. ' gold coins?'
        end
    elseif talk_state[cid] == 21 and getCount(msg) <= 0 then
        if msgcontains(msg, 'yes') then
            if doPlayerDepositMoney(cid, last_count[cid]) == TRUE then
                sayText = 'You deposited ' .. last_count[cid] .. ' gold coins. Now your account balance is ' .. getPlayerBalance(cid) .. ' gold coins.'
            else
                sayText = 'You don\'t have ' .. last_count[cid] .. ' gold coins.'
            end
        else
            sayText = 'Well, can I help you with something else?'
        end
        talk_state[cid] = 0
      
    end

The problem is located in this line:

Code:
if doPlayerDepositMoney(cid, last_count[cid]) == TRUE then

In console it says: attempt to call global 'doPlayerDepositMoney' (a nil value)
 
Last edited:
It's because the function doPlayerDepositMoney does not exists.

However you could try with this, add the function to your global.lua
Code:
function doPlayerDepositMoney(cid, amount)
   if(not doPlayerRemoveMoney(cid, amount)) then
     return false
   end

   doPlayerSetBalance(cid, getPlayerBalance(cid) + amount)
   return true
end
 
Ninja, you are good. It works.

BTW TFS 1.0 is lacking on some old functions.

I added this on global.lua:

Code:
--Custom functions

function doPlayerDepositMoney(cid, amount)
  if(not doPlayerRemoveMoney(cid, amount)) then
    return false
  end

  doPlayerSetBalance(cid, getPlayerBalance(cid) + amount)
  return true
end

function doPlayerWithdrawMoney(cid, amount)
    local balance = getPlayerBalance(cid)
    if(amount > balance or not doPlayerAddMoney(cid, amount)) then
        return false
    end

    doPlayerSetBalance(cid, balance - amount)
    return true
end

transfer not working atm, i'm trying to fix it.
 
Last edited:
Back
Top