OnPlayerWeaponSwitch: Difference between revisions
(Created page with "This event is triggered when a player changes weapon. {{CSharpContainer| {{#tag:syntaxhighlight| [ServerEvent(Event.PlayerWeaponSwitch)] |lang=csharp }} {{Parameters}} *'''p...") |
No edit summary |
||
| (One intermediate revision by one other user not shown) | |||
| Line 8: | Line 8: | ||
{{Parameters}} | {{Parameters}} | ||
*'''player:''' parameter input should be in ''' | *'''player:''' parameter input should be in '''Player''' type | ||
*'''oldWeapon:''' parameter input should be in '''WeaponHash''' type | *'''oldWeapon:''' parameter input should be in '''WeaponHash''' type | ||
*'''newWeapon:''' parameter input should be in '''WeaponHash''' type | *'''newWeapon:''' parameter input should be in '''WeaponHash''' type | ||
| Line 15: | Line 15: | ||
{{#tag:syntaxhighlight| | {{#tag:syntaxhighlight| | ||
[ServerEvent(Event.PlayerWeaponSwitch)] | [ServerEvent(Event.PlayerWeaponSwitch)] | ||
public void OnPlayerWeaponSwitch( | public void OnPlayerWeaponSwitch(Player player, WeaponHash oldWeapon, WeaponHash newWeapon) | ||
{ | { | ||
player.SendChatMessage($"You have swapped from {oldWeapon} to {newWeapon}.") | player.SendChatMessage($"You have swapped from {oldWeapon} to {newWeapon}."); | ||
} | } | ||
|lang=csharp}} | |lang=csharp}} | ||
Latest revision as of 05:48, 9 May 2023
This event is triggered when a player changes weapon.
C# Syntax
[ServerEvent(Event.PlayerWeaponSwitch)]
Parameters
- player: parameter input should be in Player type
- oldWeapon: parameter input should be in WeaponHash type
- newWeapon: parameter input should be in WeaponHash type
Example
[ServerEvent(Event.PlayerWeaponSwitch)]
public void OnPlayerWeaponSwitch(Player player, WeaponHash oldWeapon, WeaponHash newWeapon)
{
player.SendChatMessage($"You have swapped from {oldWeapon} to {newWeapon}.");
}