Mod který kontroluje přečtení pravidel serveru. by kaeza: http://pastebin.com/QVJw577B
local FORMNAME = "tos:tos_fs" local TOS = [[ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce sit amet nunc egestas, euismod neque at, placerat quam. Proin nec massa malesuada, egestas elit tincidunt, cursus nunc. Morbi libero justo, sodales sed lacus nec, convallis rhoncus est. Cras pharetra elit sit amet enim vulputate semper. Sed in laoreet est. Curabitur euismod lacus mauris, id vulputate ante mattis ac. In semper accumsan mollis. Duis in tincidunt ligula. Vivamus pellentesque lacus eros, id eleifend elit rutrum eget. Cras facilisis nulla nisl, nec mollis ligula scelerisque nec. Etiam ultrices egestas erat, non iaculis risus ornare in. Vivamus sed nisl vitae dolor condimentum sodales. Vestibulum eget pretium metus, ut fermentum ipsum. Phasellus arcu tortor, egestas malesuada sagittis a, vestibulum ut tellus. Nulla tincidunt mauris vitae dolor consectetur malesuada. Mauris placerat est turpis, vel fringilla tellus venenatis nec. Cras interdum porttitor ipsum, id sodales sapien pharetra eu. Pellentesque mattis quis sapien ut sagittis. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae. Nunc nec massa tincidunt mauris commodo imperdiet vel ac purus. Aliquam in ultrices nibh. Nam aliquam laoreet arcu, eget pharetra lorem viverra vitae. In et fringilla nulla. Fusce ac aliquet nulla. Nulla ultricies vitae tortor sit amet mattis. Integer nibh magna, laoreet in mattis sit amet, vulputate sed neque. Proin accumsan interdum risus, eget tristique lacus scelerisque cursus. ]] local TOS_list = { } -- list[paragraph][word] local par_wordlist par_wordlist = { } for line in TOS:gmatch("(.-)\n") do if line == "" then table.insert(TOS_list, par_wordlist) par_wordlist = { } end for word in line:gmatch("[%w][%w'_-]*") do table.insert(par_wordlist, word) end end local ord_suffix = { "st", "nd", "rd", [11] = "th", [12] = "th", [13] = "th" } local function ordinal(n) return n..(ord_suffix[n % 100] or ord_suffix[n % 10] or "th") end local function rnditem(list) local i = math.floor(math.random(1, #list)) return list[i], i end local function make_formspec() local par, pindex = rnditem(TOS_list) local word, windex = rnditem(par) local fs = { "size[8,6]" } table.insert(fs, "textarea[0.5,0.5;7,5;TOS;Terms of Service;"..TOS.."]") table.insert(fs, "field[0.5,5;5,1;entry;Please enter the " ..ordinal(windex).." word of the "..ordinal(pindex).." paragraph.;]") table.insert(fs, "button[6,5;1.5,0.5;ok;Accept]") table.insert(fs, "field[10,10;0.1,0.1;hidden_word;;"..word.."]") return table.concat(fs) end minetest.register_on_player_receive_fields(function(player, formname, fields) if formname ~= FORMNAME then return end local name = player:get_player_name() if fields.quit then local privs = minetest.get_player_privs(name) if not privs.tos_accepted then minetest.chat_send_player(name, "Please read the message.") minetest.show_formspec(name, FORMNAME, make_formspec()) return end elseif fields.ok then if fields.hidden_word == fields.entry then minetest.chat_send_player(name, "You're on!") local privs = minetest.get_player_privs(name) privs.tos_accepted = true minetest.set_player_privs(name, privs) else minetest.chat_send_player(name, "Wrong word.") minetest.show_formspec(name, FORMNAME, make_formspec()) return end end end) minetest.register_on_joinplayer(function(player) local name = player:get_player_name() local privs = minetest.get_player_privs(name) if not privs.tos_accepted then minetest.after(1, function() minetest.show_formspec(name, FORMNAME, make_formspec()) end) end end) minetest.register_privilege("tos_accepted", "TOS Accepted")