diff --git a/README.md b/README.md index ce62a38..7e73532 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ # A.E.S. - Terms of service -The terms to accept in order to play \ No newline at end of file +The terms to accept in order to play + +Highly modified version of the Kaeza mod diff --git a/init.lua b/init.lua new file mode 100755 index 0000000..d685305 --- /dev/null +++ b/init.lua @@ -0,0 +1,3 @@ +--originally by keaza +dofile(minetest.get_modpath("terms_of_service") .. "/player_manager.lua") +dofile(minetest.get_modpath("terms_of_service") .. "/privs.lua") diff --git a/locale/terms_of_use.it.tr b/locale/terms_of_use.it.tr new file mode 100755 index 0000000..21ff5d3 --- /dev/null +++ b/locale/terms_of_use.it.tr @@ -0,0 +1,18 @@ +# textdomain: terms_of_service + +Always respect other players=Rispettare gli altri giocatori, sempre e comunque +No excessive swearing=Niente bestemmie o eccesso di imprecazioni +No modified clients=Niente client modificati +Admins reserve the right to remove whoever transgress the rules. In case of repeated misbehaviours, the user will be banned=Gli admin si riservano il diritto di allontanare chi trasgredisce le regole. In caso di comportamenti ripetuti, l'utente verrà bannato +never=mai +SERVER RULES=REGOLAMENTO SERVER +When can I insult a user? One word=Quando posso insultare un utente? Una parola +Accept=Accetto +Deny=Rifiuto +always=sempre +You're funny, but we're funnier=Sei simpatico/a, ma noi di più +Enjoy your staying!=Buon divertimento! +Wrong, try again=Sbagliato, riprova +Please read carefully and click 'accept'=Per favore leggi meglio e clicca 'accetto' +All the players must adhere to the rules=Tutti i giocatori devono aderire al regolamento + diff --git a/mod.conf b/mod.conf new file mode 100755 index 0000000..095b809 --- /dev/null +++ b/mod.conf @@ -0,0 +1 @@ +name = terms_of_service diff --git a/player_manager.lua b/player_manager.lua new file mode 100644 index 0000000..b08bd38 --- /dev/null +++ b/player_manager.lua @@ -0,0 +1,84 @@ +local S = minetest.get_translator("terms_of_service") + +local function make_formspec() end + +local TOS = [[ +]] .. "1) " .. S("Always respect other players") .. "\n" .. [[ +]] .. "2) " .. S("No excessive swearing") .. "\n" .. [[ +]] .. "3) " .. S("No modified clients") .. "\n" .. [[ +]] .. "\n" .. [[ +]] .. S("Admins reserve the right to remove whoever transgress the rules. In case of repeated misbehaviours, the user will be banned") + + + +minetest.register_on_joinplayer(function(player) + + local p_name = player:get_player_name() + + if not minetest.get_player_privs(p_name).tos_accepted then + minetest.after(1, function() + minetest.show_formspec(p_name, "tos:tos_fs", make_formspec()) + end) + end +end) + + + +minetest.register_on_player_receive_fields(function(player, formname, fields) + + if formname ~= "tos:tos_fs" then return end + + local p_name = player:get_player_name() + + if fields.ok or fields.key_enter then + + if fields.hidden_word == string.lower(fields.entry) then + local privs = minetest.get_player_privs(p_name) + privs.tos_accepted = true + privs.interact = true + minetest.set_player_privs(p_name, privs) + minetest.chat_send_player(p_name, S("Enjoy your staying!")) + + else + minetest.chat_send_player(p_name, S("Wrong, try again")) + minetest.show_formspec(p_name, "tos:tos_fs", make_formspec()) + return + end + + elseif fields.quit then + if not minetest.get_player_privs(p_name).tos_accepted then + minetest.chat_send_player(p_name, S("Please read carefully and click 'accept'")) + minetest.show_formspec(p_name, "tos:tos_fs", make_formspec()) + return + end + + elseif fields.no then + minetest.kick_player(p_name, S("All the players must adhere to the rules")) + return + + else + minetest.show_formspec(p_name, "tos:tos_fs", make_formspec()) + end +end) + + + + + +---------------------------------------------- +---------------FUNZIONI LOCALI---------------- +---------------------------------------------- + +function make_formspec() + local word = S("never") + local formspec = { + "size[9,8]", + "textarea[0.5,0.5;8,7;TOS;".. S("SERVER RULES") .. ";"..TOS.."]", + "field[0.5,7.5;6,1;entry;" .. S("When can I insult a user? One word") .. ";]", + "button_exit[6,7.4;1.5,0.5;ok;" .. S("Accept") .. "]", + "button[7.5,7.4;1.5,0.5;no;" .. S("Deny") .. "]", + "field[10,10;0.1,0.1;hidden_word;;"..word.."]", + "field_close_on_enter[;false]" + } + return table.concat(formspec, "") +end diff --git a/privs.lua b/privs.lua new file mode 100644 index 0000000..0b881d5 --- /dev/null +++ b/privs.lua @@ -0,0 +1 @@ +minetest.register_privilege("tos_accepted", "TOS Accepted")