Add money3.delete()

This commit is contained in:
luk3yx 2023-08-08 22:11:13 +12:00
parent 79da086daf
commit 1c9e43d471
2 changed files with 14 additions and 8 deletions

View File

@ -51,6 +51,19 @@ function money3.user_exists(name)
end
money3.has_credit = money3.user_exists
-- Delete data associated with account
function money3.delete(name)
local lname = name:lower()
for _, player in ipairs(minetest.get_connected_players()) do
if player:get_player_name():lower() == lname then
-- Deleting the accounts of online players will cause bugs
return false
end
end
storage:set_string("balance-" .. lname, "")
return true
end
-- Add money
function money3.add(name, amount)
if amount ~= amount or amount < 0 then

View File

@ -79,14 +79,7 @@ if minetest.get_modpath("um_core") then
money3.set(name, default_balance or 0)
return true
end,
delete_account = function(name)
-- Deleting the accounts of online players will cause bugs
if minetest.get_player_by_name(name) then
return false
end
storage:set_string("balance-" .. name:lower(), "")
return true
end,
delete_account = money3.delete,
account_exists = money3.user_exists,
list_accounts = function()
local get_canonical_name = make_canonical_name_cache()