Events
For custom events see Custom Events.
Event articles
- WeaponDamage
- Explosion
- Checkpoint
- AnyResourceStart
- AnyResourceStop
- AnyResourceError
- Player events
- Vehicle events
Events can be registered via scripts or dynamically via event delegates. This documentation is registering events via delegates dynamically.
To add for example a player connect event handler dynamically you can just add the delegate that will be called when a player connects.
This is a example using the lambda operator to add a event handler.
Alt.OnPlayerConnect += (player, reason) => {
Console.WriteLine($"{player.Name} connected.");
};
Its also possible to add a method instead of using a lambda. The method can be private, public, static ect.
Alt.OnPlayerConnect += OnPlayerConnect;
...
public void OnPlayerConnect(IPlayer player, string reason)
{
Console.WriteLine($"{player.Name} connected.");
}
You should not register event handlers in async code.
Below is a list of all event handlers.
Warning
It looks like the sample you are looking for does not exist.
Below is a list of all event handler method signatures.
Warning
It looks like the sample you are looking for does not exist.
The player event handler looks like this.
Alt.OnPlayerEvent += (player, name, args) => {
};
For automated arguments validating you can use Custom Events.