Togu
Advanced OT User
Since the original forgottenserver on GitHub doesn't have an Bank NPC, I will post that one that I made getting some codes on the internet.
Using this feature I've found many functions, they deserve the credits:
orts/server
You will have to add on data/lib/core/player.lua: pasteBin
and then in data/npc/scripts/bank.lua: pasteBin
I didn't tested the guild bank functions and features, but player deposit, withdraw, balance and transfer are working.
Using this feature I've found many functions, they deserve the credits:
orts/server
You will have to add on data/lib/core/player.lua: pasteBin
Lua:
function Player.depositMoney(self, amount)
if not self:removeMoney(amount) then
return false
end
self:setBankBalance(self:getBankBalance() + amount)
return true
end
function Player.withdrawMoney(self, amount)
local balance = self:getBankBalance()
if amount > balance or not self:addMoney(amount) then
return false
end
self:setBankBalance(balance - amount)
return true
end
function Player.transferMoneyTo(self, target, amount)
local balance = self:getBankBalance()
if amount > balance then
return false
end
local targetPlayer = Player(target)
if targetPlayer then
targetPlayer:setBankBalance(targetPlayer:getBankBalance() + amount)
else
if not playerExists(target) then
return false
end
db.query("UPDATE `players` SET `balance` = `balance` + '" .. amount .. "' WHERE `name` = " .. db.escapeString(target))
end
self:setBankBalance(self:getBankBalance() - amount)
return true
end
and then in data/npc/scripts/bank.lua: pasteBin
I didn't tested the guild bank functions and features, but player deposit, withdraw, balance and transfer are working.