HasPlayerGotWeaponComponent

From GT-MP
Jump to: navigation, search
HasPlayerGotWeaponComponent
Server-Side Function
Utilities-terminal.png Server-Side Csharp.png C#

This function checks if the specified weapon of the given player has the specified component.


Syntax

API.hasPlayerGotWeaponComponent(Client player, WeaponHash weapon, WeaponComponent component);

Required Arguments

  • player: parameter input should be in Client type.
  • weapon: parameter input should be in WeaponHash type.
  • component: parameter input should be in WeaponComponent type. See Weapons Components.

NOTE: This function returns data in bool type.

Usage example(s)

/suppcheck command that checks if you have a suppressor on your pistol or not.

[Command("suppcheck")]
public void CMD_SuppressorCheck(Client player)
{
    if (API.hasPlayerGotWeaponComponent(player, WeaponHash.Pistol, WeaponComponent.AtPiSupp02))
    {
        API.sendChatMessageToPlayer(player, "Your pistol is silenced.");
    }
    else
    {
        API.sendChatMessageToPlayer(player, "Your pistol is not silenced.");
    }
}

References