Entity/SelectWeightedSequence

From Garry's Mod
Jump to: navigation, search
 Entity:SelectWeightedSequence( )

Contents

Description

Returns sequence ID corresponding to given activity ID.

Opposite of Entity:GetSequenceActivity.

Similar to Entity:LookupSequence.

See also Entity:SelectWeightedSequenceSeeded.

Arguments

number act

The activity ID, see ACT_ Enums.

Returns

number

The sequence ID

Examples

Example

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

local VModel = self.Owner: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.
Personal tools
Navigation