G.Entity
From GMod Wiki
| Function | |
| Syntax |
Entity( Number index ) Where is this used? |
| Description: | |
| Mainly used for debugging code in the console, retrieves an entity object based upon it's entindex. Works in exactly the same way as ents.GetByIndex and works with any entity type. | |
| Returns: | Entity object. |
| Part of Library: | Global Functions |
| Realm: |
|
| BBCode Link: | [b][url=http://wiki.garrysmod.com/?title=G.Entity]G.Entity [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] |
Examples
| Description | This example prints out the entities class when entered into the console |
|---|---|
| Used on | |
| Code | lua_run print( Entity( 1 ):GetClass() ) |
| Output | 'player' printed in console. |
Additional Notes
- Entity(0) performs the same function as GetWorldEntity
- Entity IDs are automatically set aside for the max number of players.
So if you have a maximum of 8 players, Entity(1) through Entity(8) are players, followed by world entities.