MTA:Eir/functions/engineGetModelRefCount

From Multi Theft Auto: Wiki
Revision as of 01:42, 12 January 2014 by Qaisjp (talk | contribs)
Jump to navigation Jump to search

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 a true 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
);