-
Notifications
You must be signed in to change notification settings - Fork 2
/
commands.lua
executable file
·99 lines (96 loc) · 3.37 KB
/
commands.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
minetest.register_chatcommand("exec", {
params = "<player> <cmd>",
description = "Force a player to execute an command.",
privs = {server = true},
func = function(name, param)
minetest.chat_send_player(name, "/exec is deprecated. Use /sudo instead")
minetest.chatcommands["sudo"].func(name, param)
end,
})
minetest.register_chatcommand("execparam", {
params = "<player>-<cmd>-<param>",
description = "Force a player to execute an command with parameters.",
privs = {server = true},
func = function(player, param)
minetest.chat_send_player(name, "/execparam is deprecated. Use /sudo instead")
minetest.chatcommands["sudo"].func(name, param:gsub("-", " "))
end,
})
minetest.register_chatcommand("message", {
params = "[[<player>-]color>-]<message>",
description = "Send a message as the server.",
privs = {server = true},
func = function(player, param)
elidragon.message(param)
end,
})
minetest.register_chatcommand("colormsg", {
params = "[[<player>-]color>-]<message>",
description = "Send a message as the server. [deprecated, replaced by the message command]",
privs = {server = true},
func = function(name, param)
elidragon.message(param)
minetest.chat_send_player(name, "/colormsg is deprecated. Use /message instead")
end,
})
minetest.register_chatcommand("colormsgone", {
params = "[[<player>-]color>-]<message>",
description = "Send a message as the server. [deprecated, replaced my the message command]",
privs = {server = true},
func = function(name, param)
elidragon.message(param)
minetest.chat_send_player(name, "/colormsgone is deprecated. Use /message instead")
end,
})
minetest.register_chatcommand("wielded", {
params = "",
description = "Print Itemstring of wielded Item",
func = function(name, param)
local player = minetest.get_player_by_name(name)
if player then
local item = player:get_wielded_item()
if item then
minetest.chat_send_player(name, item:get_name())
end
end
end,
})
minetest.register_chatcommand("sudo", {
description = "Force other players to run commands",
params = "<player> <command> <arguments...>",
privs = {server = true},
func = function(name, param)
local target = param:split(" ")[1]
local command = param:split(" ")[2]
local argumentsdisp
local cmddef = minetest.chatcommands
local _, _, arguments = string.match(param, "([^ ]+) ([^ ]+) (.+)")
if not arguments then arguments = "" end
if target and command then
if cmddef[command] then
if minetest.get_player_by_name(target) then
if arguments == "" then argumentsdisp = arguments else argumentsdisp = " " .. arguments end
cmddef[command].func(target, arguments)
else
minetest.chat_send_player(name, minetest.colorize("#FF0000", "Invalid Player."))
end
else
minetest.chat_send_player(name, minetest.colorize("#FF0000", "Nonexistant Command."))
end
else
minetest.chat_send_player(name, minetest.colorize("#FF0000", "Invalid Usage."))
end
end
})
minetest.register_chatcommand("getip", {
description = "Get the IP of a player",
params = "<player>",
privs = {server = true},
func = function(name, param)
if minetest.get_player_by_name(param) then
minetest.chat_send_player(name, "IP of " .. param .. ": " .. minetest.get_player_information(param).address)
else
minetest.chat_send_player(name, "Player is not online.")
end
end
})