MTA:Eir/functions/getElementIPLIndex

From Multi Theft Auto: Wiki
Jump to navigation Jump to search

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 [-]
Client

This 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