]> git.lizzy.rs Git - Crafter.git/blob - mods/server_messages/init.lua
Fix spamming death messages
[Crafter.git] / mods / server_messages / init.lua
1 local pool = {}
2
3 minetest.register_on_joinplayer(function(player)
4     local meta = player:get_meta()
5     local welcomed = (meta:get_int("welcomed") == 1)
6     local name = player:get_player_name()
7     pool[name] = minetest.get_us_time()/1000000
8     if not welcomed then
9         minetest.chat_send_all("Welcome "..name.." to the server!")
10         meta:set_int("welcomed", 1)
11     else
12         minetest.chat_send_all("Welcome back "..name.."!")
13     end
14 end)
15
16 local death_messages = {
17 " got smoked!",
18 " didn't see that coming!",
19 " is taking a nap!",
20 ", that looked painful!",
21 " is pushing up daisies!",
22 " is lucky there are infinite lives!",
23 " met their maker!",
24 " is in pieces!",
25 " got wrecked!",
26 " got destroyed!",
27 " got minced!",
28 "'s health bar is looking a little empty!",
29 " turned into a puzzle!",
30 " is in the Aether now!",
31 " is in the Nether!",
32 ", how's the Void?",
33 " dropped their stuff! Go get it!",
34 " is having a fire sale and everything's free!",
35 " is doomed!",
36 ", I didn't even know you could have negative health!",
37 " try not to keep dying!",
38 " died!",
39 " probably starved!",
40 " is seeing how the ground feels!",
41 " is shutting down!",
42 }
43
44 local leave_messages = {
45 " logged out.",
46 " gave up.",
47 " rage quit.",
48 "'s game probably crashed.",
49 " got bored.",
50 " left.",
51 " is going IRL.",
52 " left the matrix.",
53 " is out.",
54 }
55
56 minetest.register_on_dieplayer(function(player)
57     local name = player:get_player_name()
58     if (minetest.get_us_time()/1000000)-pool[name] > 0.001 then
59         minetest.chat_send_all(name..death_messages[math.random(1,table.getn(death_messages))])
60         pool[name] = minetest.get_us_time()/1000000
61     end
62 end)
63
64 minetest.register_on_leaveplayer(function(player)
65     local name = player:get_player_name()
66     minetest.chat_send_all(name..leave_messages[math.random(1,table.getn(leave_messages))])
67 end)
68