player.get_weapon

a.k.a. player.try_get_weapon

This function can be used to access a player's readied or holstered weapon.

When Bungie and 343i use this function, they often manually clear the object variable they are assigning to before calling the function. However, reverse-engineering of the game engine suggests that this is not actually necessary; the game will always properly return a value when this function is called.

This function returns object. Calling this function without storing its return value in a variable is an error.

Arguments

which

Any one of the following values

primary
The weapon that the player is currently using
secondary
The weapon that the player has holstered.

Example

--
-- Delete the player's weapon if it is not a Gravity Hammer:
--
for each player do
   global.object[0] = current_player.get_weapon(secondary)
   if not global.object[0].is_of_type(gravity_hammer) then
      global.object[0].delete()
   end
   global.object[0] = current_player.get_weapon(primary)
   if not global.object[0].is_of_type(gravity_hammer) then
      global.object[0].delete()
   end
end

Notes

See also