Check player names and assign bounties correctly
This commit is contained in:
20
init.lua
20
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
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user