1
+ local have_spawn_command = minetest .get_modpath (" spawn_command" )
2
+ local enable_damage = core .settings :get_bool (" enable_damage" )
3
+ local hide_names = {}
4
+
5
+ minetest .register_chatcommand (" about_essentials" , {
6
+ description = " About the 'essentials' mod." ,
7
+ func = function (name , param )
8
+ show_about (name )
9
+ end
10
+ })
11
+
12
+ -- 'spawn_command' mod
13
+ if have_spawn_command then
14
+ function set_the_spawn (name , param )
15
+ local p = {}
16
+ local posmessage = {x = 0 , y = 0 , z = 0 }
17
+ local player = minetest .get_player_by_name (name );
18
+ local pos = player :get_pos ();
19
+ local static_spawnpoint = minetest .setting_get_pos (" static_spawnpoint" );
20
+ local spawn_pos = vector .round (spawn_command .pos );
21
+ p .x , p .y , p .z = string.match (param , " ^([%d.~-]+)[, ] *([%d.~-]+)[, ] *([%d.~-]+)$" );
22
+ p = core .parse_coordinates (p .x , p .y , p .z , pos );
23
+
24
+ if player == nil then
25
+ return false
26
+ end
27
+
28
+ if p and p .x and p .y and p .z then
29
+ spawn_command .pos = {x = p .x , y = p .y , z = p .z };
30
+ static_spawnpoint = {x = p .x , y = p .y , z = p .z };
31
+ posmessage = {x = p .x , y = p .y , z = p .z };
32
+ minetest .chat_send_player (name , core .colorize (" #00FF06" , " Spawn sets successful at " .. posmessage .x .. " " .. posmessage .y .. " " .. posmessage .z .. " !" ))
33
+ elseif param == " " then
34
+ spawn_pos = vector .round (pos );
35
+ spawn_command .pos = spawn_pos ;
36
+ static_spawnpoint = spawnpos ;
37
+ minetest .chat_send_player (name , core .colorize (" #00FF06" , " Spawn sets successful at " .. spawn_pos .x .. " " .. spawn_pos .y .. " " .. spawn_pos .z .. " !" ))
38
+ else
39
+ minetest .chat_send_player (name , core .colorize (" red" , " Wrong position!" ))
40
+ end
41
+ end
42
+ minetest .register_chatcommand (" setspawn" , {
43
+ params = " <X>,<Y>,<Z>" ,
44
+ description = " Sets a spawn point." ,
45
+ privs = {server = true },
46
+ func = set_the_spawn ,
47
+ })
48
+ end
49
+ -- end
50
+
51
+ minetest .register_chatcommand (" ip" , {
52
+ params = " <name>" ,
53
+ description = " Show the IP of a player." ,
54
+ privs = {server = true },
55
+ func = function (name , param )
56
+ if param == " " then
57
+ minetest .chat_send_player (name , " Your IP of is " .. minetest .get_player_ip (name ))
58
+ return
59
+ end
60
+ if minetest .get_player_by_name (param ) == nil then
61
+ minetest .chat_send_player (name , core .colorize (" red" , " Player " .. param .. " not found!" ))
62
+ return
63
+ end
64
+ minetest .chat_send_player (name , " IP of " .. param .. " is " .. minetest .get_player_ip (param ))
65
+ end ,
66
+ })
67
+
68
+ minetest .register_chatcommand (" broadcast" , {
69
+ params = " <message>" ,
70
+ description = " Send GLOBAL message in chat." ,
71
+ privs = {server = true },
72
+ func = function (name , param )
73
+ if param == " " then
74
+ core .chat_send_player (name , core .colorize (" red" , " Message cannot be empty!" ))
75
+ else
76
+ core .chat_send_all (core .colorize (" #00FFC6" , param ))
77
+ end
78
+ end ,
79
+ })
80
+
81
+ if enable_damage then
82
+ function god_mode (name , param )
83
+ local player = minetest .get_player_by_name (name )
84
+ local ag = player :get_armor_groups ()
85
+ if not ag [" immortal" ] then
86
+ ag [" immortal" ] = 1
87
+ core .chat_send_player (name , " God mode enabled" )
88
+ else
89
+ ag [" immortal" ] = nil
90
+ core .chat_send_player (name , " God mode diabled" )
91
+ end
92
+ player :set_armor_groups (ag )
93
+ end
94
+
95
+ minetest .register_chatcommand (" god" , {
96
+ description = " Enable/Disabe the god mode." ,
97
+ privs = {god = true },
98
+ func = god_mode
99
+ })
100
+ end
101
+
102
+ minetest .register_chatcommand (" ban_menu" , {
103
+ description = " Open the ban menu." ,
104
+ privs = {ban = true },
105
+ func = function (name , param )
106
+ if core .is_singleplayer () then
107
+ minetest .chat_send_player (name , core .colorize (" red" , " You cannot ban in single mode!" ))
108
+ else
109
+ show_ban_menu (name )
110
+ end
111
+ end
112
+ })
113
+
114
+ minetest .register_chatcommand (" kick_menu" , {
115
+ description = " Open the kick menu." ,
116
+ privs = {kick = true },
117
+ func = function (name , param )
118
+ if core .is_singleplayer () then
119
+ minetest .chat_send_player (name , core .colorize (" red" , " You cannot kick in single mode!" ))
120
+ else
121
+ show_kick_menu (name )
122
+ end
123
+ end
124
+ })
125
+
126
+ -- minetest.register_chatcommand("mute_menu", {
127
+ -- description = "Open the mute menu.",
128
+ -- privs = {mute = true},
129
+ -- func = function(name, param)
130
+ -- if core.is_singleplayer() then
131
+ -- minetest.chat_send_player(name, core.colorize("red", "You cannot mute in single mode!"))
132
+ -- else
133
+ -- show_mute_menu(name)
134
+ -- end
135
+ -- end
136
+ -- })
137
+
138
+ minetest .register_chatcommand (" getpos" , {
139
+ params = " <name>" ,
140
+ description = " Allows the player to find out the position of another player." ,
141
+ privs = {vip = true },
142
+ func = function (name , param )
143
+ local player = minetest .get_player_by_name (param );
144
+
145
+ if param == " " then
146
+ minetest .chat_send_player (name , core .colorize (" red" , " Player name cannot be empty!" ))
147
+ return
148
+ elseif minetest .get_player_by_name (param ) == nil then
149
+ minetest .chat_send_player (name , core .colorize (" red" , " Player " .. param .. " not found!" ))
150
+ return
151
+ else
152
+ local pos = player :get_pos ();
153
+ local round_pos = vector .round (pos );
154
+ minetest .chat_send_player (name , " Position of " .. param .. " is " .. round_pos .x .. " " .. round_pos .y .. " " .. round_pos .z )
155
+ end
156
+ end ,
157
+ })
158
+
159
+ minetest .register_chatcommand (" rename_me" , {
160
+ params = " <new_name>" ,
161
+ description = " Hide your real name and rename it on fake." ,
162
+ privs = {},
163
+ func = function (name , param )
164
+ hide_names [name ] = param
165
+ end
166
+ })
167
+
168
+ minetest .register_on_chat_message (function (name , message )
169
+ local new_name = hide_names [name ]
170
+ if new_name then
171
+ minetest .chat_send_all (" <" .. new_name .. " > " .. message )
172
+ return true
173
+ end
174
+ end )
0 commit comments