Patched emerald cheat glitch by adding wait time for players to get start balance

This commit is contained in:
James David Clarke 2024-01-10 14:40:50 +00:00
parent 492a2e28ee
commit 1d8238da7e
No known key found for this signature in database
GPG Key ID: 9F5ECFD0E20F1C4C
3 changed files with 35 additions and 13 deletions

@ -2,8 +2,8 @@ local storage = minetest.get_mod_storage()
function atm.create_account(name)
if not storage:contains("balance_" .. name) and minetest.player_exists(name) then
storage:set_int("balance_" .. name, atm.startbalance)
atm.balance[name] = atm.startbalance
storage:set_int("balance_" .. name, 0)
atm.balance[name] = 0
end
end
@ -100,4 +100,4 @@ minetest.register_on_mods_loaded(function()
io.close(file)
atm.migrate_transactions()
end
end)
end)

@ -25,18 +25,38 @@ local S = core.get_translator(core.get_current_modname())
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 timer = 0
local start_balance_period = tonumber(core.settings:get("emeraldbank.start_balance_period")) or 1800
local income_timer = 0
local start_balance_timer = 0
function emeraldbank.income(dtime)
timer = timer + dtime;
if timer >= income_period then
timer = 0
for _, player in ipairs(core.get_connected_players()) do
if not player or player.is_fake_player then return end
emeraldbank.add_emeralds(player, income_count)
income_timer = income_timer + dtime
local conn_players = core.get_connected_players()
if income_timer >= income_period then
income_timer = 0
for _, player in ipairs(conn_players) do
if not player or player.is_fake_player then return end
emeraldbank.add_emeralds(player, income_count)
end
end
-- Starting balance timer
start_balance_timer = start_balance_timer + dtime
if start_balance_timer >= start_balance_period then
start_balance_timer = 0
for _, player in ipairs(conn_players) do
if not player or player.is_fake_player then return end
local meta = player:get_meta()
local had_start_balance = meta:get_string("emeraldbank_had_start_balance")
if had_start_balance == "" or had_start_balance == nil then
mcl_title.set(player, "actionbar", {text=S("You have earned your starting balance for playtime: @1", atm.startbalance), color="green"})
emeraldbank.add_emeralds(player, atm.startbalance)
meta:set_string("emeraldbank_had_start_balance", "true")
end
end
end
end
minetest.register_globalstep(emeraldbank.income)

@ -7,16 +7,18 @@ emeraldbank.bank_craft (bank craft) bool true
# Number of emeralds on start
emeraldbank.start_balance (emeralds on start) int 30
# Length of time (in seconds) between checking if a player has had their start balance
emeraldbank.start_balance_period (time till start balance earned) int 1800
# If true, bank will give emeralds to players for gamed time
emeraldbank.income_enabled (Is income enabled?) bool true
# Number of emeralds given as income
emeraldbank.income_count (number of emeralds) int 1
# Length of time (in seconds) between checking if a user should get income
# Length of time (in seconds) between checking if a player should get income
emeraldbank.income_period (time between income) int 1800
[Shops]
# If true shop can be crafted