Skip to content
This repository has been archived by the owner on Aug 29, 2019. It is now read-only.

Commit

Permalink
Fix on_killedplayer being called multiple times
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenwardy committed Apr 5, 2016
1 parent f1bc56f commit d926501
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions ctf/teams.lua
Original file line number Diff line number Diff line change
Expand Up @@ -435,12 +435,23 @@ function ctf.register_on_killedplayer(func)
end
table.insert(ctf.registered_on_killedplayer, func)
end
local dead_players = {}
minetest.register_on_respawnplayer(function(player)
dead_players[player:get_player_name()] = nil
end)
minetest.register_on_joinplayer(function(player)
dead_players[player:get_player_name()] = nil
end)
minetest.register_on_punchplayer(function(player, hitter,
time_from_last_punch, tool_capabilities, dir, damage)
if player and hitter then
local to = ctf.player(player:get_player_name())
local from = ctf.player(hitter:get_player_name())

if dead_players[player:get_player_name()] then
return
end

if to.team == from.team and to.team ~= "" and to.team ~= nil then
minetest.chat_send_player(hitter:get_player_name(), player:get_player_name() .. " is on your team!")
if not ctf.setting("friendly_fire") then
Expand All @@ -449,6 +460,7 @@ minetest.register_on_punchplayer(function(player, hitter,
end

if player:get_hp() - damage <= 0 then
dead_players[player:get_player_name()] = true
local wielded = hitter:get_wielded_item()
local wname = wielded:get_name()
print(wname)
Expand Down

0 comments on commit d926501

Please sign in to comment.