GetPlayerWeapon
From SA-MP Wiki
(Difference between revisions)
Revision as of 08:41, 24 April 2014 Vince (Talk | contribs) ← Previous diff |
Revision as of 10:08, 23 January 2017 RoboN1X (Talk | contribs) (Example) Next diff → |
||
Line 12: | Line 12: | ||
public OnPlayerDeath(playerid, killerid, reason) | public OnPlayerDeath(playerid, killerid, reason) | ||
{ | { | ||
- | if(GetPlayerWeapon(killerid) == 38) Ban(killerid); //Ban if they have a minigun | + | if(killerid != INVALID_PLAYER_ID) |
+ | { | ||
+ | if(GetPlayerWeapon(killerid) == 38) Ban(killerid); //Ban if they have a minigun | ||
+ | } | ||
return 1; | return 1; | ||
} | } |
Revision as of 10:08, 23 January 2017
Description:
Returns the ID of the weapon a player is currently holding.
(playerid)
playerid | The 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; }
Related Functions
The following functions may be useful, as they are related to this function in one way or another.
- GetPlayerWeaponData: Find out information about weapons a player has.
- GivePlayerWeapon: Give a player a weapon.
- ResetPlayerWeapons: Remove all weapons from a player.