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

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


In C#
Server-Side Function

API.getPlayerCurrentWeapon(Client player);

Required Arguments

  • player: parameter input should be in Client type.

NOTE: This function returns data in WeaponHash type.

In Javascript
Client-Side Function


This returns the current weapon for the local player.

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.

public void CheckGun(Client player)
     WeaponHash hashcode = API.getPlayerCurrentWeapon(player);
     API.sendChatMessageToPlayer(player, "You have a weapon with hash code " + (int)hashcode + "!");
     API.sendChatMessageToPlayer(player, "The weapon name is " + hashcode + "!");

If the player is not using any weapon, it will display: "You have a weapon with has code -1569615261!" "The weapon name is Unarmed!"