The entity that represents an item instance lying in the world.
Item.spawn creates it and ties the instance to it with set_item, which gives the
entity the model, skin, color and bodygroups of the item. Pressing the use key on it
briefly opens the menu of the item for the player; holding the key for half a second
takes the item. A client asks the server for the item of the entity once the entity
reaches it, and draws the name and the description of the item as its target ID.
The entity remembers the character that dropped it (set_dropper, get_dropper). It
has the health that ItemBase:get_entity_health returns for its item: with health
above 0 it takes damage and, once the health is gone, the item is destroyed, which the
ItemEntityTakeDamage and ItemEntityDestroyed hooks tell about. It also calls the
on_entity_think, on_entity_draw, on_entity_removed, on_entity_take_damage and
on_entity_destroyed callbacks of its item.
Summary
Methods
Methods
Destroys the item of the entity: calls the on_entity_destroyed callback of the item, runs the 'ItemEntityDestroyed' hook, plays the break effect and removes the entity along with the item instance.
Parameters
- damage_info CTakeDamageInfo optional, defaults to
nilthe damage that has destroyed the item
Draws the model of the item, unless the on_entity_draw callback of the item returns false.
Draws the name and the description of the item when the local player looks at it up close. Requests the item from the server and draws a loading cog if it is not known yet.
Parameters
- x Number screen position
- y Number screen position
- distance Number distance between the local player and the entity
Returns who has dropped the item.
Returns
- Map table with character_id (Number, nil if the player had no character) and steam_id (String) fields, or nil if no player has dropped the item
On the server
Sets up the physics and the use type of the item entity.
On the client
Asks the server for the item of the entity as soon as the entity reaches the client.
Defined in
Checks whether the item can be destroyed by damage, which it can if the entity was given health when the item was set.
Returns
- Boolean
ENT:is_dropped_by_other_character(actor)
server plugins/items/plugin/entities/entities/fl_item.lua:172Checks whether the item was dropped by a character of the player other than the one they are playing now.
Parameters
- actor Player
Returns
- Boolean
Calls the on_entity_think callback of the item once a second, or after as many seconds as the callback has returned the last time, 0.1 at least.
Calls the on_entity_removed callback of the item when the entity is being removed.
Takes health off the item for the damage it receives and destroys the item once no health is left. The on_entity_take_damage callback of the item and the 'ItemEntityTakeDamage' hook can ignore the damage or change it. Both are asked even if the item is not destructible, in which case nothing happens to it afterward.
Parameters
- damage_info CTakeDamageInfo
Clears the hold of the player who is holding the use key on the item, if there is one, so that their pickup progress does not stay on the screen once the entity is gone.
Queues a request to the server for the item of the entity, at most once every two seconds. The queue is sent at a rate the server accepts, so that every entity gets its item even when many reach the client at once.
Sets who has dropped the item. Only the character and the SteamID of the player are kept, so that the entity remembers them after the player has left and after the server has restarted.
Parameters
- dropper Player/Map the player who dropped the item, or a table with the character_id and steam_id fields; anything else makes the entity forget its dropper
Ties an item instance to the entity, applying its model, skin, color, bodygroups and health, and tells the clients that know the item about it.
Parameters
- item_obj Item
Returns
- Boolean false if no item was given, nothing otherwise
On the server
Makes the player take the item once they have held the use key on it for half a second, and lets the item think.
On the client
Lets the item think.
Defined in
ENT:Use(activator, caller, use_type, _value)
server plugins/items/plugin/entities/entities/fl_item.lua:72Tracks how long the player holds the use key on the item. Releasing the key in under half a second runs the 'PlayerUseItemEntity' hook.
Parameters
- activator Entity the entity that pressed the use key, normally a Player
- caller Entity
- use_type Number USE_ enumerator
- _value Number