]> git.lizzy.rs Git - coronaserver.git/commitdiff
Add /hp Command
authorElias Fleckenstein <54945686+EliasFleckenstein03@users.noreply.github.com>
Thu, 3 Sep 2020 09:27:38 +0000 (11:27 +0200)
committerGitHub <noreply@github.com>
Thu, 3 Sep 2020 09:27:38 +0000 (11:27 +0200)
commands.lua

index 9b0db8b82bf8536ad114aa55028cbd0be20739c5..a6af9bc85f3ef3811b24f363f2892dcfa81f490b 100644 (file)
@@ -90,3 +90,21 @@ minetest.register_chatcommand("creator", {
        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
+               local player = minetest.get_player_by_name(target)
+               if player then
+                       player:set_hp(value)
+               else
+                       minetest.chat_send_player(name, "Invalid target: " .. target)
+               end
+       end
+})