rules/init.lua

141 lines
4.3 KiB
Lua
Raw Normal View History

2018-11-11 18:57:07 +00:00
rules = {}
2020-09-20 18:06:09 +00:00
local S = minetest.get_translator(minetest.get_current_modname())
2018-11-11 18:57:07 +00:00
local items = {
2020-09-20 18:06:09 +00:00
S("By playing on this server you agree to these rules:"),
2018-11-11 18:57:07 +00:00
"",
S("1. No swearing, dating, or other inappropriate behaviour."),
2020-09-20 18:06:09 +00:00
S("2. No spamming, using all-caps, or any other method of chat abuse."),
S("3. Don't be a cheater. No hacked clients."),
S("4. Spawnkilling is considered excessive and thus forbidden if it doesn't"),
" " .. S("contribute to the goal of the game in a proper way. Consequently,"),
" " .. S("spawnkilling can already be punished if only two kills are made,"),
" " .. S("depending on the situation."),
2020-09-20 18:06:09 +00:00
S("5. Don't be a traitor. Don't:"),
S(" a. Dig blocks in your base to make it less secure or"),
S(" to trap team mates on purpose."),
S(" b. Help the other team win."),
S(" c. Change teams."),
S("6. Don't leave the game whilst in a fight"),
S("7. Don't impersonate other community members"),
S("8. Do not share your password with ANYONE."),
S("9. Avoid controversial topics like politics/religion"),
S("10. Moderator decisions are final."),
2018-11-11 18:57:07 +00:00
"",
2020-09-20 18:06:09 +00:00
S("Failure to follow these rules may result in a kick or ban"),
S(" (temp or permanent) depending on severity."),
2018-11-11 18:57:07 +00:00
"",
2022-05-09 20:31:16 +00:00
S("Created by rubenwardy. Developed by ")..S("LandarVargan and savilli."),
2021-02-20 21:30:49 +00:00
S("Moderators")..": Thomas-S, IceAgeComing, Waterbug, DragonsVolcanoDance,",
2022-05-02 23:26:16 +00:00
" Shara, Calinou, Aurika, LandarVargan, Xenon, Jhalman, Kat",
2018-11-11 18:57:07 +00:00
"",
2020-09-20 18:06:09 +00:00
S("Though the server owner will not actively read private messages or disclose"),
S("their content outside the mod team, random checks will be done to make sure"),
S("they are not being abused and they will be reviewed if abuse or inappropriate"),
2021-02-22 20:25:03 +00:00
S("behaviour is suspected."),
2018-11-11 18:57:07 +00:00
"",
2020-09-20 18:06:09 +00:00
S("Use /report to send a message to a moderator."),
S("For example, /report bobgreen is destroying our base")}
2018-11-11 18:57:07 +00:00
for i = 1, #items do
items[i] = minetest.formspec_escape(items[i])
end
rules.txt = table.concat(items, ",")
if minetest.global_exists("sfinv") then
sfinv.register_page("rules:rules", {
title = "Rules",
get = function(self, player, context)
return sfinv.make_formspec(player, context,
"textlist[0,0;7.85,8.5;help;" .. rules.txt .. "]", false)
end
})
end
local function need_to_accept(pname)
2019-01-20 23:43:34 +00:00
return not minetest.check_player_privs(pname, { interact = true }) and
not minetest.check_player_privs(pname, { shout = true })
2019-01-19 23:43:19 +00:00
end
2018-11-11 18:57:07 +00:00
function rules.show(player)
2019-01-19 23:43:19 +00:00
local pname = player:get_player_name()
2019-01-20 00:07:26 +00:00
local fs = "size[8,8.6]bgcolor[#080808BB;true]" ..
"textlist[0.1,0.1;7.8,7.9;msg;" .. rules.txt .. ";-1;true]"
2018-11-11 18:57:07 +00:00
if not need_to_accept(pname) then
2019-01-20 00:07:26 +00:00
fs = fs .. "button_exit[0.5,7.6;7,2;ok;Okay]"
2018-11-11 18:57:07 +00:00
else
local yes = minetest.formspec_escape("Yes, let me play!")
local no = minetest.formspec_escape("No, get me out of here!")
2019-01-20 00:07:26 +00:00
fs = fs .. "button_exit[0.5,7.6;3.5,2;no;" .. no .. "]"
fs = fs .. "button_exit[4,7.6;3.5,2;yes;" .. yes .. "]"
2018-11-11 18:57:07 +00:00
end
2019-01-19 23:43:19 +00:00
minetest.show_formspec(pname, "rules:rules", fs)
2018-11-11 18:57:07 +00:00
end
minetest.register_chatcommand("rules", {
2019-01-20 23:43:34 +00:00
func = function(pname, param)
2018-11-11 18:57:07 +00:00
if param ~= "" and
2019-01-20 23:43:34 +00:00
minetest.check_player_privs(pname, { kick = true }) then
pname = param
2018-11-11 18:57:07 +00:00
end
2019-01-20 23:43:34 +00:00
local player = minetest.get_player_by_name(pname)
2018-11-11 18:57:07 +00:00
if player then
rules.show(player)
return true, "Rules shown."
else
2019-01-20 23:43:34 +00:00
return false, "Player " .. pname .. " does not exist or is not online"
2018-11-11 18:57:07 +00:00
end
end
})
minetest.register_on_newplayer(function(player)
2019-01-19 23:43:19 +00:00
local pname = player:get_player_name()
local privs = minetest.get_player_privs(pname)
privs.shout = nil
privs.interact = nil
minetest.set_player_privs(pname, privs)
2018-11-11 18:57:07 +00:00
rules.show(player)
end)
minetest.register_on_joinplayer(function(player)
if need_to_accept(player:get_player_name()) then
2018-11-11 18:57:07 +00:00
rules.show(player)
end
end)
minetest.register_on_player_receive_fields(function(player, form, fields)
if form ~= "rules:rules" then return end
2018-11-11 18:57:07 +00:00
2019-01-20 23:43:34 +00:00
local pname = player:get_player_name()
if not need_to_accept(pname) then
2018-11-11 18:57:07 +00:00
return true
end
if fields.no then
2019-01-20 23:43:34 +00:00
minetest.kick_player(pname,
2018-11-11 18:57:07 +00:00
"You need to agree to the rules to play on this server. " ..
"Please rejoin and confirm another time.")
return true
end
if not fields.yes then
return true
end
2019-01-20 23:43:34 +00:00
local privs = minetest.get_player_privs(pname)
2018-11-11 18:57:07 +00:00
privs.shout = true
privs.interact = true
2019-01-20 23:43:34 +00:00
minetest.set_player_privs(pname, privs)
2018-11-11 18:57:07 +00:00
2019-01-20 23:43:34 +00:00
minetest.chat_send_player(pname, "Welcome "..pname.."! You have now permission to play!")
2018-11-11 18:57:07 +00:00
return true
end)