• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Bank NPC TFS 1.1

You can use the npc once you copy the functions from the Rl map server.
I think theses ones are the only ones you need.

Code:
function getMoneyCount(string)
    local b, e = string:find("%d+")
    local money = b and e and tonumber(string:sub(b, e)) or -1
    if isValidMoney(money) then
        return money
    end
    return -1
end

function getMoneyWeight(money)
    local gold = money
    local crystal = math.floor(gold / 10000)
    gold = gold - crystal * 10000
    local platinum = math.floor(gold / 100)
    gold = gold - platinum * 100
    return (ItemType(2160):getWeight() * crystal) + (ItemType(2152):getWeight() * platinum) + (ItemType(2148):getWeight() * gold)
end

Regards Alw
 
Code:
Lua Script Error: [Npc interface]
data/npc/scripts/bank.lua:onCreatureSay
data/lib/compat/compat.lua:1136: attempt to call global 'isValidMoney' (a nil va
lue)
stack traceback:
        [C]: in function 'isValidMoney'
        data/lib/compat/compat.lua:1136: in function 'getMoneyCount'
        data/npc/scripts/bank.lua:86: in function 'callback'
        data/npc/lib/npcsystem/npchandler.lua:407: in function 'onCreatureSay'
        data/npc/scripts/bank.lua:10: in function <data/npc/scripts/bank.lua:10>
 
Code:
Lua Script Error: [Npc interface]
data/npc/scripts/bank.lua:onCreatureSay
data/lib/compat/compat.lua:1134: attempt to call global 'isNumber' (a nil value)

stack traceback:
        [C]: in function 'isNumber'
        data/lib/compat/compat.lua:1134: in function 'isValidMoney'
        data/lib/compat/compat.lua:1140: in function 'getMoneyCount'
        data/npc/scripts/bank.lua:86: in function 'callback'
        data/npc/lib/npcsystem/npchandler.lua:407: in function 'onCreatureSay'
        data/npc/scripts/bank.lua:10: in function <data/npc/scripts/bank.lua:10>
 
I did add alot of functions but these last 2 (isnumber and deposit money I didnt find them in orts files)

Code:
Lua Script Error: [Npc interface]
data/npc/scripts/bank.lua:onCreatureSay
data/npc/scripts/bank.lua:99: attempt to call method 'depositMoney' (a nil value
)
stack traceback:
        [C]: in function 'depositMoney'
        data/npc/scripts/bank.lua:99: in function 'callback'
        data/npc/lib/npcsystem/npchandler.lua:407: in function 'onCreatureSay'
        data/npc/scripts/bank.lua:10: in function <data/npc/scripts/bank.lua:10>
 
:O didnt know u could do that in github

sorry for double post but

i searched in github code searcher and couldnt find a lib for this

ITEM_CRYSTAL_COIN is this source now?

i want to add new currencys but I have no idea where I can do this
 
Last edited by a moderator:
These are two methods I found in luascript.cpp, this is in both 1.0 & 1.1
Code:
player:setBankBalance(bankBalance)
player:getBankBalance()
In 1.0 there is no lib directory however in 1.1 there is and if you look in the sources you will find that ITEM_CRYSTAL_COIN is defined inside of const.h with the item id & inside of item.cpp it has defined its monetary value.

So if you go to data\lib\core\item.lua you can attempt to re-write this method Item::getWorth() inside of item.lua and possibly itemtype.lua
 
Back
Top