forked from Mirrorlandia_minetest/mesecons
Add /hp command to set the HP of a given player, requires the ban privelege.
This commit is contained in:
parent
3792b692aa
commit
db90c1cb4b
@ -3,7 +3,7 @@ minetest.register_chatcommand("say", {
|
|||||||
description = "Say <text> as the server",
|
description = "Say <text> as the server",
|
||||||
privs = {server=true},
|
privs = {server=true},
|
||||||
func = function(name, param)
|
func = function(name, param)
|
||||||
minetest.chat_send_all(param)
|
minetest.chat_send_all(name .. ": " .. param)
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -20,6 +20,20 @@ minetest.register_chatcommand("tell", {
|
|||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
minetest.register_chatcommand("hp", {
|
||||||
|
params = "<name> <value>",
|
||||||
|
description = "Set health of <name> to <value> hitpoints",
|
||||||
|
privs = {ban=true},
|
||||||
|
func = function(name, param)
|
||||||
|
local found, _, target, value = param:find("^([^%s]+)%s+(%d+)$")
|
||||||
|
if found == nil then
|
||||||
|
minetest.chat_send_player(name, "Invalid usage: " .. param)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
minetest.get_player_by_name(target):set_hp(value)
|
||||||
|
end
|
||||||
|
})
|
||||||
|
|
||||||
local initialize_data = function(meta, player, command, param)
|
local initialize_data = function(meta, player, command, param)
|
||||||
meta:set_string("formspec",
|
meta:set_string("formspec",
|
||||||
"invsize[9,6;]" ..
|
"invsize[9,6;]" ..
|
||||||
|
Loading…
Reference in New Issue
Block a user