

modMinerTrade.getUrlDatabase = function()
	--Extensao '.tbl' ou '.db'
	local extension = ""
	if modMinerTrade.save_compressed then
		extension = ".db64"
	else
		extension = ".tbl"
	end
	return minetest.get_worldpath().."/minertrade"..extension
end

modMinerTrade.doBankSave = function()
	--modMinerTrade.debug("modMinerTrade.doBankSave() >>> "..modMinerTrade.getUrlDatabase())
	local file = io.open(modMinerTrade.getUrlDatabase(), "w")
	if file then
		local content = minetest.serialize(modMinerTrade.bank)
		--modMinerTrade.debug("modMinerTrade.doBankSave() >>> content = "..dump(content))
		if modMinerTrade.save_compressed then
			content = minetest.encode_base64(content)
		end
		file:write(content)
		file:close()
		minetest.log('action',"[MINERTRADE] Banco de dados salvo !")
	else
		minetest.log('error',"[MINERTRADE:ERRO] "..modMinerTrade.translate("The file '%s' is not in table format!"):format(modMinerTrade.getUrlDatabase()))
	end
end

modMinerTrade.doBankLoad = function()
	modMinerTrade.debug("modMinerTrade.doBankSave() >>> "..modMinerTrade.getUrlDatabase())
	local file = io.open(modMinerTrade.getUrlDatabase(), "r")
	if file then
		if modMinerTrade.save_compressed then
			modMinerTrade.bank = minetest.deserialize(minetest.decode_base64(file:read("*all")))
		else
			modMinerTrade.bank = minetest.deserialize(file:read("*all"))
		end
		modMinerTrade.debug("modMinerTrade.doBankLoad() >>> modMinerTrade.bank = "..dump(modMinerTrade.bank))
		file:close()
		if not modMinerTrade.bank or type(modMinerTrade.bank) ~= "table" then
			minetest.log('error',"[MINERTRADE:ERRO] "..modMinerTrade.translate("The file '%s' is not in table format!"):format(modMinerTrade.getUrlDatabase()))
			return { }
		else
			minetest.log('action',"[MINERTRADE] "..modMinerTrade.translate("Opening '%s'!"):format(modMinerTrade.getUrlDatabase()))
		end
	end
end

modMinerTrade.isExistAcount = function(playername)
	if modMinerTrade.bank.player[playername] ~= nil then
		return true
	else
		return false
	end
end

modMinerTrade.createAcount = function(playername)
	if modMinerTrade.bank.player[playername] == nil then
		modMinerTrade.bank.player[playername] = { 
			account_created = os.date("%Y/%b/%d %Hh:%Mm:%Ss"),
			balance = 0,
			statement = { }
		}
		modMinerTrade.bank.accounts = modMinerTrade.bank.accounts + 1
		return true
	else
		return false
	end
	
	return modMinerTrade.bank.player[playername].balance
end

modMinerTrade.getBalance = function(playername)
	if modMinerTrade.isExistAcount(playername) then
		return modMinerTrade.bank.player[playername].balance
	end
end

modMinerTrade.addBalance = function(playername, value)
	if value ~= nil and type(value) == "number" and value ~= 0 then
		if modMinerTrade.isExistAcount(playername) then
			modMinerTrade.bank.player[playername].balance = modMinerTrade.bank.player[playername].balance + value
			return true
		end
	end
	return false
end

modMinerTrade.addStatement = function(playername, value, description)
	if value ~= nil and type(value) == "number" and value ~= 0 then
		if modMinerTrade.isExistAcount(playername) then
			table.insert(
				modMinerTrade.bank.player[playername].statement,
				{
					when = os.date("%Y-%B-%d %Hh:%Mm:%Ss"),
					value = value,
					description = description,
				}
			)
			return true
		end
	end
	return false
end

modMinerTrade.getStatement = function(playername)
	if playername ~= nil and type(playername) == "string" and playername ~= "" then
		if modMinerTrade.isExistAcount(playername) then
			return modMinerTrade.bank.player[playername].statement
		end
	end
end

modMinerTrade.showAtm = {
	frmMain = function(playername) --FORMULÁRIO: PRINCIPAL / RAIZ
		local formspec = "size[15,10]"
			.."bgcolor[#636D7688;false]"
			--.."bgcolor[#636D76FF;false]"
			--..default.gui_bg
			--..default.gui_bg_img
			--..default.gui_slots
			
			--.."background[5.0,-0.25;10,10;default_steel_block.png^text_atm_front.png]"
			..        "box[0.00,0.10;4.50,9.5;#000000]"
			..     "button[0.25,0.50;4.00,0.5;btnBalance;"..minetest.formspec_escape(core.colorize("#FFFFFF", modMinerTrade.translate("BALANCE"))).."]"
			..     "button[0.25,1.25;4.00,0.5;btnStatement;"..minetest.formspec_escape(core.colorize("#FFFFFF", modMinerTrade.translate("STATEMENT"))).."]"
			..     "button[0.25,2.00;4.00,0.5;btnDeposits;"..minetest.formspec_escape(core.colorize("#444444", modMinerTrade.translate("DEPOSITS"))).."]"
			..     "button[0.25,2.75;4.00,0.5;btnWithdrawals;"..minetest.formspec_escape(core.colorize("#FFFFF", modMinerTrade.translate("WITHDRAWALS"))).."]" -- [DINHEIRO E CHECK]
			..     "button[0.25,3.50;4.00,0.5;btnTransfers;"..minetest.formspec_escape(core.colorize("#444444", modMinerTrade.translate("TRANSFERS"))).."]"
			..     "button[0.25,4.25;4.00,0.5;btnLoans;"..minetest.formspec_escape(core.colorize("#444444", modMinerTrade.translate("LOANS"))).."]" --Emprestimos
			..     "button[0.25,5.00;4.00,0.5;btnCreditCard;"..minetest.formspec_escape(core.colorize("#444444", modMinerTrade.translate("CREDIT CARD"))).."]" -- [EXPEDIR E MUDAR SENHA]
			..     "button[0.25,5.75;4.00,0.5;btnSetings;"..minetest.formspec_escape(core.colorize("#444444", modMinerTrade.translate("SETTINGS"))).."]" --Se quer ou não uma senha, se quer receber uma carta quando houver uma nova movimentacao.
			.."button_exit[0.25,6.50;4.00,0.5;;"..minetest.formspec_escape(core.colorize("#FFFFFF", modMinerTrade.translate("EXIT"))).."]"
			
			--.."box"   .."[5.0,0.25;9.5,9.5;#000000]"
			.."background[5.0,0.25;9.5,9.5;text_atm_front.png]"
			
		modMinerTrade.doSoundPlayer(playername, "sfx_atm", 5)
		minetest.show_formspec(playername, "frmAtmMain", formspec)
	end,
	frmBalance = function(playername) --FORMULÁRIO: SALDO
		local msgBalance = ""
		if modMinerTrade.isExistAcount(playername) then
			msgBalance = modMinerTrade.translate("You have %02d minercash."):format(modMinerTrade.getBalance(playername))
		else
			msgBalance = modMinerTrade.translate("Player '%s' is not an account holder of this bank."):format(playername)
		end

		local formspec = "size[15,10]"
		.."bgcolor[#636D7688;false]"
		--.."bgcolor[#636D76FF;false]"
		--..default.gui_bg
		--..default.gui_bg_img
		--..default.gui_slots
		
		--.."bgcolor[#636D76FF;false]"
		--.."background[-0.25,-0.25;10,11;safe_inside.png]"
		--.."button[0,0.0;4,0.5;btnAtmMain;"..minetest.formspec_escape(core.colorize("#FFFFFF", modMinerTrade.translate("BACK"))).."]"
		--.."button_exit[0,3.0;4,0.5;;"..minetest.formspec_escape(core.colorize("#FFFFFF", modMinerTrade.translate("EXIT"))).."]"
		
		..        "box[0.00,0.10;4.50,9.5;#000000]"
		..     "button[0.25,0.50;4.00,0.5;btnAtmMain;"..minetest.formspec_escape(core.colorize("#FFFFFF", modMinerTrade.translate("BACK"))).."]"
		--..     "button[0.25,1.25;4.00,0.5;btnStatement;"..minetest.formspec_escape(core.colorize("#888888", modMinerTrade.translate("STATEMENT"))).."]"
		--..     "button[0.25,2.00;4.00,0.5;btnDeposits;"..minetest.formspec_escape(core.colorize("#888888", modMinerTrade.translate("DEPOSITS"))).."]"
		--..     "button[0.25,2.75;4.00,0.5;btnWithdrawals;"..minetest.formspec_escape(core.colorize("#FFFFF", modMinerTrade.translate("WITHDRAWALS"))).."]" -- [DINHEIRO E CHECK]
		--..     "button[0.25,3.50;4.00,0.5;btnTransfers;"..minetest.formspec_escape(core.colorize("#888888", modMinerTrade.translate("TRANSFERS"))).."]"
		--..     "button[0.25,4.25;4.00,0.5;btnLoans;"..minetest.formspec_escape(core.colorize("#888888", modMinerTrade.translate("LOANS"))).."]" --Emprestimos
		--..     "button[0.25,5.00;4.00,0.5;btnCreditCard;"..minetest.formspec_escape(core.colorize("#888888", modMinerTrade.translate("CREDIT CARD"))).."]" -- [EXPEDIR E MUDAR SENHA]
		--..     "button[0.25,5.75;4.00,0.5;btnSetings;"..minetest.formspec_escape(core.colorize("#888888", modMinerTrade.translate("SETTINGS"))).."]" --Se quer ou não uma senha, se quer receber uma carta quando houver uma nova movimentacao.
		.."button_exit[0.25,6.50;4.00,0.5;;"..minetest.formspec_escape(core.colorize("#FFFFFF", modMinerTrade.translate("EXIT"))).."]"
		
		..       "box[5.0,0.25;9.5,9.5;#00000088]"
		.."background[5.0,0.25;9.5,9.5;text_atm_front.png]"
		
		--..     "label[5.25,0.50;"..minetest.formspec_escape(core.colorize("#00FFFF", modMinerTrade.translate("BALANCES")..":")).."]"
		--..     "label[5.25,2.50;"..minetest.formspec_escape(core.colorize("#00FFFF", msgBalance)).."]"
		..  "textarea[5.75,1.00;9.0,9.0;;"..minetest.formspec_escape(core.colorize("#00FFFF", modMinerTrade.translate("BALANCES")..":"))..";"..minetest.formspec_escape(core.colorize("#00FFFF", msgBalance)).."]"
		
		
		modMinerTrade.doSoundPlayer(playername, "sfx_atm", 5)
		minetest.show_formspec(
			playername, 
			"frmAtmBalance", 
			formspec
		)
	end,
	frmStatement = function(playername, selStatement) --FORMULÁRIO: SALDO
		local formspec = "size[15,10]"
		.."bgcolor[#636D7644;false]"
		--.."bgcolor[#636D76FF;false]"
		--..default.gui_bg
		--..default.gui_bg_img
		--..default.gui_slots
		
		--.."bgcolor[#636D76FF;false]"
		--.."background[-0.25,-0.25;10,11;safe_inside.png]"
		--.."button[0,0.0;4,0.5;btnAtmMain;"..minetest.formspec_escape(core.colorize("#FFFFFF", modMinerTrade.translate("BACK"))).."]"
		--.."button_exit[0,3.0;4,0.5;;"..minetest.formspec_escape(core.colorize("#FFFFFF", modMinerTrade.translate("EXIT"))).."]"
		
		..        "box[0.00,0.10;4.50,9.5;#000000]"
		..     "button[0.25,0.50;4.00,0.5;btnAtmMain;"..minetest.formspec_escape(core.colorize("#FFFFFF", modMinerTrade.translate("BACK"))).."]"
		--..     "button[0.25,1.25;4.00,0.5;btnStatement;"..minetest.formspec_escape(core.colorize("#888888", modMinerTrade.translate("STATEMENT"))).."]"
		--..     "button[0.25,2.00;4.00,0.5;btnDeposits;"..minetest.formspec_escape(core.colorize("#888888", modMinerTrade.translate("DEPOSITS"))).."]"
		--..     "button[0.25,2.75;4.00,0.5;btnWithdrawals;"..minetest.formspec_escape(core.colorize("#FFFFF", modMinerTrade.translate("WITHDRAWALS"))).."]" -- [DINHEIRO E CHECK]
		--..     "button[0.25,3.50;4.00,0.5;btnTransfers;"..minetest.formspec_escape(core.colorize("#888888", modMinerTrade.translate("TRANSFERS"))).."]"
		--..     "button[0.25,4.25;4.00,0.5;btnLoans;"..minetest.formspec_escape(core.colorize("#888888", modMinerTrade.translate("LOANS"))).."]" --Emprestimos
		--..     "button[0.25,5.00;4.00,0.5;btnCreditCard;"..minetest.formspec_escape(core.colorize("#888888", modMinerTrade.translate("CREDIT CARD"))).."]" -- [EXPEDIR E MUDAR SENHA]
		--..     "button[0.25,5.75;4.00,0.5;btnSetings;"..minetest.formspec_escape(core.colorize("#888888", modMinerTrade.translate("SETTINGS"))).."]" --Se quer ou não uma senha, se quer receber uma carta quando houver uma nova movimentacao.
		.."button_exit[0.25,6.50;4.00,0.5;;"..minetest.formspec_escape(core.colorize("#FFFFFF", modMinerTrade.translate("EXIT"))).."]"
		
		..       "box[5.0,0.25;9.5,9.5;#00000088]"
		--.."background[5.0,0.25;9.5,9.5;text_atm_front.png]"
		
		local msgStatement = "Select a bank statement to view transaction details!"
		local isAccount = modMinerTrade.isExistAcount(playername)
		if isAccount then
			formspec = formspec
			..   "label[5.25,0.50;"..minetest.formspec_escape(core.colorize("#00FFFF", modMinerTrade.translate("STATEMENT")..":")).."]"
			--..   "label[5.25,2.50;"..minetest.formspec_escape(core.colorize("#00FFFF", msgStatement)).."]"
			--"textarea[5.75,1.00;9.0,9.0;;"..minetest.formspec_escape(core.colorize("#00FFFF", modMinerTrade.translate("STATEMENT")..":"))..";"..minetest.formspec_escape(core.colorize("#00FFFF", msgStatement)).."]"
			
			local listStatement = modMinerTrade.getStatement(playername)
			local plusStatement = ""
			--..minetest.formspec_escape("QUANDO | VALOR")
			
			for i, oneStatement in ipairs(listStatement) do
				local sign = ""
				if oneStatement.value >= 1 then
					sign = "+"
				end
				--local line = oneStatement.when.." | "..sign..oneStatement.value.." minercash."
				local line = sign..oneStatement.value.." minercash. ["..oneStatement.when.."]"
				if plusStatement == "" then
					plusStatement = minetest.formspec_escape(line)
				else
					plusStatement = plusStatement..","..minetest.formspec_escape(line)
				end
			end
			local value = modMinerTrade.getBalance(playername)
			if value ~= nil then
				local sign = ""
				if value >= 1 then
					sign = "+"
				end
				modMinerTrade.getBalance(playername)
				
				plusStatement = plusStatement..","..minetest.formspec_escape(
					--os.date("%Y-%b-%d %Hh:%Mm:%Ss").." <<< "..sign..value.." minercash ("..modMinerTrade.translate("TOTAL")..")."
					modMinerTrade.translate("TOTAL")..": "..sign..value.." minercash."
					--.." ["..os.date("%Y-%b-%d %Hh:%Mm:%Ss").."]"
				)
			end

			local mySel = ""
			if selStatement ~= nil and type(selStatement)=="number" and selStatement >= 1 and selStatement <= #listStatement then
				mySel = selStatement
				msgStatement = dump(listStatement[selStatement].description)
			end
			formspec = formspec
			.."         style[fldStatement;bgcolor=red;textcolor=yellow;border=true]"
			..         "table[5.25,1.00;9.0,7.5;fldStatement;"..plusStatement..";"..mySel.."]"
			--..    "textlist[5.25,1.00;9.0,6.0;fldStatement;"..plusStatement..";"..mySel.."]"
			--.."tablecolumns[cell1,opt1_a,opt2_a;cell2,opt1_b,opt2_b;type_c,opt1_c,opt2_c]"
			--.."tableoptions[opt1;opt2;opt3]"
		else
			msgStatement = modMinerTrade.translate("Player '%s' is not an account holder of this bank."):format(playername)
		end

		formspec = formspec
		.."textarea[5.75,9.00;9.0,1.5;;"..minetest.formspec_escape(core.colorize("#00FFFF", modMinerTrade.translate("TRANSACTION DETAILS")..":"))..";"
			..minetest.formspec_escape(core.colorize("#00FFFF", msgStatement))
		.."]"
		
		
		
		minetest.show_formspec(
			playername, 
			"frmAtmStatement", 
			formspec
		)
	end,
	frmWithdrawals = function(playername) --FORMULÁRIO: EXTRATO
		local formspec = "size[9.5,10.5]"
			--.."bgcolor[#636D76FF;false]"
			--..default.gui_bg
			--..default.gui_bg_img
			--..default.gui_slots
			
			--.."bgcolor[#636D76FF;false]"
			.."background[-0.25,-0.25;10,11;safe_inside.png]"
			.."button[0,0.0;4,0.5;btnAtmMain;"..minetest.formspec_escape(core.colorize("#FFFFFF", modMinerTrade.translate("BACK"))).."]"
			.."button_exit[0,3.0;4,0.5;;"..minetest.formspec_escape(core.colorize("#FFFFFF", modMinerTrade.translate("EXIT"))).."]"
		
		modMinerTrade.doSoundPlayer(playername, "sfx_atm", 5)
		minetest.show_formspec(playername, "frmAtmWithdrawals", formspec)
	end,
	
}

modMinerTrade.onReceiveFields = function(player, formname, fields)
	local playername = player:get_player_name()
	--modMinerTrade.debug("modMinerTrade.onReceiveFields() >>> player = "..playername.." | formname = "..formname.." | fields = "..dump(fields))
	if fields.btnAtmMain ~= nil then
		modMinerTrade.showAtm.frmMain(playername)
	else
		if formname == "frmAtmMain"  then
			if fields.btnBalance ~= nil then
				modMinerTrade.showAtm.frmBalance(playername)
			elseif fields.btnStatement ~= nil then
				modMinerTrade.doSoundPlayer(playername, "sfx_atm", 5)
				modMinerTrade.showAtm.frmStatement(playername)
			elseif fields.btnWithdrawals ~= nil then
				modMinerTrade.showAtm.frmWithdrawals(playername)
			end
		elseif formname == "frmAtmStatement"  then
			--modMinerTrade.debug("modMinerTrade.onReceiveFields() >>> player = "..playername.." | formname = "..formname.." | fields = "..dump(fields))
			if fields.fldStatement ~= nil then
				local tblStatement = modMinerTrade.getStatement(playername)
				local fldStatement = minetest.explode_table_event(fields.fldStatement)
				if fldStatement.row ~= nil and type(fldStatement.row) == "number" and fldStatement.row >= 1 and fldStatement.row <= #tblStatement then
					modMinerTrade.debug("modMinerTrade.onReceiveFields() >>>  fldStatement = "..dump(fldStatement))
					modMinerTrade.showAtm.frmStatement(playername, fldStatement.row)
				end
			end
		end
	end
end

--###############################################################################################################

minetest.register_node("minertrade:atm", {
	description = modMinerTrade.translate("PUBLIC ATM\n* Save your money in the ATM, and withdraw your money in your Personal Safe or other ATM in the shops scattered around the map."),
	--inventory_image =  minetest.inventorycube("text_atm_front_1.png"),
	--inventory_image =  "text_atm_front_1.png",
	paramtype = "light",
	sunlight_propagates = true,
	light_source = default.LIGHT_MAX,
	paramtype2 = "facedir",
	
	--legacy_facedir_simple = true, --<=Nao sei para que serve!
	is_ground_content = false,
	groups = {cracky=1},
	--groups = {cracky=3,oddly_breakable_by_hand=3},
	--sounds = default.node_sound_glass_defaults(),
	tiles = {
		--[[
		"default_wood.png",
		"default_wood.png",
		"default_wood.png",
		"default_wood.png",
		"default_wood.png",
		"text_atm_front_1.png",
		--]]
		
		--[[ 
		"safe_side.png",
		"safe_side.png",
		"safe_side.png",
		"safe_side.png",
		"safe_side.png",
		"safe_side.png^text_atm_front.png",
		--]]
		
		"default_steel_block.png",
		"default_steel_block.png",
		"default_steel_block.png",
		"default_steel_block.png",
		"default_steel_block.png",
		"default_steel_block.png^text_atm_front.png",
	},

	on_place = function(itemstack, placer, pointed_thing)
		local playername = placer:get_player_name()

		if not pointed_thing.type == "node" then
			return itemstack
		end

		local posAbove = pointed_thing.above --acima
		local posUnder = pointed_thing.under --abaixo
		if not placer or not placer:is_player() or
			not minetest.registered_nodes[minetest.get_node(posAbove).name].buildable_to
		then --Verifica se pode construir sobre os objetos construiveis
			return itemstack
		end
		
		local nodeUnder = minetest.get_node(posUnder)
		if minetest.registered_nodes[nodeUnder.name].on_rightclick then --Verifica se o itema na mao do jogador tem funcao rightclick
			return minetest.registered_nodes[nodeUnder.name].on_rightclick(posUnder, nodeUnder, placer, itemstack)
		end
		
		if 
			minetest.get_player_privs(playername).server 
			or modMinerTrade.getNodesInRange(posAbove, 2, "minertrade:dispensingmachine")>=1 
		then
			local facedir = minetest.dir_to_facedir(placer:get_look_dir())
			--minetest.chat_send_player(playername, "[ATM] aaaaaa")
			minetest.set_node(posAbove, {
				name = "minertrade:atm",
				param2 = facedir,
			})
			local meta = minetest.get_meta(posAbove)
			--meta:set_string("infotext", modMinerTrade.translate("PUBLIC ATM\n* Save your money in the ATM, and withdraw your money in your Personal Safe or other ATM in the shops scattered around the map."))
			local now = os.time() --Em milisegundos
			if not minetest.get_player_privs(playername).server then
				meta:set_string("opentime", now+modMinerTrade.delayConstruct)
			else
				meta:set_string("opentime", now)
			end
			itemstack:take_item() -- itemstack:take_item() = Ok
		else
			minetest.chat_send_player(playername, 
				core.colorize("#00ff00", "["..modMinerTrade.translate("ATM").."]: ")
				..modMinerTrade.translate("You can not install this 'ATM' too far from a 'Dispensing Machine'!")
			)
			--return itemstack -- = Cancel
		end
		
		return itemstack
	end,
	
	on_rightclick = function(pos, node, clicker)
		local clickername = clicker:get_player_name()
		local meta = minetest.get_meta(pos)
		--meta:set_string("infotext", modMinerTrade.translate("PUBLIC ATM\n* Save your money in the ATM, and withdraw your money in your Personal Safe or other ATM in the shops scattered around the map."))
		local opentime = tonumber(meta:get_string("opentime")) or 0
		local now = os.time() --Em milisegundos
		if now >= opentime or minetest.get_player_privs(clickername).server then
			--[[ 
			modMinerTrade.showInventory(
				clicker, 
				clickername, 
				modMinerTrade.translate("PUBLIC ATM - Account of '%s':"):format(clickername)
			)
			--]]
			modMinerTrade.showAtm.frmMain(clickername)
		else
			--minetest.sound_play("sfx_failure", {object=clicker, max_hear_distance=5.0,})
			modMinerTrade.doSoundPlayer(clickername, "sfx_failure", 5)
			minetest.chat_send_player(clickername, 
				core.colorize("#00ff00", "["..modMinerTrade.translate("ATM").."]: ")
				..modMinerTrade.translate(
					"The ATM will only run %02d seconds after it is installed!"
				):format(opentime-now)
			)
		end
		--modMinerTrade.debug("on_rightclick() >>> "..modMinerTrade.getUrlDatabase())
	end,
})

--[[ 
minetest.register_craft({
	output = 'minertrade:atm',
	recipe = {
		{"default:steel_ingot"	,"default:steel_ingot"		,"default:steel_ingot"},
		{"default:steel_ingot"	,"default:obsidian_glass"	,"default:steel_ingot"},
		{"default:steel_ingot"	,"default:mese"				,"default:steel_ingot"},
	}
})
--]]
minetest.register_alias("atm","minertrade:atm")
minetest.register_alias(modMinerTrade.translate("atm"),"minertrade:atm")

minetest.register_on_player_receive_fields(function(sender, formname, fields)
	return modMinerTrade.onReceiveFields(sender, formname, fields)
end)

minetest.register_on_joinplayer(function(player)
	local playername = player:get_player_name()
	if not modMinerTrade.isExistAcount(playername) then
		modMinerTrade.createAcount(playername)
	end
end)

minetest.register_on_leaveplayer(function(player)
	modMinerTrade.doBankSave()
end)

minetest.register_on_shutdown(function()
	modMinerTrade.doBankSave()
	minetest.log('action',"[STRONGBOX] "..modMinerTrade.translate("Saving bank from all players in the file '%s'!"):format(modMinerTrade.getUrlDatabase()))
end)
