Garry's Mod Wiki

Entity:GetAnimInfo

  table Entity:GetAnimInfo( number animIndex )

Description

Returns a table containing the number of frames, flags, name, and FPS of an entity's animation ID.

Animation ID is not the same as sequence ID. See Entity:GetAnimCount

Arguments

1 number animIndex
The animation ID to look up

Returns

1 table
Information about the animation, or nil if the index is out of bounds

Example

A function that finds an entity sequence's corresponding animation and returns the animation info.

function GetAnimInfoSequence( ent, seq ) if( !IsValid( ent ) ) then return nil end local seqname = ent:GetSequenceName( seq ) if( seqname == "Unknown" ) then return nil end local info = nil local done = ent:GetAnimInfo(0).label -- this is how we know when to stop local i = 1 -- We don't want to increment too high or we will run into errors or possibly crashes while(i < 1600) do -- arbitrary failsafe info = ent:GetAnimInfo(i) if(string.find(info.label, "@"..seqname) or string.find(info.label, "a_"..seqname)) then return info end -- the first animation info is repeated when there are no animations left in the model if(info.label == done) then break end i = i + 1 end return nil end