init.lua 763 B

1234567891011121314151617181920212223242526272829
  1. kickall = kickall or {}
  2. kickall.modpath = minetest.get_modpath("kickall")
  3. minetest.register_chatcommand("kickall", {
  4. params = "<message>",
  5. description = "Kick all players, with a message.",
  6. privs = {kick=true},
  7. func = function(name, param)
  8. if param == nil or param == "" then
  9. minetest.chat_send_player(name, "# Server: Please provide a reason, so players know why they are kicked.")
  10. return false
  11. end
  12. local players = minetest.get_connected_players()
  13. for k, v in pairs(players) do
  14. local pname = v:get_player_name()
  15. if pname ~= name then
  16. minetest.kick_player(pname, param)
  17. end
  18. end
  19. minetest.chat_send_player(name, "# Server: All other players kicked!")
  20. return true
  21. end,
  22. })