MTA:Eir/functions/engineGetModelRefCount: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 12: Line 12:


===Returns===
===Returns===
Returns a '''true''' if modelIndex is a valid model info index and the model info that it points to is allocated, '''false''' otherwise.
Returns the model reference count if '''modelIndex''' is a valid model info index and the model info that it points to is allocated, '''false''' otherwise.


==Example==  
==Example==  

Revision as of 14:08, 29 March 2014

Template:*Client function

This function returns the reference count of a GTA:SA model info. The reference count describes how often a model info is used by the game (including MTA).

Syntax

int engineGetModelRefCount ( int modelIndex )

Arguments

  • modelIndex: value ranging from [0..19999] that denotes an internal model info

Returns

Returns the model reference count if modelIndex is a valid model info index and the model info that it points to is allocated, false otherwise.

Example

Click to collapse [-]
Client

This snippet destroys every MTA object whose model is used more than twice.

addEvent( "onClientElementModelSweep", true );
addEventHandler( "onClientElementModelSweep", root,
    function()
        for m,n in ipairs( getElementsByType( "object" ) ) do
            local refCount = engineGetModelRefCount( getElementModel( n ) );

            if ( refCount > 2 ) then
                destroyElement( n );
            end
        end
    end
);