Skip to content

Commit

Permalink
only donate if all receivers re valid
Browse files Browse the repository at this point in the history
  • Loading branch information
lazylier committed Jun 10, 2024
1 parent e0bc688 commit e31639f
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions mods/ctf/ctf_modebase/ranking_commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -182,35 +182,31 @@ minetest.register_chatcommand("donate", {

if receivers[pname] then
return false, "You cannot donate more than once to the same person."
end

if not receivers[pname] then
else
receivers[pname] = true
end
end

local pname, names, count = next(receivers), "", 0
while pname do
current_mode.recent_rankings.add(pname, {score=score}, true)
current_mode.recent_rankings.add(name, {score=-score}, true)

minetest.log("action", string.format(
"Player '%s' donated %s score to player '%s'", name, score, pname
))

minetest.chat_send_all(pname)
end

local r, names, count = next(receivers), "", 0
while r do
names = names .. r
names = names .. pname
count = count + 1

n = next(receivers, r)
n = next(receivers, pname)

if n then
names = names .. ", "
end
r = n
pname = n
end
separators = {string.find(names, ", (%S+)$")}

if count > 2 then
names = string.gsub(names, ", (%S+)$", ", and %1")
elseif count > 1 then
Expand Down

0 comments on commit e31639f

Please sign in to comment.