EntityDestroyed: Difference between revisions
mNo edit summary |
mNo edit summary |
||
| (5 intermediate revisions by 2 users 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| | |||
{{Parameters}} | |||
* '''entity''': {{RageType|Entity}} | |||
{{Example}} | |||
<syntaxhighlight lang="javascript"> | <syntaxhighlight lang="javascript"> | ||
mp.events.add("entityDestroyed", entity => { | mp.events.add("entityDestroyed", entity => { | ||
| Line 10: | Line 14: | ||
}); | }); | ||
</syntaxhighlight> | </syntaxhighlight> | ||
}} | |||
{{ClientsideCsEvent}} | |||
{{CSharpContainer| | |||
<syntaxhighlight lang="csharp"> | |||
public delegate void OnEntityDestroyedDelegate(Entity entity); | |||
</syntaxhighlight> | |||
{{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. | |||
<syntaxhighlight lang="csharp"> | |||
Events.OnEntityDestroyed += OnEntityDestroyed; | |||
</syntaxhighlight> | |||
<syntaxhighlight lang="csharp"> | |||
public void OnEntityDestroyed(RAGE.Elements.Entity entity) | |||
{ | |||
RAGE.Chat.Output($"{entity.Model} destroyed at {entity.Position} with serverside id:{entity.RemoteId}"); | |||
} | |||
</syntaxhighlight> | |||
}} | |||
== See also == | |||
* [[entityCreated]] | |||
* [[entityModelChange]] | |||
[[Category:Entity API]] | |||
[[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}");
}