From 7a95698bd16feb00132257064b3cfe0c95c93d98 Mon Sep 17 00:00:00 2001 From: Eric Meehan Date: Wed, 15 Apr 2026 17:35:27 -0400 Subject: [PATCH] Check player names and assign bounties correctly --- init.lua | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/init.lua b/init.lua index bc42bb5..9a52f16 100644 --- a/init.lua +++ b/init.lua @@ -2,7 +2,7 @@ bounty = {} bounty.file = core.get_worldpath() .. '/bounty.txt' bounty.data = {} bounty.prizes = false --determines if prizes or amount per points game-mechanic is used -if false then +if true then bounty.prizes = 'currency:minegeld_100' bounty.points_per_prize = 20 --per 100 points you get a default:steel_ingot else @@ -140,22 +140,32 @@ bounty.get_player_bounty = function(player_name) return prize end +bounty.player_exists = function(player_name) + if not minetest.get_player_by_name(player_name) then + return false + else + return true + end +end + --chatcommands for testing purposes core.register_chatcommand('bounty', { - params = '', description = 'Place bounty on offenders and increasing the bounty by 20', privs = { interact = true }, func = function(name, params) - bounty.increase(name, 20) + if bounty.player_exists(params) then + bounty.increase(params, 20) + end end }) core.register_chatcommand('forgive', { - params = '', description = 'Forgive offender and decrease bounty by 20', privs = { interact = true }, func = function(name, params) - bounty.decrease(name, 20) + if bounty.player_exists(params) then + bounty.decrease(params, 20) + end end })