Entity.EntIndex

From GMod Wiki

Revision as of 19:52, 29 October 2009 by Crazy Quebecer (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Function
Syntax Entity:EntIndex( )
Description:
Returns the ID an entity is using - this was entid in GMod 9.
Returns: Integer
In Object: Entity
Realm: NewerShared.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=Entity.EntIndex]Entity.EntIndex [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]



Examples

DescriptionIn this example we'll add all spawn points to a table using the entity index as the key.
Used onNewerServer.png
Code
 
function GetSpawnpoints()
    -- First create the table we're storing the player entities in.
    local pTable = {}
 
    -- Then loop through every spawn point found in the map.
    for k,v in pairs(ents.FindByClass("info_player_start")) do
        -- Set the variable 'idx' to the player's entity index.
        local idx = v:EntIndex() 
 
        -- Using the index as the key, add the entity (val) to the table.
        pTable[idx] = v
    end
 
    -- Return our filled table!
    return pTable
end
 
OutputA table filled with spawn points indexed by their entity ID.


Additional Notes

See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox