Shared definition of the cw_item entity: a non-spawnable anim entity named Item with a networked item Index and an ENT:GetItemTable accessor.

Summary

Methods

Draw()client
Draws the item model unless the ItemEntityDraw hook or the item's OnDrawModel returns false.
Explode()server
Plays a glass impact effect and a soft impact sound at the entity's position.
Returns the item instance fetched for this entity through cw.entity:FetchItemTable.
Draws the item name, weight and space when the item entity is looked at.
Sets up physics, simple use and 25 health for the item entity.
Calls the item's OnEntityRemoved(entity) when the entity is removed and forgets the entity with item.RemoveItemEntity.
Applies damage above 5 to the entity's health and destroys it at zero health.
Makes the entity represent an item instance.
Sets up the networked Index integer holding the item's instance index.
Think()shared
Removes entities stuck in the world or without an item, and runs the item's OnEntityThink.
Always transmits the item entity to every client.

Methods

Draws the item model unless the ItemEntityDraw hook or the item's OnDrawModel returns false.

Plays a glass impact effect and a soft impact sound at the entity's position.

Returns the item instance fetched for this entity through cw.entity:FetchItemTable.

On the server this is overridden by the version in init.lua.

Returns

  • Item The item instance, or nil if it has not been fetched yet

Defined in

Draws the item name, weight and space when the item entity is looked at.

PaintItemTargetID must return true for anything to be drawn. The item's OnHUDPaintTargetID can draw extra lines and returns the new y, or false to stop drawing.

Parameters

  • x
  • y
  • alpha

Sets up physics, simple use and 25 health for the item entity.

Calls the item's OnEntityRemoved(entity) when the entity is removed and forgets the entity with item.RemoveItemEntity.

Applies damage above 5 to the entity's health and destroys it at zero health.

The item's OnEntityTakeDamage can return false to ignore the damage. Fires ItemEntityTakeDamage and, when destroyed, the item's OnEntityDestroyed and the ItemEntityDestroyed hook.

Parameters

  • damageInfo

Makes the entity represent an item instance.

Sets the item's model and skin, networks its index, calls the item's OnCreated(entity) and registers the entity with item.AddItemEntity. Does nothing when itemTable is nil.

Parameters

  • itemTable Item The item instance

Sets up the networked Index integer holding the item's instance index.

On the server

Removes entities stuck in the world or without an item, and runs the item's OnEntityThink.

OnEntityThink may return the number of seconds until the next think; the default is one second.

On the client

Requests the item data from the server until it arrives, then runs the item's OnEntityThink and the ItemEntityThink hook.

Defined in

Always transmits the item entity to every client.

Defined in