income use function add_emeralds()

This commit is contained in:
Nathaniel Freeman 2021-10-20 17:54:50 +02:00
parent dec4b888e8
commit aff751548b

@ -22,7 +22,7 @@
local S = core.get_translator(core.get_current_modname()) local S = core.get_translator(core.get_current_modname())
local income_enabled = core.settings:get_bool("emeraldbank.income_enabled", true)
local income_count = tonumber(core.settings:get("emeraldbank.income_count")) or 1 local income_count = tonumber(core.settings:get("emeraldbank.income_count")) or 1
local income_period = tonumber(core.settings:get("emeraldbank.income_period")) or 1800 local income_period = tonumber(core.settings:get("emeraldbank.income_period")) or 1800
@ -30,21 +30,16 @@ local income_period = tonumber(core.settings:get("emeraldbank.income_period")) o
-- income -- income
if income_enabled then if income_enabled then
local timer = 0 local timer = 0
core.register_globalstep( core.register_globalstep(function(dtime)
function(dtime)
timer = timer + dtime; timer = timer + dtime;
if timer >= income_period then if timer >= income_period then
timer = 0 timer = 0
for _, player in ipairs(core.get_connected_players()) do for _, player in ipairs(core.get_connected_players()) do
if not player or player.is_fake_player then return end if not player or player.is_fake_player then return end
local meta = player:get_meta()
local name = player:get_player_name() local name = player:get_player_name()
local bankemeralds = meta:get_int("emeraldbank:emerald")
local total = bankemeralds+income_count
meta:set_int("emeraldbank:emerald", total)
core.chat_send_player(name, S("You have earned @1 emeralds in your bank account!", income_count) ) core.chat_send_player(name, S("You have earned @1 emeralds in your bank account!", income_count) )
emeraldbank.add_emeralds(player, income_count)
end end
end end
end end)
)
end end