Fix up and re-add kill assists (#782)
* Add kill assists * Fix bug * Move to seperate mod * Fix bugs and improve code some more Co-authored-by: LoneWolfHT <lonewolf04361@gmail.com>
This commit is contained in:
parent
c9c2f6c7e0
commit
f8cb85be9f
11 changed files with 138 additions and 39 deletions
|
@ -445,6 +445,15 @@ function ctf.register_on_killedplayer(func)
|
|||
end
|
||||
table.insert(ctf.registered_on_killedplayer, func)
|
||||
end
|
||||
|
||||
ctf.registered_on_punchplayer = {}
|
||||
function ctf.register_on_punchplayer(func)
|
||||
if ctf._mt_loaded then
|
||||
error("You can't register callbacks at game time!")
|
||||
end
|
||||
table.insert(ctf.registered_on_punchplayer, func)
|
||||
end
|
||||
|
||||
local dead_players = {}
|
||||
minetest.register_on_respawnplayer(function(player)
|
||||
dead_players[player:get_player_name()] = nil
|
||||
|
@ -453,7 +462,7 @@ 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)
|
||||
time_from_last_punch, tool_capabilities, dir, damage, ...)
|
||||
if player and hitter then
|
||||
local pname = player:get_player_name()
|
||||
local hname = hitter:get_player_name()
|
||||
|
@ -487,5 +496,12 @@ minetest.register_on_punchplayer(function(player, hitter,
|
|||
end
|
||||
return false
|
||||
end
|
||||
|
||||
for i = 1, #ctf.registered_on_punchplayer do
|
||||
ctf.registered_on_punchplayer[i](
|
||||
player, hitter, time_from_last_punch,
|
||||
tool_capabilities, dir, damage, ...
|
||||
)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue