mirror of
https://codeberg.org/usrib/emeraldbank.git
synced 2024-12-22 22:22:25 +01:00
Patched emerald cheat glitch by adding wait time for players to get start balance
This commit is contained in:
parent
492a2e28ee
commit
1d8238da7e
4
atm.lua
4
atm.lua
@ -2,8 +2,8 @@ local storage = minetest.get_mod_storage()
|
|||||||
|
|
||||||
function atm.create_account(name)
|
function atm.create_account(name)
|
||||||
if not storage:contains("balance_" .. name) and minetest.player_exists(name) then
|
if not storage:contains("balance_" .. name) and minetest.player_exists(name) then
|
||||||
storage:set_int("balance_" .. name, atm.startbalance)
|
storage:set_int("balance_" .. name, 0)
|
||||||
atm.balance[name] = atm.startbalance
|
atm.balance[name] = 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
36
income.lua
36
income.lua
@ -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_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
|
||||||
|
local start_balance_period = tonumber(core.settings:get("emeraldbank.start_balance_period")) or 1800
|
||||||
local timer = 0
|
local income_timer = 0
|
||||||
|
local start_balance_timer = 0
|
||||||
|
|
||||||
function emeraldbank.income(dtime)
|
function emeraldbank.income(dtime)
|
||||||
timer = timer + dtime;
|
income_timer = income_timer + dtime
|
||||||
if timer >= income_period then
|
local conn_players = core.get_connected_players()
|
||||||
timer = 0
|
if income_timer >= income_period then
|
||||||
for _, player in ipairs(core.get_connected_players()) do
|
income_timer = 0
|
||||||
if not player or player.is_fake_player then return end
|
for _, player in ipairs(conn_players) do
|
||||||
emeraldbank.add_emeralds(player, income_count)
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
minetest.register_globalstep(emeraldbank.income)
|
minetest.register_globalstep(emeraldbank.income)
|
||||||
|
@ -7,16 +7,18 @@ emeraldbank.bank_craft (bank craft) bool true
|
|||||||
# Number of emeralds on start
|
# Number of emeralds on start
|
||||||
emeraldbank.start_balance (emeralds on start) int 30
|
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
|
# If true, bank will give emeralds to players for gamed time
|
||||||
emeraldbank.income_enabled (Is income enabled?) bool true
|
emeraldbank.income_enabled (Is income enabled?) bool true
|
||||||
|
|
||||||
# Number of emeralds given as income
|
# Number of emeralds given as income
|
||||||
emeraldbank.income_count (number of emeralds) int 1
|
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
|
emeraldbank.income_period (time between income) int 1800
|
||||||
|
|
||||||
|
|
||||||
[Shops]
|
[Shops]
|
||||||
|
|
||||||
# If true shop can be crafted
|
# If true shop can be crafted
|
||||||
|
Loading…
Reference in New Issue
Block a user