mirror of
https://codeberg.org/usrib/emeraldbank.git
synced 2025-01-03 20:07:32 +01:00
added set_emeralds(player) func
This commit is contained in:
parent
cc80001245
commit
d0abd6105c
@ -26,6 +26,38 @@ function emeraldbank.get_emeralds(name)
|
|||||||
return atm.balance[name]
|
return atm.balance[name]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Accepts a player object or player name as input now
|
||||||
|
function emeraldbank.set_emeralds(player, num)
|
||||||
|
if not player then return false end
|
||||||
|
|
||||||
|
local name
|
||||||
|
if type(player) == "string" then
|
||||||
|
name = player
|
||||||
|
else
|
||||||
|
name = player:get_player_name()
|
||||||
|
end
|
||||||
|
|
||||||
|
atm.read_account(name)
|
||||||
|
|
||||||
|
-- Check if atm.balance[name] exists
|
||||||
|
if atm.balance[name] == nil then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
if num then
|
||||||
|
atm.balance[name] = math.floor(num)
|
||||||
|
|
||||||
|
-- Update actionbar only if 'player' is a player object
|
||||||
|
if type(player) ~= "string" then
|
||||||
|
mcl_title.set(player, "actionbar", {text=S("Emeralds in Bank: @1", atm.balance[name]), color="yellow"})
|
||||||
|
end
|
||||||
|
|
||||||
|
atm.save_account(name)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
-- Accepts a player object or player name as input now
|
-- Accepts a player object or player name as input now
|
||||||
function emeraldbank.add_emeralds(player, num)
|
function emeraldbank.add_emeralds(player, num)
|
||||||
if not player then return false end
|
if not player then return false end
|
||||||
|
Loading…
Reference in New Issue
Block a user