From 3eb3bf035e5a961a51fea6cfdd6b51daca587736 Mon Sep 17 00:00:00 2001 From: Lunovox Date: Wed, 11 Mar 2020 12:25:22 -0300 Subject: [PATCH] =?UTF-8?q?adicionar=20sal=C3=A1rio=20no=20mod.=20(n=C3=A3?= =?UTF-8?q?o=20testada)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- init.lua | 3 ++- payday.lua | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 payday.lua diff --git a/init.lua b/init.lua index c3decf6..6b4d5ef 100644 --- a/init.lua +++ b/init.lua @@ -14,7 +14,8 @@ dofile(modpath.."/item_exchange_table.lua") dofile(modpath.."/item_dispensing_machine.lua") -- --dofile(path.."/item_rent_door.lua") +dofile(modpath.."/payday.lua") -- <== Pay diary per playing in server. dofile(modpath.."/commands.lua") -dofile(modpath.."/on_final.lua") -- <== Depois que carregou tudo! +dofile(modpath.."/on_final.lua") -- <== Only after load all code! minetest.log('action',"["..modname:upper().."] Loaded!") diff --git a/payday.lua b/payday.lua new file mode 100644 index 0000000..1b9786d --- /dev/null +++ b/payday.lua @@ -0,0 +1,47 @@ +--[[ +minetest.after(3.5, function() + modMinerTrade.payday = { + interval = (60 *24) / (tonumber(minetest.setting_get("time_speed")) or 72), + time = 0 + } + modMinerTrade.payday.interval = 1 + minetest.register_globalstep(function(dtime) + modMinerTrade.payday.time = modMinerTrade.payday.time + dtime + if modMinerTrade.payday.time >= modMinerTrade.payday.interval then + + end + end) +end) +--]] + +minetest.after(3.5, function() + local interval = 5 + local time = 0 + minetest.register_globalstep(function(dtime) + time = time + dtime + if time >= interval then + time = 0 + local dc = minetest.get_day_count() + local players = minetest.get_connected_players() + local salary = "minertrade:minercoin 1" + if #players >= 1 then + for _, player in ipairs(players) do + local playername = player:get_player_name() + local inv = modMinerTrade.getSafeInventory(ownername) + local lp = tonumber(player:get_meta("last_pay")) or 0 + if lp ~= dc then + player:set_meta("last_pay",dc) + minetest.chat_send_player( + playername, + core.colorize("#00ff00", "["..modMinerTrade.translate("CITY HALL").."]: ") + ..modMinerTrade.translate("The city hall deposited your salary in your bank account!") + ) + minetest.sound_play("sfx_cash_register", {object=player, max_hear_distance=5.0,}) + inv:add_item("safe_"..playername, salary) + end + end + end + end + end) +end) +