onjoin.lua 435 B

1234567891011121314151617181920
  1. minetest.register_on_joinplayer(function(player)
  2. minetest.after(2, function(name)
  3. local messages = mail.getMessages(name)
  4. local unreadcount = 0
  5. for _, message in pairs(messages) do
  6. if message.unread then
  7. unreadcount = unreadcount + 1
  8. end
  9. end
  10. if unreadcount > 0 then
  11. minetest.chat_send_player(name,
  12. "(" .. unreadcount .. ") You have mail! Type /mail to read")
  13. end
  14. end, player:get_player_name())
  15. end)