OnPlayerDeath: Difference between revisions
(Created page with "test") |
No edit summary |
||
| (2 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
This event is triggered when a player dies. | |||
{{CSharpContainer| | |||
{{#tag:syntaxhighlight| | |||
[ServerEvent(Event.PlayerDeath)] | |||
|lang=csharp | |||
}} | |||
{{Parameters}} | |||
*'''player:''' parameter input should be in '''Player''' type | |||
*'''killer:''' parameter input should be in '''Player''' type | |||
*'''reason:''' parameter input should be in '''uint''' type | |||
{{Example}} | |||
{{#tag:syntaxhighlight| | |||
[ServerEvent(Event.PlayerDeath)] | |||
public void OnPlayerDeath(Player player, Player killer, uint reason) | |||
{ | |||
if (!killer.IsNull) | |||
{ | |||
NAPI.Chat.SendChatMessageToAll($"{killer.Name} has killed {player.Name} with {reason}."); | |||
} | |||
else | |||
{ | |||
NAPI.Chat.SendChatMessageToAll($"{player.Name} has died ({reason})."); | |||
} | |||
} | |||
|lang=csharp}} | |||
}} | |||
[[Category:Serverside Events]] | |||
Latest revision as of 13:19, 22 May 2023
This event is triggered when a player dies.
C# Syntax
[ServerEvent(Event.PlayerDeath)]
Parameters
- player: parameter input should be in Player type
- killer: parameter input should be in Player type
- reason: parameter input should be in uint type
Example
[ServerEvent(Event.PlayerDeath)]
public void OnPlayerDeath(Player player, Player killer, uint reason)
{
if (!killer.IsNull)
{
NAPI.Chat.SendChatMessageToAll($"{killer.Name} has killed {player.Name} with {reason}.");
}
else
{
NAPI.Chat.SendChatMessageToAll($"{player.Name} has died ({reason}).");
}
}