PlayerWeaponShot: Difference between revisions
(Created page with "{{ClientSide}} This event is called everytime a player shoots a weapon. == Syntax == <syntaxhighlight lang="javascript"> mp.events.add('playerWeaponShot', (targetPosition,...") |
No edit summary |
||
| Line 1: | Line 1: | ||
{{ | This event is called every time a player shoots a weapon. | ||
{{ClientsideCsJsEvent}} | |||
{{CSharpContainer| | |||
<syntaxhighlight lang="c#"> | |||
public delegate void OnPlayerWeaponShotDelegate(Vector3 targetPos, Player target, CancelEventArgs cancel); | |||
</syntaxhighlight> | |||
{{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 | |||
== | <syntaxhighlight lang="c#"> | ||
Events.OnPlayerWeaponShot += OnPlayerWeaponShot; | |||
</syntaxhighlight> | |||
<syntaxhighlight lang="c#"> | |||
public void OnPlayerWeaponShot(RAGE.Vector3 targetPos, RAGE.Elements.Player target, RAGE.Events.CancelEventArgs cancel) | |||
{ | |||
RAGE.Chat.Output($"You shot a weapon"); | |||
} | |||
</syntaxhighlight> | |||
}} | |||
{{JSContainer| | |||
<syntaxhighlight lang="javascript"> | <syntaxhighlight lang="javascript"> | ||
mp.events.add('playerWeaponShot', (targetPosition, targetEntity) => {}); | mp.events.add('playerWeaponShot', (targetPosition, targetEntity) => {}); | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{Parameters}} | |||
* '''targetPosition''': Targetted position, output expects a | * '''targetPosition''': Targetted position, output expects a '''[[Vector3::Vector3|Vector3]]''' type. | ||
* '''targetEntity''': Targetted entity, output expects | * '''targetEntity''': Targetted entity, output expects '''any''' type. | ||
{{Example}} | |||
The example below prints a message in player's screen everytime he shots a weapon. | The example below prints a message in player's screen everytime he shots a weapon. | ||
| Line 22: | Line 41: | ||
}); | }); | ||
</syntaxhighlight> | </syntaxhighlight> | ||
}} | |||
Revision as of 11:09, 29 November 2018
This event is called every time a player shoots a weapon.
Client-Side Event
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: Targetted position, output expects a Vector3 type.
- targetEntity: Targetted entity, output expects any type.
Example
The example below prints a message in player's screen everytime he shots a weapon.
mp.events.add('playerWeaponShot', (targetPosition, targetEntity) => {
mp.gui.chat.push('You fired a weapon!');
});