getPedWeapon | Multi Theft Auto: Wiki Skip to content

getPedWeapon

Client-side
Server-side
Shared

Manual Review Required

Please finish this page using the corresponding Old Wiki article. Go to Contribution guidelines for more information.


This function tells you which weapon type is in a certain weapon slot of a ped.

OOP Syntax Help! I don't understand this!

  • Method:ped:getWeapon(...)

Syntax

int getPedWeapon ( ped thePed, [ int weaponSlot = current ] )
Required Arguments
  • thePed: the ped you want to get the weapon type from.
Optional Arguments

NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use.

  • weaponSlot (default: current): an integer representing the weapon slot (set to the ped's current slot if not given).

Returns

  • int: value

Returns an int indicating the type of the weapon the ped has in the specified slot. If the slot is empty, it returns 0.

Code Examples

shared
-- Find a player called someguy and find his current weapon id.
local weaponType = getPedWeapon ( getRandomPlayer() )
-- If a weapon type was returned then
if ( weaponType ) then
outputChatBox ( "someguy's current Weapon-type: " .. weaponType .. "." ) -- Display the weapon type in the chat box
end

See Also