Prevent cheating restart_gift

This commit is contained in:
LoneWolfHT 2020-12-13 11:27:36 -08:00
parent d7355a984a
commit bcc1c7954a

View File

@ -1,5 +1,6 @@
local can_gift = true local can_gift = true
local GIFT_AMOUNT = 50 local GIFT_AMOUNT = 50
local gifted = {}
minetest.after(60, function() can_gift = false end) minetest.after(60, function() can_gift = false end)
@ -9,6 +10,8 @@ minetest.register_on_joinplayer(function(player)
local main, match = ctf_stats.player(pname) local main, match = ctf_stats.player(pname)
if main and match then if main and match then
if gifted[pname] then GIFT_AMOUNT = -50 end
main.score = main.score + GIFT_AMOUNT main.score = main.score + GIFT_AMOUNT
match.score = match.score + GIFT_AMOUNT match.score = match.score + GIFT_AMOUNT
@ -19,6 +22,14 @@ minetest.register_on_joinplayer(function(player)
color = 0xc000cd, color = 0xc000cd,
value = GIFT_AMOUNT value = GIFT_AMOUNT
}) })
if gifted[pname] then
GIFT_AMOUNT = -50
minetest.chat_send_player(pname, "No reward for the greedy.")
return
else
gifted[pname] = true
end
end end
minetest.chat_send_player(pname, "Thanks for staying with us through that restart!") minetest.chat_send_player(pname, "Thanks for staying with us through that restart!")