Skip to content

Commit

Permalink
Limit the number of characters in the donate message to 50 (#1368)
Browse files Browse the repository at this point in the history
* Update ranking_commands.lua

* Update ranking_commands.lua

---------

Co-authored-by: LandarVargan <[email protected]>
  • Loading branch information
Themostrandom and LoneWolfHT authored Jan 11, 2025
1 parent effc59e commit f879876
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion mods/ctf/ctf_modebase/ranking_commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ ctf_core.register_chatcommand_alias("donate", "d", {
end

local pnames, score, dmessage = {}, 0, ""

local pcount, ismessage = 0, false

for p in string.gmatch(param, "%S+") do
Expand Down Expand Up @@ -183,6 +182,9 @@ ctf_core.register_chatcommand_alias("donate", "d", {

dmessage = (dmessage and dmessage ~= "") and (": " .. dmessage) or ""

if #dmessage > 50 then
return false, "The donation message is " .. (#dmessage - 50) .. " chars too long!"
end

current_mode.recent_rankings.add(name, {score=-scoretotal}, true)
local names = ""
Expand All @@ -202,12 +204,15 @@ ctf_core.register_chatcommand_alias("donate", "d", {

donate_timer[name] = os.time()
local donate_text = string.format("%s donated %s score to %s%s", name, score, names, dmessage)

minetest.chat_send_all(minetest.colorize("#00EEFF", donate_text))
ctf_modebase.announce(donate_text)
return true
end
})



local allow_reset = {}
minetest.register_chatcommand("reset_rankings", {
description = minetest.colorize("red", "Resets rankings of you or another player to nothing"),
Expand Down

0 comments on commit f879876

Please sign in to comment.