EntityDestroyed: Difference between revisions
m (category) |
mNo edit summary |
||
| (3 intermediate revisions 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 | ||
{{ | |||
{{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=" | <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=" | <syntaxhighlight lang="csharp"> | ||
Events.OnEntityDestroyed += OnEntityDestroyed; | Events.OnEntityDestroyed += OnEntityDestroyed; | ||
</syntaxhighlight> | </syntaxhighlight> | ||
<syntaxhighlight lang=" | <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: | [[Category:Entity API]] | ||
[[Category:Server-side Event]] | [[Category:Server-side Event]] | ||
Latest revision as of 07:12, 21 May 2022
Event triggered when an entity is destroyed
Server-Side Event
JavaScript Syntax
Parameters
- entity: Entity
Example
mp.events.add("entityDestroyed", entity => {
// Do what you want
});
Client-Side Event
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}");
}