GetPlayerWeapon

From SA-MP Wiki

Jump to: navigation, search


Description:

Returns the ID of the weapon a player is currently holding.


Parameters:
(playerid)
playeridThe ID of the player to get the currently held weapon of.


Return Values:

The ID of the player's current weapon. Returns -1 if the player specified does not exist.


Example Usage:

public OnPlayerDeath(playerid, killerid, reason)
{
    if(killerid != INVALID_PLAYER_ID)
    {
        if(GetPlayerWeapon(killerid) == 38) Ban(killerid); //Ban if they have a minigun
    }
    return 1;
}
Image:32px-Circle-style-warning.png

Important
Note

Sometimes the result can be -1 which is an invalid weapon ID. Circumstances of this are not yet known, but it is best to discard information when returned weapon is -1.


Image:32px-Ambox_warning_orange.png

Note

When the player state is PLAYER_STATE_DRIVER or PLAYER_STATE_PASSENGER this function returns the weapon held by the player before they entered the vehicle. If a cheat is used to spawn a weapon inside a vehicle, this function will not report it.


Related Functions

The following functions may be useful, as they are related to this function in one way or another.

Personal tools
In other languages