EntityDestroyed: Difference between revisions
mNo edit summary |
No edit summary |
||
| Line 1: | Line 1: | ||
Event triggered when an entity is destroyed | Event triggered when an entity is destroyed | ||
{{ServersideCsJsEvent}} | |||
{{JSContainer| | |||
{{Parameters}} | |||
* '''entity''' | * '''entity''' | ||
{{Example}} | |||
<syntaxhighlight lang="javascript"> | <syntaxhighlight lang="javascript"> | ||
mp.events.add("entityDestroyed", entity => { | mp.events.add("entityDestroyed", entity => { | ||
| Line 10: | Line 10: | ||
}); | }); | ||
</syntaxhighlight> | </syntaxhighlight> | ||
}} | |||
{{ClientsideCsEvent}} | |||
{{CSharpContainer| | |||
<syntaxhighlight lang="c#"> | |||
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="c#"> | |||
Events.OnEntityDestroyed += OnEntityDestroyed; | |||
</syntaxhighlight> | |||
<syntaxhighlight lang="c#"> | |||
public void OnEntityDestroyed(RAGE.Elements.Entity entity) | |||
{ | |||
RAGE.Chat.Output($"{entity.Model} destroyed at {entity.Position} with serverside id:{entity.RemoteId}"); | |||
} | |||
</syntaxhighlight> | |||
}} | |||
Revision as of 14:42, 29 November 2018
Event triggered when an entity is destroyed
Server-Side Event
JavaScript Syntax
Parameters
- 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}");
}