OnPlayerDeath: Difference between revisions

From RAGE Multiplayer Wiki
mNo edit summary
No edit summary
Line 8: Line 8:


{{Parameters}}
{{Parameters}}
*'''player:''' parameter input should be in '''Client''' type
*'''player:''' parameter input should be in '''Player''' type
*'''killer:''' parameter input should be in '''Client''' type
*'''killer:''' parameter input should be in '''Player''' type
*'''reason:''' parameter input should be in '''uint''' type
*'''reason:''' parameter input should be in '''uint''' type


Line 15: Line 15:
{{#tag:syntaxhighlight|
{{#tag:syntaxhighlight|
[ServerEvent(Event.PlayerDisconnected)]
[ServerEvent(Event.PlayerDisconnected)]
public void OnPlayerDeath(Client player, Client killer, uint reason)
public void OnPlayerDeath(Player player, Player killer, uint reason)
{
{
if (!killer.IsNull)
if (!killer.IsNull)

Revision as of 05:47, 9 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.PlayerDisconnected)]
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}).");
	}
}