Defines the ammo_base base item for ammunition: using one gives ammoAmount rounds of ammoClass if the player carries a weapon that takes that ammo.

Each instance has a networked Rounds data field, and the item's weight and space scale with the rounds left.

Summary

Methods

Returns the tooltip line showing how many rounds the item holds.
Returns the item's inventory space scaled by the rounds left out of ammoAmount.
Returns the item's weight scaled by the rounds left out of ammoAmount.
Called when a player drops the ammo; does nothing, so dropping is allowed.
Sets the new instance's Rounds data from the item's ammoCount field.
Gives ammoAmount rounds of ammoClass if the player carries a weapon that uses it, consuming the item.

Methods

Returns the tooltip line showing how many rounds the item holds.

Returns

  • String Markup line with roundsText and ammoAmount

Returns the item's inventory space scaled by the rounds left out of ammoAmount.

Returns

  • Number The space taken by the remaining rounds

Returns the item's weight scaled by the rounds left out of ammoAmount.

Returns

  • Number The weight of the remaining rounds

ITEM:OnDrop(player, position)

shared gamemodes/catwork/gamemode/core/items/sh_ammo_base.lua:56

Called when a player drops the ammo; does nothing, so dropping is allowed.

Parameters

  • player
  • position

Sets the new instance's Rounds data from the item's ammoCount field.

ITEM:OnUse(player, itemEntity)

shared gamemodes/catwork/gamemode/core/items/sh_ammo_base.lua:30

Gives ammoAmount rounds of ammoClass if the player carries a weapon that uses it, consuming the item.

Parameters

  • player
  • itemEntity

Returns

  • Boolean false (keeping the item) when no carried weapon uses this ammo, otherwise nil

Defined in