-- adapted from the income.lua file from the currency mod. local timer = 0 function atm.welfare_payout() payout = false for _,player in ipairs(minetest.get_connected_players()) do local name = player:get_player_name() local limit = atm.welfare[name] or atm.welfare_cap atm.ensure_init(name) if limit > atm.welfare_amount then atm.balance[name] = math.floor(atm.balance[name] + atm.welfare_amount) atm.welfare[name] = limit - atm.welfare_amount payout = true end end if payout then atm.saveaccounts() end end minetest.register_globalstep(function(dtime) timer = timer + dtime; if timer >= 1000 then timer = 0 atm.welfare_payout() end end) minetest.register_chatcommand("give_welfare", { description = "Put a player on welfare payments", params = " ", privs = { kick = true }, func = function (name, params) local plname, amount = params:match("(%S+)%s+(%d+)") if not plname then return false, "Invalid parameters: "..params end if not atm.balance[plname] then return false, plname.." does not have a bank account!" end atm.welfare[plname] = tonumber(amount) or atm.welfare_cap minetest.chat_send_player(name, "Player "..plname.." put on welfare successfully.") return true end, })