EntityDestroyed: Difference between revisions

From RAGE Multiplayer Wiki
m (category)
mNo edit summary
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
{{note|Doesn't work in 1.1.}}
Event triggered when an entity is destroyed
Event triggered when an entity is destroyed
{{ServersideCsJsEvent}}
 
{{ServersideJsEvent}}
 
{{JSContainer|
{{JSContainer|
{{Parameters}}
{{Parameters}}
* '''entity'''
* '''entity''': {{RageType|Entity}}
 
{{Example}}
{{Example}}
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
Line 11: Line 15:
</syntaxhighlight>
</syntaxhighlight>
}}
}}
{{ClientsideCsEvent}}
{{ClientsideCsEvent}}
{{CSharpContainer|
{{CSharpContainer|
<syntaxhighlight lang="c#">
<syntaxhighlight lang="csharp">
public delegate void OnEntityDestroyedDelegate(Entity entity);
public delegate void OnEntityDestroyedDelegate(Entity entity);
</syntaxhighlight>
</syntaxhighlight>
{{Parameters}}
{{Parameters}}
* '''entity''' - the destroyed entity, expects '''RAGE.Elements.Entity'''
* '''entity''' - the destroyed entity, expects '''RAGE.Elements.Entity'''
Line 21: Line 28:
{{Example}}
{{Example}}
The example below sends a message to client when an entity is destoryed, showing the entity model, position and remoteId.
The example below sends a message to client when an entity is destoryed, showing the entity model, position and remoteId.
<syntaxhighlight lang="c#">
<syntaxhighlight lang="csharp">
Events.OnEntityDestroyed += OnEntityDestroyed;
Events.OnEntityDestroyed += OnEntityDestroyed;
</syntaxhighlight>
</syntaxhighlight>
<syntaxhighlight lang="c#">
<syntaxhighlight lang="csharp">
public void OnEntityDestroyed(RAGE.Elements.Entity entity)
public void OnEntityDestroyed(RAGE.Elements.Entity entity)
{
{
Line 32: Line 39:
}}
}}


== See also ==
* [[entityCreated]]
* [[entityModelChange]]


[[Category:Entity API]]
[[Category:Entity API]]
[[Category:Server-side Event]]
[[Category:Server-side Event]]

Latest revision as of 07:12, 21 May 2022

Doesn't work in 1.1.

Event triggered when an entity is destroyed

Server-Side
Event

 JavaScript



JavaScript Syntax

Parameters

  • entity: Entity

Example

mp.events.add("entityDestroyed", entity => {
  // Do what you want
});


Client-Side
Event

 C#




C# Syntax

public delegate void OnEntityDestroyedDelegate(Entity entity);

Parameters

  • entity - the destroyed entity, expects RAGE.Elements.Entity

Example

The example below sends a message to client when an entity is destoryed, showing the entity model, position and remoteId.

Events.OnEntityDestroyed += OnEntityDestroyed;
public void OnEntityDestroyed(RAGE.Elements.Entity entity)
{
   RAGE.Chat.Output($"{entity.Model} destroyed at {entity.Position} with serverside id:{entity.RemoteId}");
}


See also