RemovePlayerWeapon

From GT-MP
Jump to: navigation, search
RemovePlayerWeapon
Shared Function
Utilities-terminal.png Server-Side System-users.png Client-Side
Csharp.png C# Javascript.png JavaScript

This function will remove the given weapon from the given player.


Syntax

In C#
Server-Side Function

void API.removePlayerWeapon(Client player, WeaponHash weapon);

Required Arguments

  • player: parameter input should be in Client type.
  • weapon: parameter input should be in WeaponHash type.
Dialog-warning.png Note: This feature is currently not in the API, or is currently not accurate on the wiki due to upcoming API changes. New API functions and changes will be released with the next update.

NOTE: This function returns data in bool type.

Usage example(s)

/discardwep command that removes the weapon the player is holding:

In C#
Server-Side Function

[Command("discardwep")]
public void CMD_DiscardWep(Client player)
{
    WeaponHash weapon = API.getPlayerCurrentWeapon(player);

    if (weapon == WeaponHash.Unarmed)
    {
        API.sendChatMessageToPlayer(player, "You're not holding a weapon.");
        return;
    }

    API.removePlayerWeapon(player, weapon);
}

References