Page 1 of 1
How to determine if the player has been killed?
Posted: Mon Dec 15, 2014 9:49 am
by FatApe
I am trying to make my mod do something when the player dies. I tried using the onentitydied event but that is called every time any entity dies. How do I check if just the player has died. Thanks.
Re: How to determine if the player has been killed?
Posted: Mon Dec 15, 2014 1:04 pm
by L0771
is with onentitydied, but you can't know who player has die.
I use a code like this, if a entity die, asks what player is dead, on this save a var with the dead player
Code: Select all
game.onevent(defines.events.onentitydied, function(event)
if event.entity.type == "player" then
local player
for _,vplayer in ipairs(game.players) do
if v.character == nil and glob.dead[vplayer.name] == nil then
player = v
end
end
if player ~= nil then
glob.dead[player.name] = true
-- code
end
end
end)
Is an example je
With this can know what player is dead, for multiplayer, and if have a mod who adds entities type player NPC.
onplayerdied doesn't exist.
Re: How to determine if the player has been killed?
Posted: Mon Dec 15, 2014 5:35 pm
by FatApe
Thank you very much!