Add /hp command to set the HP of a given player, requires the ban privelege.

This commit is contained in:
Anthony Zhang 2013-03-07 16:47:32 -05:00
parent 3792b692aa
commit db90c1cb4b
1 changed files with 15 additions and 1 deletions

View File

@ -3,7 +3,7 @@ minetest.register_chatcommand("say", {
description = "Say <text> as the server",
privs = {server=true},
func = function(name, param)
minetest.chat_send_all(param)
minetest.chat_send_all(name .. ": " .. param)
end
})
@ -20,6 +20,20 @@ minetest.register_chatcommand("tell", {
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)
meta:set_string("formspec",
"invsize[9,6;]" ..