Give kill type to on_killedplayer, and fix crash in ctf_colors.get_color()

master
rubenwardy 2016-04-05 17:15:59 +01:00
parent 386d72965e
commit f1bc56f4cd
2 changed files with 17 additions and 2 deletions

View File

@ -449,8 +449,19 @@ minetest.register_on_punchplayer(function(player, hitter,
end
if player:get_hp() - damage <= 0 then
local wielded = hitter:get_wielded_item()
local wname = wielded:get_name()
print(wname)
local type = "sword"
if wname:sub(1, 8) == "shooter:" then
if wname == "shooter:grenade" then
type = "grenade"
else
type = "bullet"
end
end
for i = 1, #ctf.registered_on_killedplayer do
ctf.registered_on_killedplayer[i](player:get_player_name(), hitter:get_player_name())
ctf.registered_on_killedplayer[i](player:get_player_name(), hitter:get_player_name(), type)
end
return false
end

View File

@ -1,5 +1,9 @@
function ctf_colors.get_color(name, tplayer)
local tcolor_text = ctf.team(tplayer.team).data.color
local team = ctf.team(tplayer.team)
local tcolor_text = nil
if team then
tcolor_text = team.data.color
end
local tcolor_hex = ctf.flag_colors[tcolor_text]
if not tcolor_hex then
tcolor_hex = "0x000000"