init.lua 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. kill = kill or {}
  2. kill.modpath = minetest.get_modpath("kill")
  3. minetest.register_privilege("kill", "Player can kill other players via command.")
  4. minetest.register_privilege("killme", "Player can ask the server to kill them.")
  5. minetest.register_chatcommand("kill", {
  6. params = "<player>",
  7. description = "Kill specified player.",
  8. privs = {kill=true},
  9. func = function(name, param)
  10. if param == nil or param == "" then
  11. minetest.chat_send_player(name, "# Server: You must supply a player's name.")
  12. easyvend.sound_error(name)
  13. return false
  14. end
  15. assert(type(param) == "string")
  16. local player = minetest.get_player_by_name(param)
  17. if not player then
  18. minetest.chat_send_player(name, "# Server: Player <" .. rename.gpn(param) .. "> not found.")
  19. easyvend.sound_error(name)
  20. return false
  21. end
  22. player:set_hp(0)
  23. return true
  24. end
  25. })
  26. minetest.register_chatcommand("killme", {
  27. params = "",
  28. description = "Kill yourself.",
  29. privs = {killme=true},
  30. func = function(name, param)
  31. minetest.chat_send_player(name, "# Server: Killing player <" .. rename.gpn(name) ..">.")
  32. minetest.get_player_by_name(name):set_hp(0)
  33. return true
  34. end
  35. })