GetPlayerWeapons

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

Returns an array of weapon hashes that contains all the weapons the player is currently holding.


Syntax

API.getPlayerWeapons(Client player);

Required Arguments

  • player: parameter input should be in Client type.

NOTE: This function returns data in WeaponHash[] type.

Usage example(s)

/myweapons command that lists all of your weapons:

[Command("myweapons")]
public void CMD_MyWeapons(Client player)
{
    API.sendChatMessageToPlayer(player, "Your weapons:");

    WeaponHash[] player_weapons = API.getPlayerWeapons(player);
    foreach (WeaponHash weapon in player_weapons)
    {
        API.sendChatMessageToPlayer(player, "-> " + weapon);
    }
}

References