2
0

static_spawn.lua 752 B

123456789101112131415161718192021
  1. local static_spawnpoint_string = core.settings:get("static_spawnpoint")
  2. if static_spawnpoint_string and
  3. static_spawnpoint_string ~= "" and
  4. not core.setting_get_pos("static_spawnpoint") then
  5. error('The static_spawnpoint setting is invalid: "' ..
  6. static_spawnpoint_string .. '"')
  7. end
  8. local function put_player_in_spawn(player_obj)
  9. local static_spawnpoint = core.setting_get_pos("static_spawnpoint")
  10. if not static_spawnpoint then
  11. return false
  12. end
  13. core.log("action", "Moving " .. player_obj:get_player_name() ..
  14. " to static spawnpoint at " .. core.pos_to_string(static_spawnpoint))
  15. player_obj:set_pos(static_spawnpoint)
  16. return true
  17. end
  18. core.register_on_newplayer(put_player_in_spawn)
  19. core.register_on_respawnplayer(put_player_in_spawn)