Garry's Mod Wiki

Entity:SelectWeightedSequence

  number Entity:SelectWeightedSequence( number act )

Description

Returns sequence ID corresponding to given activity ID.

Opposite of Entity:GetSequenceActivity.

Similar to Entity:LookupSequence.

See also Entity:SelectWeightedSequenceSeeded.

Arguments

1 number act
The activity ID, see ACT enum.

Returns

1 number
The sequence ID

Example

Use this hook to check if the model has a certain ACT_* enumeration, and if it does, play it.

local VModel = self:GetOwner():GetViewModel() if ( self:Clip1() == 0 and VModel:SelectWeightedSequence( ACT_VM_RELOAD_EMPTY ) ) then local SEQ = self:LookupSequence( ACT_VM_RELOAD_EMPTY ) if ( SEQ == -1 ) then print( "reload" ) local EnumToSeq = VModel:SelectWeightedSequence( ACT_VM_RELOAD ) -- Play the normal reload animation VModel:SendViewModelMatchingSequence( EnumToSeq ) else print( "reload empty" ) local EnumToSeq = VModel:SelectWeightedSequence( ACT_VM_RELOAD_EMPTY ) -- Play the empty reload animation VModel:SendViewModelMatchingSequence( EnumToSeq ) end end
Output: Will play the ACT_VM_RELOAD_EMPTY enumeration if the model has it. If not, it will play the normal reload enum.