GetPlayerCurrentWeapon: Difference between revisions

From RAGE Multiplayer Wiki
(Created page with "This function will tell you which weapon has the player in the hand. See also Weapons Models. ==Syntax== <syntaxhighlight lang="C#" >WeaponHash NAPI.Player.GetPlayerCurre...")
 
No edit summary
 
Line 2: Line 2:


==Syntax==
==Syntax==
<syntaxhighlight lang="C#" >WeaponHash NAPI.Player.GetPlayerCurrentWeapon(Client player);</syntaxhighlight>
<syntaxhighlight lang="C#" >WeaponHash NAPI.Player.GetPlayerCurrentWeapon(Player player);</syntaxhighlight>


'''Required Arguments'''
'''Required Arguments'''
*'''player:''' parameter input should be in '''Client''' type.
*'''player:''' parameter input should be in '''Player''' type.


'''NOTE:''' This function returns data in '''WeaponHash''' type.
'''NOTE:''' This function returns data in '''WeaponHash''' type.
Line 13: Line 13:
<syntaxhighlight lang="C#" >
<syntaxhighlight lang="C#" >
[Command("checkweapon")]
[Command("checkweapon")]
public void CheckGun(Client player)
public void CheckGun(Player player)
{
{
     WeaponHash hashcode = NAPI.Player.GetPlayerCurrentWeapon(player);
     WeaponHash hashcode = NAPI.Player.GetPlayerCurrentWeapon(player);

Latest revision as of 21:48, 22 December 2022

This function will tell you which weapon has the player in the hand. See also Weapons Models.

Syntax

WeaponHash NAPI.Player.GetPlayerCurrentWeapon(Player player);

Required Arguments

  • player: parameter input should be in Player type.

NOTE: This function returns data in WeaponHash type.

Usage example(s)

The example shows an in-game command which will first print out the actual hash code number and on the next line it will display the name of the weapon in use.

[Command("checkweapon")]
public void CheckGun(Player player)
{
     WeaponHash hashcode = NAPI.Player.GetPlayerCurrentWeapon(player);
     NAPI.Chat.SendChatMessageToPlayer(player, "You have a weapon with hash code " + (int)hashcode + "!");
     NAPI.Chat.SendChatMessageToPlayer(player, "The weapon name is " + hashcode + "!");
}