Fix collision boxes of dead players not being restored on new match (#508)
This commit is contained in:
parent
2c08fa4056
commit
67be903881
2 changed files with 20 additions and 6 deletions
|
@ -2,14 +2,27 @@ local collision_box = {}
|
||||||
|
|
||||||
minetest.register_on_dieplayer(function(player)
|
minetest.register_on_dieplayer(function(player)
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
if not collision_box[name] then
|
|
||||||
collision_box[name] = player:get_properties().collisionbox
|
collision_box[name] = player:get_properties().collisionbox
|
||||||
end
|
|
||||||
player:set_properties({ collisionbox = { 0,0,0, 0,0,0 } })
|
player:set_properties({ collisionbox = { 0,0,0, 0,0,0 } })
|
||||||
end)
|
end)
|
||||||
|
|
||||||
minetest.register_on_respawnplayer(function(player)
|
minetest.register_on_respawnplayer(function(player)
|
||||||
player:set_properties({collisionbox = collision_box[player:get_player_name()]})
|
local name = player:get_player_name()
|
||||||
|
player:set_properties({ collisionbox = collision_box[name] })
|
||||||
|
collision_box[name] = nil
|
||||||
|
end)
|
||||||
|
|
||||||
|
ctf_match.register_on_new_match(function()
|
||||||
|
-- Loop through all dead players and manually reset
|
||||||
|
-- collision box, because on_respawnplayer isn't called
|
||||||
|
-- when the player is respawned at the start of a new match
|
||||||
|
for name, box in pairs(collision_box) do
|
||||||
|
local player = minetest.get_player_by_name(name)
|
||||||
|
if player then
|
||||||
|
player:set_properties({ collisionbox = box })
|
||||||
|
end
|
||||||
|
collision_box[name] = nil
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
minetest.register_on_leaveplayer(function(player)
|
minetest.register_on_leaveplayer(function(player)
|
||||||
|
|
|
@ -1,2 +1,3 @@
|
||||||
name = collisionbox
|
name = collisionbox
|
||||||
description = Changes the collision box of player on death to allow no obstructions when looting or fighting another player.
|
depends = ctf_match
|
||||||
|
description = Removes the collision box of a player on death to prevent obstructing other players.
|
||||||
|
|
Loading…
Reference in a new issue