From 1fd07dfa23a0efa6022b729e6835caca060665f9 Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Wed, 8 Nov 2017 00:52:09 +0000 Subject: [PATCH] Add ability to lock a player to a certain color --- mods/ctf_alloc/depends.txt | 2 ++ mods/ctf_alloc/init.lua | 30 ++++++++++++++++++++++++++++++ mods/ctf_pvp_engine | 2 +- 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 mods/ctf_alloc/depends.txt create mode 100644 mods/ctf_alloc/init.lua diff --git a/mods/ctf_alloc/depends.txt b/mods/ctf_alloc/depends.txt new file mode 100644 index 0000000..56021d4 --- /dev/null +++ b/mods/ctf_alloc/depends.txt @@ -0,0 +1,2 @@ +ctf +lib_chatcmdbuilder diff --git a/mods/ctf_alloc/init.lua b/mods/ctf_alloc/init.lua new file mode 100644 index 0000000..8f6b057 --- /dev/null +++ b/mods/ctf_alloc/init.lua @@ -0,0 +1,30 @@ +local storage = minetest.get_mod_storage() +local data = minetest.parse_json(storage:get_string("locktoteam")) or {} + +local ctf_autoalloc = ctf.autoalloc +function ctf.autoalloc(name, alloc_mode) + if data[name] then + return data[name] + end + + return ctf_autoalloc(name, alloc_mode) +end + +ChatCmdBuilder.new("ctf_lockpt", function(cmd) + cmd:sub(":name :team", function(name, pname, team) + if team == "!" then + data[pname] = nil + storage:set_string("locktoteam", minetest.write_json(data)) + return true, "Unlocked " .. pname + else + data[pname] = team + storage:set_string("locktoteam", minetest.write_json(data)) + return true, "Locked " .. pname .. " to " .. team + end + end) +end, { + description = "Lock a player to a team", + privs = { + ctf_admin = true, + } +}) diff --git a/mods/ctf_pvp_engine b/mods/ctf_pvp_engine index 730f090..9a10f60 160000 --- a/mods/ctf_pvp_engine +++ b/mods/ctf_pvp_engine @@ -1 +1 @@ -Subproject commit 730f0906de0f572e763dabeb7e4b7514e9e6bb41 +Subproject commit 9a10f60e974ab2f20d1a7843fc2f04ac60ec645d