How to determine if the player has been killed?
How to determine if the player has been killed?
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?
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
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.
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)
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?
Thank you very much!