PlayerWeaponShot
This event is called every time a player shoots a weapon.
Client-Side Event
C# | JavaScript |
---|
C# Syntax
public delegate void OnPlayerWeaponShotDelegate(Vector3 targetPos, Player target, CancelEventArgs cancel);
Parameters
- targetPos - the position of the target, expects RAGE.Vector3
- target - the target player, expects RAGE.Elements.Player
- cancel - cancel, expects RAGE.Events.CancelEventArgs
Example
The example below shows a chat message to the client when they shoot a weapon
Events.OnPlayerWeaponShot += OnPlayerWeaponShot;
public void OnPlayerWeaponShot(RAGE.Vector3 targetPos, RAGE.Elements.Player target, RAGE.Events.CancelEventArgs cancel)
{
RAGE.Chat.Output($"You shot a weapon");
}
JavaScript Syntax
mp.events.add('playerWeaponShot', (targetPosition, targetEntity) => {});
Parameters
- targetPosition: Target's position, output expects a Vector3 type.
- targetEntity: Target's entity, output expects any type. Returns undefined if no target entity.
Example
The example below prints a message to the player's chat every time the player fires a weapon.
mp.events.add('playerWeaponShot', (targetPosition, targetEntity) => {
mp.gui.chat.push('You fired a weapon!');
});