2016-07-01 18:59:00 +01:00
|
|
|
minetest.register_privilege("secret", "Wouldn't you like to know?")
|
2016-07-14 18:36:17 +01:00
|
|
|
minetest.register_privilege("caged", {description = "Not going anywhere...", give_to_singleplayer=false})
|
2016-07-03 19:50:27 +01:00
|
|
|
minetest.register_privilege("hidden_one", {description = "Can hide from players.", give_to_singleplayer=false})
|
2016-07-01 18:59:00 +01:00
|
|
|
|
2016-07-04 19:26:28 +01:00
|
|
|
|
2016-12-12 14:42:45 +00:00
|
|
|
-- Admin Curses
|
2016-07-01 18:59:00 +01:00
|
|
|
|
2016-12-12 14:42:45 +00:00
|
|
|
-- prevents player from jumping
|
2017-09-09 17:53:12 +01:00
|
|
|
local function hobble(user, target)
|
|
|
|
local player = minetest.get_player_by_name(target)
|
2017-10-16 12:42:57 +01:00
|
|
|
player:set_attribute("hobbled", "true")
|
2016-07-03 18:05:46 +01:00
|
|
|
player:set_physics_override({jump = 0})
|
2016-07-01 18:59:00 +01:00
|
|
|
end
|
2016-07-03 18:05:46 +01:00
|
|
|
|
2016-07-01 18:59:00 +01:00
|
|
|
minetest.register_chatcommand("hobble", {
|
2017-09-09 18:02:54 +01:00
|
|
|
params = "<person>",
|
2016-07-03 18:05:46 +01:00
|
|
|
privs = {secret=true},
|
2016-07-01 18:59:00 +01:00
|
|
|
description = "Prevent player jumping.",
|
2017-09-09 17:53:12 +01:00
|
|
|
func = function(name, target)
|
|
|
|
local player = minetest.get_player_by_name(target)
|
2016-07-03 18:05:46 +01:00
|
|
|
if player == nil then
|
|
|
|
minetest.chat_send_player(name,"Player does not exist")
|
|
|
|
return
|
|
|
|
end
|
2017-09-09 17:59:30 +01:00
|
|
|
hobble(name, target)
|
2017-09-09 17:53:12 +01:00
|
|
|
minetest.chat_send_player(target, "Cursed by an admin! No more jumping!")
|
2016-07-03 18:05:46 +01:00
|
|
|
minetest.chat_send_player(name, "Curse successful!")
|
|
|
|
end
|
2016-07-01 18:59:00 +01:00
|
|
|
})
|
|
|
|
|
2016-12-12 14:42:45 +00:00
|
|
|
-- reduces player movement speed
|
2017-09-09 17:53:12 +01:00
|
|
|
local function slowmo(name, target)
|
|
|
|
local player = minetest.get_player_by_name(target)
|
2017-10-16 12:42:57 +01:00
|
|
|
player:set_attribute("slowed", "true")
|
2016-07-03 19:17:38 +01:00
|
|
|
player:set_physics_override({speed = 0.3})
|
2016-07-01 18:59:00 +01:00
|
|
|
end
|
2016-07-03 18:05:46 +01:00
|
|
|
|
2016-07-01 18:59:00 +01:00
|
|
|
minetest.register_chatcommand("slowmo", {
|
2017-09-09 18:02:54 +01:00
|
|
|
params = "<person>",
|
2016-07-03 18:05:46 +01:00
|
|
|
privs = {secret=true},
|
2016-07-01 18:59:00 +01:00
|
|
|
description = "Reduce player movement speed.",
|
2017-09-09 17:53:12 +01:00
|
|
|
func = function(name, target)
|
|
|
|
local player = minetest.get_player_by_name(target)
|
2016-07-03 18:05:46 +01:00
|
|
|
if player == nil then
|
|
|
|
minetest.chat_send_player(name,"Player does not exist")
|
|
|
|
return
|
|
|
|
end
|
2017-09-09 17:53:12 +01:00
|
|
|
slowmo(name,target)
|
|
|
|
minetest.chat_send_player(target, "Cursed by an admin! You feel sloooooow!")
|
2016-07-03 18:05:46 +01:00
|
|
|
minetest.chat_send_player(name, "Curse successful!")
|
|
|
|
end
|
2016-07-01 18:59:00 +01:00
|
|
|
})
|
|
|
|
|
2016-12-12 14:42:45 +00:00
|
|
|
-- disable sneak glitch for the player
|
2017-09-09 17:53:12 +01:00
|
|
|
local function noglitch(name, target)
|
|
|
|
local player = minetest.get_player_by_name(target)
|
2017-10-16 12:42:57 +01:00
|
|
|
player:set_attribute("unglitched", "true")
|
2016-07-03 19:17:38 +01:00
|
|
|
player:set_physics_override({sneak = false})
|
2016-07-01 18:59:00 +01:00
|
|
|
end
|
2016-07-03 18:05:46 +01:00
|
|
|
|
2016-07-01 18:59:00 +01:00
|
|
|
minetest.register_chatcommand("noglitch", {
|
2017-09-09 18:02:54 +01:00
|
|
|
params = "<person>",
|
2016-07-03 18:05:46 +01:00
|
|
|
privs = {secret=true},
|
2016-07-01 18:59:00 +01:00
|
|
|
description = "Disable sneak glitch for a player.",
|
2017-09-09 17:53:12 +01:00
|
|
|
func = function(name, target)
|
|
|
|
local player = minetest.get_player_by_name(target)
|
2016-07-03 18:05:46 +01:00
|
|
|
if player == nil then
|
|
|
|
minetest.chat_send_player(name,"Player does not exist")
|
|
|
|
return
|
|
|
|
end
|
2017-09-09 17:53:12 +01:00
|
|
|
noglitch(name, target)
|
|
|
|
minetest.chat_send_player(target, "Cursed by an admin! You feel less glitchy...")
|
2016-07-03 18:05:46 +01:00
|
|
|
minetest.chat_send_player(name, "Curse successful!")
|
|
|
|
end
|
2016-07-01 18:59:00 +01:00
|
|
|
})
|
|
|
|
|
2016-12-12 14:42:45 +00:00
|
|
|
-- prevent player from changing speed/direction and jumping
|
2017-09-09 17:53:12 +01:00
|
|
|
local function freeze(name, target)
|
|
|
|
local player = minetest.get_player_by_name(target)
|
2017-10-16 12:42:57 +01:00
|
|
|
player:set_attribute("frozen", "true")
|
2016-07-03 18:14:34 +01:00
|
|
|
player:set_physics_override({jump = 0, speed = 0})
|
|
|
|
end
|
|
|
|
|
|
|
|
minetest.register_chatcommand("freeze", {
|
2017-09-09 18:02:54 +01:00
|
|
|
params = "<person>",
|
2016-07-03 18:14:34 +01:00
|
|
|
privs = {secret=true},
|
|
|
|
description = "Prevent player movement.",
|
2017-09-09 17:53:12 +01:00
|
|
|
func = function(name, target)
|
|
|
|
local player = minetest.get_player_by_name(target)
|
2016-07-03 18:14:34 +01:00
|
|
|
if player == nil then
|
|
|
|
minetest.chat_send_player(name,"Player does not exist")
|
|
|
|
return
|
|
|
|
end
|
2017-09-09 17:53:12 +01:00
|
|
|
freeze(name, target)
|
|
|
|
minetest.chat_send_player(target, "Cursed by an admin! You are now frozen!")
|
2016-07-03 18:14:34 +01:00
|
|
|
minetest.chat_send_player(name, "Curse successful!")
|
|
|
|
end
|
|
|
|
})
|
|
|
|
|
2017-03-24 19:58:15 +00:00
|
|
|
-- disables minimap for player
|
2017-09-09 17:53:12 +01:00
|
|
|
local function getlost(name,target)
|
|
|
|
local player = minetest.get_player_by_name(target)
|
2017-10-16 12:42:57 +01:00
|
|
|
player:set_attribute("lost", "true")
|
2017-03-24 19:58:15 +00:00
|
|
|
player:hud_set_flags({minimap = false})
|
|
|
|
end
|
|
|
|
|
|
|
|
minetest.register_chatcommand("getlost", {
|
2017-09-09 18:02:54 +01:00
|
|
|
params = "<person>",
|
2017-03-24 19:58:15 +00:00
|
|
|
privs = {secret=true},
|
|
|
|
description = "Prevent player from using the minimap.",
|
2017-09-09 17:53:12 +01:00
|
|
|
func = function(name, target)
|
|
|
|
local player = minetest.get_player_by_name(target)
|
2017-03-24 19:58:15 +00:00
|
|
|
if player == nil then
|
|
|
|
minetest.chat_send_player(name,"Player does not exist")
|
|
|
|
return
|
|
|
|
end
|
2017-09-09 17:53:12 +01:00
|
|
|
getlost(name,target)
|
|
|
|
minetest.chat_send_player(target, "Cursed by an admin! You will get lost now!")
|
2017-03-24 19:58:15 +00:00
|
|
|
minetest.chat_send_player(name, "Curse successful!")
|
|
|
|
end
|
|
|
|
})
|
|
|
|
|
|
|
|
|
2016-12-12 14:42:45 +00:00
|
|
|
-- trigger curse effects when player joins
|
2016-07-03 18:14:34 +01:00
|
|
|
minetest.register_on_joinplayer(function(player)
|
|
|
|
local name = player:get_player_name()
|
2017-10-16 12:42:57 +01:00
|
|
|
if player:get_attribute("hobbled") == "true" then
|
2016-07-05 17:15:36 +01:00
|
|
|
hobble(name,name)
|
|
|
|
end
|
2017-10-16 12:42:57 +01:00
|
|
|
if player:get_attribute("slowed") == "true" then
|
2016-07-05 17:15:36 +01:00
|
|
|
slowmo(name,name)
|
|
|
|
end
|
2017-10-16 12:42:57 +01:00
|
|
|
if player:get_attribute("unglitched") == "true" then
|
2016-07-05 17:15:36 +01:00
|
|
|
noglitch(name,name)
|
2016-07-05 17:16:56 +01:00
|
|
|
end
|
2017-10-16 12:42:57 +01:00
|
|
|
if player:get_attribute("frozen") == "true" then
|
2016-07-03 18:14:34 +01:00
|
|
|
freeze(name,name)
|
2016-07-05 17:16:56 +01:00
|
|
|
end
|
2017-10-16 12:42:57 +01:00
|
|
|
if player:get_attribute("lost") == "true" then
|
2017-09-26 22:14:13 +01:00
|
|
|
getlost(name,name)
|
2017-03-24 19:58:15 +00:00
|
|
|
end
|
2016-07-03 18:14:34 +01:00
|
|
|
end)
|
|
|
|
|
2016-12-12 14:42:45 +00:00
|
|
|
-- reset player physics
|
2016-07-01 18:59:00 +01:00
|
|
|
minetest.register_chatcommand("setfree",{
|
2017-09-09 18:02:54 +01:00
|
|
|
params = "<person>",
|
2016-07-01 18:59:00 +01:00
|
|
|
privs = {secret=true},
|
2016-07-03 18:05:46 +01:00
|
|
|
description = "Reset player movement.",
|
2017-09-09 17:53:12 +01:00
|
|
|
func = function(name, target)
|
|
|
|
local player = minetest.get_player_by_name(target)
|
2016-07-01 18:59:00 +01:00
|
|
|
if player == nil then
|
2016-07-03 18:05:46 +01:00
|
|
|
minetest.chat_send_player(name,"Player does not exist")
|
2016-07-01 18:59:00 +01:00
|
|
|
return
|
|
|
|
end
|
2017-10-16 12:42:57 +01:00
|
|
|
player:set_attribute("hobbled", "")
|
|
|
|
player:set_attribute("slowed", "")
|
|
|
|
player:set_attribute("unglitched", "")
|
|
|
|
player:set_attribute("frozen", "")
|
|
|
|
player:set_attribute("lost", "")
|
2016-07-01 18:59:00 +01:00
|
|
|
player:set_physics_override({jump = 1, speed = 1, sneak = true})
|
2017-03-24 19:58:15 +00:00
|
|
|
player:hud_set_flags({minimap = true})
|
2017-09-09 17:53:12 +01:00
|
|
|
minetest.chat_send_player(target, "The curse is lifted. You have been set free!")
|
2016-07-05 17:18:22 +01:00
|
|
|
minetest.chat_send_player(name, "The curse is lifted.")
|
2016-07-01 18:59:00 +01:00
|
|
|
end,
|
|
|
|
})
|
2016-07-03 19:50:27 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
2016-12-12 14:42:45 +00:00
|
|
|
-- Cage Commands
|
2016-07-04 19:26:28 +01:00
|
|
|
|
2016-07-14 18:36:17 +01:00
|
|
|
local priv_table = {}
|
|
|
|
|
2016-12-12 14:42:45 +00:00
|
|
|
-- save table to file
|
2016-07-14 18:36:17 +01:00
|
|
|
local function table_save()
|
|
|
|
local data = priv_table
|
|
|
|
local f, err = io.open(minetest.get_worldpath() .. "/curse_priv_table.txt", "w")
|
|
|
|
if err then
|
|
|
|
return err
|
|
|
|
end
|
|
|
|
f:write(minetest.serialize(data))
|
|
|
|
f:close()
|
|
|
|
end
|
|
|
|
|
2016-12-12 14:42:45 +00:00
|
|
|
-- read saved file
|
2016-07-14 18:36:17 +01:00
|
|
|
local function table_read()
|
|
|
|
local f, err = io.open(minetest.get_worldpath() .. "/curse_priv_table.txt", "r")
|
|
|
|
local data = minetest.deserialize(f:read("*a"))
|
|
|
|
f:close()
|
|
|
|
return data
|
|
|
|
end
|
|
|
|
|
|
|
|
minetest.after(3.0, function()
|
|
|
|
local f, err = io.open(minetest.get_worldpath() .. "/curse_priv_table.txt", "r")
|
|
|
|
if err then
|
|
|
|
table_save()
|
|
|
|
else
|
|
|
|
priv_table = table_read()
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
|
|
|
|
minetest.register_on_shutdown(function()
|
|
|
|
table_save()
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
2016-12-12 14:42:45 +00:00
|
|
|
-- put a player in the cage
|
2016-07-04 19:26:28 +01:00
|
|
|
minetest.register_chatcommand("cage", {
|
2017-09-09 18:02:54 +01:00
|
|
|
params = "<person>",
|
2016-07-04 19:26:28 +01:00
|
|
|
privs = {secret=true},
|
|
|
|
description = "Put a player in the cage.",
|
2016-07-14 18:36:17 +01:00
|
|
|
func = function(warden_name, target_name)
|
2017-07-06 21:04:59 +01:00
|
|
|
--prevent self-caging
|
|
|
|
if warden_name == target_name then
|
|
|
|
minetest.chat_send_player(warden_name,"You can't cage yourself")
|
|
|
|
return
|
|
|
|
end
|
2016-12-12 14:42:45 +00:00
|
|
|
-- get target player or return
|
2016-07-14 18:36:17 +01:00
|
|
|
local target = minetest.get_player_by_name(target_name)
|
|
|
|
if not target then
|
|
|
|
minetest.chat_send_player(warden_name,"Player does not exist")
|
2016-07-04 19:26:28 +01:00
|
|
|
return
|
|
|
|
end
|
2016-12-12 14:42:45 +00:00
|
|
|
-- get target player's privs or return
|
2016-07-14 18:36:17 +01:00
|
|
|
local privs = minetest.get_player_privs(target_name)
|
|
|
|
if privs.caged == true then
|
|
|
|
minetest.chat_send_player(warden_name,"This player is already caged")
|
|
|
|
return
|
|
|
|
end
|
2016-12-12 14:42:45 +00:00
|
|
|
-- get cage position from config or return
|
2016-07-04 19:26:28 +01:00
|
|
|
local cagepos = minetest.setting_get_pos("cage_coordinate")
|
|
|
|
if not cagepos then
|
2016-07-14 18:36:17 +01:00
|
|
|
minetest.chat_send_player(warden_name, "No cage set...")
|
|
|
|
return
|
2016-07-04 19:26:28 +01:00
|
|
|
end
|
2016-12-12 14:42:45 +00:00
|
|
|
-- add current target privs to table and save to file
|
2016-07-14 18:36:17 +01:00
|
|
|
priv_table[target_name] = privs
|
|
|
|
table_save()
|
2016-12-12 14:42:45 +00:00
|
|
|
-- remove all privs but shout and add caged and unglitched
|
2016-07-14 18:36:17 +01:00
|
|
|
minetest.set_player_privs(target_name,{shout = true, caged = true})
|
|
|
|
noglitch(warden_name, target_name)
|
2016-12-12 14:42:45 +00:00
|
|
|
-- move target to cage location
|
2016-07-14 18:36:17 +01:00
|
|
|
target:setpos(cagepos)
|
2016-07-04 19:26:28 +01:00
|
|
|
end
|
|
|
|
})
|
|
|
|
|
2016-12-12 14:42:45 +00:00
|
|
|
-- free a player from the cage
|
2016-07-04 19:26:28 +01:00
|
|
|
minetest.register_chatcommand("uncage", {
|
2017-09-09 18:02:54 +01:00
|
|
|
params = "<person>",
|
2016-07-04 19:26:28 +01:00
|
|
|
privs = {secret=true},
|
|
|
|
description = "Free a player from the cage.",
|
2016-07-14 18:36:17 +01:00
|
|
|
func = function(warden_name, target_name)
|
2016-12-12 14:42:45 +00:00
|
|
|
-- get target player or return
|
2016-07-14 18:36:17 +01:00
|
|
|
local target = minetest.get_player_by_name(target_name)
|
|
|
|
if not target then
|
|
|
|
minetest.chat_send_player(warden_name,"Player does not exist")
|
2016-07-04 19:26:28 +01:00
|
|
|
return
|
|
|
|
end
|
2016-12-12 14:42:45 +00:00
|
|
|
-- get target player's privs or return
|
2016-07-14 18:36:17 +01:00
|
|
|
local privs = minetest.get_player_privs(target_name)
|
|
|
|
if privs.caged ~= true then
|
|
|
|
minetest.chat_send_player(warden_name,"This player is not caged")
|
|
|
|
return
|
|
|
|
end
|
2016-12-12 14:42:45 +00:00
|
|
|
-- get release position from config or return
|
2016-09-20 12:35:02 +01:00
|
|
|
local releasepos = minetest.setting_get_pos("release_coordinate")
|
|
|
|
if not releasepos then
|
|
|
|
minetest.chat_send_player(warden_name, "No release point set...")
|
2016-07-14 18:36:17 +01:00
|
|
|
return
|
2016-07-04 19:26:28 +01:00
|
|
|
end
|
2016-12-12 14:42:45 +00:00
|
|
|
-- get target's original privs from table and restore them
|
2016-07-14 18:36:17 +01:00
|
|
|
local original_privs = priv_table[target_name]
|
|
|
|
minetest.set_player_privs(target_name,original_privs)
|
2016-12-12 14:42:45 +00:00
|
|
|
-- remove entry for target from table and save to file
|
2016-07-14 18:36:17 +01:00
|
|
|
priv_table[target_name] = nil
|
|
|
|
table_save()
|
2016-12-12 14:42:45 +00:00
|
|
|
-- restore sneak and move target to release point
|
2016-07-14 18:36:17 +01:00
|
|
|
target:set_physics_override({sneak = true})
|
2016-09-20 12:35:02 +01:00
|
|
|
target:setpos(releasepos)
|
2016-07-04 19:26:28 +01:00
|
|
|
end
|
|
|
|
})
|
|
|
|
|
2016-07-25 00:45:43 +01:00
|
|
|
-- list caged players
|
|
|
|
minetest.register_chatcommand("list_caged", {
|
2017-09-09 18:02:54 +01:00
|
|
|
params = "",
|
2016-07-25 00:45:43 +01:00
|
|
|
description = "List all caged players.",
|
|
|
|
privs = {server = true},
|
|
|
|
func = function (_, _)
|
|
|
|
local players = ""
|
|
|
|
for player, _ in pairs(priv_table) do
|
|
|
|
players = players .. player .. ", "
|
|
|
|
end
|
|
|
|
return true, "Currently caged players: " .. players
|
|
|
|
end
|
|
|
|
})
|
|
|
|
|
2016-07-04 19:26:28 +01:00
|
|
|
|
|
|
|
|
2016-12-12 14:42:45 +00:00
|
|
|
-- Other Commands
|
2016-07-03 19:50:27 +01:00
|
|
|
|
2016-12-12 14:42:45 +00:00
|
|
|
-- hide player model and nametag (only works in 0.4.14 and above)
|
2016-07-03 19:50:27 +01:00
|
|
|
vanished_players = {}
|
|
|
|
|
|
|
|
minetest.register_chatcommand("vanish", {
|
2017-09-09 18:02:54 +01:00
|
|
|
params = "",
|
2016-07-03 19:50:27 +01:00
|
|
|
description = "Make user invisible",
|
|
|
|
privs = {hidden_one = true},
|
2017-09-09 17:53:12 +01:00
|
|
|
func = function(user)
|
2016-07-03 19:50:27 +01:00
|
|
|
local prop
|
2017-09-09 17:53:12 +01:00
|
|
|
local player = minetest.get_player_by_name(user)
|
|
|
|
vanished_players[user] = not vanished_players[user]
|
|
|
|
if vanished_players[user] then
|
2016-07-03 19:50:27 +01:00
|
|
|
prop = {visual_size = {x = 0, y = 0},
|
|
|
|
collisionbox = {0,0,0,0,0,0}}
|
|
|
|
player:set_nametag_attributes({color = {a = 0, r = 255, g = 255, b = 255}})
|
|
|
|
else
|
2016-07-14 18:36:17 +01:00
|
|
|
-- default player size.
|
2016-07-03 19:50:27 +01:00
|
|
|
prop = {visual_size = {x = 1, y = 1},
|
|
|
|
collisionbox = {-0.35, -1, -0.35, 0.35, 1, 0.35}}
|
|
|
|
player:set_nametag_attributes({color = {a = 255, r = 255, g = 255, b = 255}})
|
|
|
|
end
|
|
|
|
player:set_properties(prop)
|
|
|
|
end
|
|
|
|
})
|
|
|
|
|
2016-12-12 14:42:45 +00:00
|
|
|
-- announcements
|
2016-07-25 00:40:37 +01:00
|
|
|
minetest.register_chatcommand("proclaim", {
|
2017-09-09 18:02:54 +01:00
|
|
|
params = "<text>",
|
2016-07-03 19:50:27 +01:00
|
|
|
description = "Sends text to all players",
|
|
|
|
privs = {server = true},
|
2017-09-09 17:53:12 +01:00
|
|
|
func = function (user, text)
|
|
|
|
if not text
|
|
|
|
or text == "" then
|
2016-07-03 19:50:27 +01:00
|
|
|
return
|
|
|
|
end
|
2017-09-09 17:53:12 +01:00
|
|
|
minetest.chat_send_all(text)
|
2016-07-25 00:43:17 +01:00
|
|
|
if minetest.get_modpath("irc") then
|
|
|
|
if irc.connected and irc.config.send_join_part then
|
2017-09-09 17:53:12 +01:00
|
|
|
irc:say(text)
|
2016-07-25 00:43:17 +01:00
|
|
|
end
|
|
|
|
end
|
2016-07-03 19:50:27 +01:00
|
|
|
end
|
|
|
|
})
|
2016-07-14 18:36:17 +01:00
|
|
|
|