OnPlayerDeath: Difference between revisions

From Onset Developer Wiki
Chloe (talk | contribs)
mNo edit summary
REDRUM (talk | contribs)
 
Line 10: Line 10:


== Example ==
== Example ==
__EDIT_ME__
<syntaxhighlight lang="Lua">
function OnPlayerDeath(player, instigator)
    if player == instigator then
AddPlayerChat(player, '<span color="#ff0000">You have killed yourself.</>')
      else
        AddPlayerChat(player, '<span color="#ff0000">You were killed by '..GetPlayerName(instigator)..'.</>')
    end
end
AddEvent("OnPlayerDeath", OnPlayerDeath)
</syntaxhighlight>


{{RelatedFunctions}}
{{RelatedFunctions}}
{{PlayerEvents}}
{{PlayerEvents}}

Latest revision as of 22:46, 24 January 2020

OnPlayerDeath

Type: Event
Context: Server & Client
Introduced: v1.0

Description

Calls when a player dies by any means possible. If the player wasn't killed by another player, instigator will be the same as the player.

Syntax

OnPlayerDeath(player, instigator)

Parameters

  • player
    The player that has died.
  • instigator
    The player who is responsible for the death.

Example

function OnPlayerDeath(player, instigator)
    if player == instigator then 
	AddPlayerChat(player, '<span color="#ff0000">You have killed yourself.</>')
      else
        AddPlayerChat(player, '<span color="#ff0000">You were killed by '..GetPlayerName(instigator)..'.</>')
    end
end
AddEvent("OnPlayerDeath", OnPlayerDeath)

See also