MTA:Eir/functions/getElementIPLIndex: Difference between revisions
Jump to navigation
Jump to search
Line 22: | Line 22: | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
local function entityClearHandler( entity ) | local function entityClearHandler( entity ) | ||
if not ( getElementIPLIndex( entity ) == 0 ) then | if ( isElementStreamedIn( entity ) ) and not ( getElementIPLIndex( entity ) == 0 ) then | ||
destroyElement( entity ); | destroyElement( entity ); | ||
end | end |
Revision as of 20:00, 11 December 2013
This function returns the IPL index of the given entity. If the IPL index is != 0, then the entity is managed by native GTA:SA, otherwise MTA. The IPL index can be used with getIPLSectorInfo to retrieve additional information.
An IPL sector is a zone on the native GTA:SA world. It stores dummies, buildings and objects. Its buildings and objects are created when streamed in and destroyed when streamed out.
This function is part of the discussion: shall buildings be made MTA entities?
Syntax
int getElementIPLIndex ( element entity )
Arguments
- entity: a streamed in MTA entity
Returns
Returns the IPL index associated with the given entity if it is streamed in, false otherwise.
Example
Click to collapse [-]
ClientThis snippet destroys all buildings that are managed by native GTA:SA (WIP; POD)
local function entityClearHandler( entity ) if ( isElementStreamedIn( entity ) ) and not ( getElementIPLIndex( entity ) == 0 ) then destroyElement( entity ); end end local function clearWorld() for m,n in ipairs( getElementsByType( "building" ) ) do entityClearHandler( n ); end for m,n in ipairs( getElementsByType( "dummy" ) ) do entityClearHandler( n ); end for m,n in ipairs( getElementsByType( "object" ) ) do entityClearHandler( n ); end end